sequential and the power of selfie programs
See the picture above. It shows…
a tiny program whose output is written on the program itself.
For this to happen, the program needs to have a way to store its output in a section of the code which is ignored by the compiler or interpreter (for example, in a comment)
I call these programs: selfie programs. #selfieprogram
Selfie programs are immensely powerful, showing at one glance what might require an otherwise long-winded description.
Here are some examples:
Selfie programs are not new
People have been using them for ever, without a need for formalising their notation.
A comment followed by some kind of right arrow seems to be the most common notation, but there are other similar flavours.
i=2*3; // --> 6
i=2*3; // ⇒ 6
selfie programs are incredibly effective in communicating the author’s intentions because:
- They are self-contained (everything that is required is there and, crucially, nothing else)
- They are sequential (typically a few lines to set the use case, followed by one line to print the output)
- They care about user-experience: no need for your eyes to bounce from a code panel to an output panel.
…and so I wrote sequential
Any code which runs on it uses console.log to print its result, which is automatically displayed as a comment.
So, who is sequential for ?
Thanks for reading this.