screwlisp proposes kittens

Sharpsign tootcoding - NicCLIM and compsci pedagogy

Where I guess #Tootcoding is my tag for fediversal toots as incremental, forkable (replyable) computer programming. Originally I was thinking of #tooteev to enjoy the repeated long vowels, but #eev is a better tag for best-enjoyed-with-eev. Here I will give my developments of the idea after having slept on it, and an example.

Centrally I considered https://mdhughes.tech 's suggestion that tootcoding could work via a Mastodon bot in the usual way that would evaluate a tagged toot, and reply with an animated GIF of a McCLIM frame (i.e. GUI window) carrying out the instructions. Rendering images and animations, and graphically targetting the common lisp interface manager 2.0 spec commands instead of arbitrary programming with ANSI common lisp as such is a good idea, but after some thought I will insist upon locally empowering the user rather than an internet service generating an internet picture of its interpretation. There is a place for internet services, but personal learning by its dint must be highly local.

NicCLIM for introductory programming

My NicCLIM is at its heart a bare-bones CLIM 2.0 spec application frame using the McCLIM open source implementation (there are of course the Franz Inc and Lispworks proprietary implementations, and the historical Symbolics one at least otherwise). In CLIM you declaratively make a GUI and add commands that are commands-your-GUI-can-receive. NicCLIM already has commands that loosely express how I see Bill Joy’s VI as working; my emphasis is on using its commands, and using its commands viz a viz the host lisp. Becoming able to do things being my vision of learning. The thing being able to originally branch or promulgate new tootcodes without the help of new outside instruction.

NicCLIM

Choices

ANSI CL is a good language that I believe will never change in response to market forces due to it uniquely being both an ANSI standard but explicitly owned-by-the-community per Pitman’s CL: The untold story.

The common lisp interface manager 2 spec canonicalizes decades of work on HPC (of the time) user interfaces, and is attached to ANSI CL by lisp’s metaobject protocol.

Lisp used to be an HPC operating system language (as well as other things), but in modernity lisp’s portability everywhere and its standard’s immutability is more critical than wanting it to also be a particular microcomputer operating system.

The fediverse as a coding medium

  1. The fediverse is an established distributed, decentralized and popular social media writing, art and music place
  2. Code is a kind of writing
  3. Our new contribution is programmatically interfacing writing, art and music: which is to say facilitating indie game dev.

eev’s freeform evaluation and inspection/introspection/automation means no rules have to be introduced to mastodon / fediversal toots constituting freely branchable multiply targetted sequences of code.

Aside describing eev: eev’s three main keys are M-e ‘emacs-lisp evaluate’, often popping up and populating a temporary buffer; M-k kill that temporary buffer when you are finished using it; and ancillarily F8 “pitch this line (of code) at that thing over there”

One special case that occurs to me is to understand the Mastodon’s Quote Toot feature as being GOTO this toot (and continue). This is different to my idea yesterday of using subsequences; GOTO is necessary about START and STOP turn out to be completely unnecessary and inelegant.

One example, then!

Instead of a remote bot interpreting code into a picture, I will post freeform annotated eev-style writing and code, and a screenshot or animated GIF of the NicCLIM window as it appears on my machine and should also directly work on your machine. If you do not use eev, you presumably have some other way of sending code to a target to be run, possibly by pasting it into an xterm.

Priors: I am assuming you are getting McCLIM via https://quicklisp.org you have set up, and have downloaded NicCLIM (better link) to ~/Downloads/nicclim.lisp, and are using embeddable common lisp or understand your own choice of lisp compiler. Sorry about the heavy “start everything” first toot.

tootcoding toot the first

(ql:quickload :mcclim)
(compile-file #P"~/Downloads/nicclim.lisp" :load t)
(in-package :nic)
(require 'bordeaux-threads)
(require 'uiop)
(uiop:chdir "~/GAME/") ; you do you.
(rect-file 'garden 5 5 '(soil))
(bt:make-thread
 (lambda ()
   (in-package :nic)
   (enclose-map 'garden)))

Placing some grass

tootcoding toot the second

Execute-frame-command *nic* is literally what we are doing, so I do not want to hide it. We are asking the application frame stored in nic, currently running, to execute a command. These commands are also available via the interactor, menus and hotkeys (the menu also tells you the hotkey).

(loop
  :for cmd
    :in (list '(com-set-cur1 grass)
	      '(com-l) '(com-j) '(com-push-cur1))
  :do
     (execute-frame-command *nic* cmd)
     (sleep 1))

Zazzing things up a bit with images.

tootcoding toot the third

(uiop:run-program "gimp")
;; I saved IMGS/SOIL.PNG and IMGS/GRASS.PNG .
(loop
  :for cmd
    :in (list '(com-set-cur1 imgs/grass.png)
	      '(com-swap)
	      '(com-set-cur1 grass)
	      '(com-set-bitmap))
  :do
  (execute-frame-command *nic* cmd)
  (sleep 1))
(loop
  :for cmd
    :in (list '(com-set-cur1 imgs/soil.png)
	      '(com-swap)
	      '(com-set-cur1 soil)
	      '(com-set-bitmap))
  :do
  (execute-frame-command *nic* cmd)
  (sleep 1)) 

Add another tuft of grass.

tootcoding toot the fourth

(loop
  :for cmd
    :in (list '(com-set-cur1 grass)
	      '(com-l) '(com-j) '(com-push-cur1)
	      '(com-h) '(com-push-cur1))
  :do
     (execute-frame-command *nic* cmd)
     (sleep 1))

Oops, I moved around a bit interactively.

Save the GARDEN

tootcoding toot the fifth

(execute-frame-command *nic* '(writef garden))

~/GAME/GARDEN :

(SOIL)	(SOIL)	(SOIL)	(SOIL)	(SOIL)
(SOIL)	(SOIL GRASS)	(SOIL)	(SOIL)	(SOIL)
(SOIL)	(SOIL)	(SOIL)	(SOIL GRASS)	(SOIL GRASS)
(SOIL)	(SOIL)	(SOIL)	(SOIL)	(SOIL)

Conclusions

I guess there are very rough edges, but we planted some grass in a garden. I am going to add

(defun nic:x (&rest args) (apply 'execute-frame-command *nic* args))

to nicclim.lisp I think. Still we can directly see that sometimes we are sending lisp expressions to lisp, and sometimes we are sending commands to the GUI, and have symbols rendering as pictures which is nice.

There seems to be some nice potential for the animated-gif nature of things. We are probably being held back by my own aesthetic sensibilities; perhaps someone else will reply to this thread with an alternate evolution.

I do sometimes get I guess odd race conditions using McCLIM on my extremely slow computer where McCLIM’s internal event queue cannot get a lock as fast as it wants to, though if you have a computer this slow I guess you probably can deal with it.

What I do not have is a literature review supporting some theory of pedagogy, other than having recently read Amen Zwa’s theory that data hiding what the computer is doing from children allegedly being taught what the computer is doing is Quixotic.

Purely from memory as I could not magic up the reference I am thinking of yet, the circa 1970 LOGO language turtle-drawing is meant to have been specifically psychologically designed as an opposite-world programming language that was more useable for atypical computer people and less useable for typical computer people, but I do not have the citation for that.

One such group being children, who lack the decade of schooling that hypothetically makes you into a typical programmer yet being more atuned to the idea of maneuvering a physical turtle.

Proximally I have two explicit targets. One is live electronic music noodling; the other is the semiannual lispgames game jam https://itch.io/jam/autumn-lisp-game-jam-2025 starting in 7 days.

Fin.

See you on the Mastodon for both your prosaic and programmatic replies to ⬆ Tootcoding.

screwlisp proposes kittens