Recto: In Case Programming Isn’t Hard Enough

There’s long been a push to stop writing code as a sequence of lines and go to something graphical, which has been very successful in some areas and less so in others. But even when you use something graphical like Scratch, it is really standing in for lines of code? Many graphical environments are really just interface builders, and you still write traditional code underneath. [Masato Hagiwara] asks the question: Can you write code that is actually a 2D graphic? Where the graphical layout isn’t a cover for code, but is the code itself? His answer is Recto.

Whereas a C program, for example, has a syntactical structure of lines, a Recto program has rectangles. Rectangles can contain data, and their structure naturally mimics the kinds of structures we usually use: columns, rows, matrices, and so on. Rectangles can also contain… wait for it… other rectangles. Special rectangles act as dictionaries or sets.

We thought this sort of reminded us of Lisp, and, in fact, [Hagiwara] makes that clear later in the post. The real problem is how do you…write? draw?… this kind of code? At first, he laid it out in a spreadsheet before compilation. Now he’s built an editor for it, and you can try it in your browser. There’s also a limited-feature compiler that can handle simple programs.

[Hagiwara] goes on to show how this representation would work for natural human languages, too. Honestly, we have enough trouble with English and the few other human languages we struggle with, but it is interesting to contemplate.

If you like strange languages, there’s Piet. Not that either of these is the weirdest we’ve ever seen.

20 thoughts on “Recto: In Case Programming Isn’t Hard Enough

  1. We do write graphical code where it makes sense: simulink, scicos, “ladders” in plc.
    Few years back I was supposed to “write software” for PLC to control pneumatic hammers. Code was simple – each hammer was controlled by one DO – all in all 32 hammers. One by one to be triggered every X seconds (where X is either 10 or 20 sec.).
    Anyway – Codesys (i think it was it) allowed to choose which language I want to use. I chose pascal style code to make it short and easy to write. But my boss wanted to use some “diagram style graphs” (not even ladder). It took me much more time and it was much less readable.

  2. Recto looks like someone was trying to make whitespace even more important than in Python, but didn’t want to go all the way to the actual Whitespace programming language.

  3. Programming — writing program code, that is — is really simple. What’s not so straightforward is articulating the problem and stating it in a form that’s logical and obvious. No amount of ‘language du jour’ will fix this basic fact of life.

    1. This is a very important point that ought to be obvious but is not appreciated as much as it should be.

      I see it particularly in new programmers who are fresh out of their studies and have never written real production code, just toy projects and academic stuff. They can pick up the language syntax and concepts very quickly, but working out how to structure their thoughts about what the code has to do and express that in the language is much harder, and takes time to learn.

    2. You mean like pulling the hardware data sheets, figuring out what registers do what, what bits need to set/cleared in what order, what hex masks to use. And then write the interrupt handler to do the right thing? Simple … Right? ;) or using the PIO and DMA in a Pico… Yeah, a = b + c is simple … IF that is the ‘correct’ formula for what you are trying to do ;) . Oh, and then using the correct (or good enough) data structure for the problem ( array, linked lists, red-black trees, hashing, randomization, sort method, etc.) So simple? Depends on one’s point of view and what the problem is…

  4. +1, Have done quite a bit of Labview work. It gets very little respect among programmers, but if you look at it, all the pieces of a text based language are there. The GUI integration is what makes it useful to me.

  5. My goal is the opposite : creating the most powerful , succinct , personal programming language & environment possible .
    https://CoSy.com is a timestamped notekeeping environment built & commanded in array language evolved from APL , via K , in open to the
    chip Forth whitespace delimited RPN where any line in your notes , including defining new words , can be evaluated simply by tapping F6 instead of ` Enter .

    I’ll admit , I can’t figure out what the hell that jumble above does — which I guess is its point .

    I will comment that Ken Iverson considered one of his significant accomplishments linearizing math notation into an executable string .

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.