"Literate" Ludus #98
Labels
No Label
accepted
bug
clj
documentation
enhancement
errors
infrastructure
later
next
now
optimization
proposal
question
research
semantics
syntax
ux
vm
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: twc/ludus#98
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The idea here is that there should be some kind of document that includes prose, code, and some other stuff. The prose should be readable, the code should be runnable, and the other stuff should do what we need it to.
The idea is, perhaps, something like Observable, like a Jupyter notebook, or like Literate Scribble.
A few thoughts come to mind immediately:
A few open questions:
From a design perspective, the obvious first place is a canonical, textual document that can be written, put under source control, etc.
Three possibilities come to mind right away:
First, just use a (very lightly modified?) markdown format & file:
This has a few advantages: you can just parse the thing with your usual markdown parser; markdown is readable as text; it's a widely-known standard, and thus highly searchable; it's text-forward, which is to say, you just start writing text, and code becomes the special case, which is nice for authoring things.
Additionally, this allows for different blocks to have names. This may or may not be an advantage.
Second, you could modify Ludus to include markdown in an ergonomic way:
This also has a few advantages. With the "block comment"
&&&
-fencing strategy, all Ludus notebooks are just Ludus files. This comes with many of the same benefits as the first "just markdown" strategy.These have one major difference between them. In the first, you can see the named Ludus block. The idea here is that there's a single markdown file (the "toplevel" is textual, as it were), which includes multiple Ludus blocks, which presumably each get their own scope. In the second, the toplevel is Ludus: all the code is a single script, and thus executed all at once.
It's not at all clear to me which is better. Clearly the "separate code blocks" is more powerful in some sense, although it does require an engine of some kind beyond a Ludus interpreter to manage the relationships between blocks. Meanwhile, the "single script" keeps things less abstracted and complex.
Third, there's the possibility of creating a system from scratch, maybe something like Racket's Scribble (linked above). This, of course, allows for a more flexible system, that may well make things like references or marginal comments, or similarly not-web-standard textual factors far easier to deal or work with.
Clearly, the design space is huge. We could go anywhere from a few extensions to markdown to full-on DSL territory. What would a Ludus-ish DSL look like in this case? What would the principles be?
One simple version could be something akin to Clojure's hiccup, but with semantic-ish meanings rather than mapping to HTML. So, e.g.,
You get the gist. These could be "tuples" or "lists" (parens or brackets; probably brackets, since they're less common in prose), but the thought is that something like this is extremely straightforward to parse, and extremely straightforward to render into HTML (which will be our target).
In other words, while there's a set of design problems here, to look into (using Scribble, Hiccup, Markdown as having solved related problems), the technical issues for this textual format are actually extremely straightforward: parsing is easy, outputting HTML is easy, CSS formatting is easy, the set of things we'd want & need are domain specific and fairly restricted.
(Also, there's a big benefit here to the idea that, by swapping out bare text with strings, we'd have something like a basic HTML library for Ludus that models markup with lists and keywords and dicts. That's a nice touch.)
That said (and still in other words), the more difficult design issues is the mapping between an HTML front-end that renders the textual format (say,
.ldn
, for Ludus notebook), and the actual textual back-end. Where does interactivity lie? Do we try to make the different code blocks hot-reloading? Or do we follow Ludus's extremely strict approach to mutation and change? How do we think about and model, in code and on the page, different turtle graphics drawings? Different consoles? Or do we have a code-and-prose pane on the left, and drawings-and-console pane on the right, very much like we have now?Conversation with @matt: Looks like the first version of "Ludus as a host in markdown" is the most promising approach here: it will already work with all the parsers.
Also, perhaps we have a version of Ludus shebang in a markdown file that means that Ludus can know this is executable as Ludus.
For reference: https://observablehq.com/framework/
Observable's open source SSG based on markdown
Next steps:
a. Command line execution
b. web.ludus.dev notebook format
c. Test against pandoc output