These days what we really need is an easily embeddable Python. Guile is very nice if you want a somewhat fancy Scheme system, but it got out of control if all you wanted was something light and embeddable.
These days what we really need is an easily embeddable Python. Guile is very nice if you want a somewhat fancy Scheme system, but it got out of control if all you wanted was something light and embeddable.
I've had fun w Guile over the years (though actually never considered its "heaviness"); fun.
I'm constantly amazed at the professional love for Python; its got it's network effect in full-effect: lots of people, lots of software - there's just no denying that. But for Joy of Development, Tcl (and C) is still my go-to.
You probably know this, but speaking of embeddable Python and Tcl, Tcl is indeed embedded in Python if you're running Tkinter[1].
And Larry Wall thought routers were weird places to be ported to[2].
[0] https://sourceforge.net/projects/tcl/postdownload
I do like Lua, but if I just try to use it in my work, I would be paria.
It still was my gateway into Common Lisp and remains a very cool scripting language with builtin event loop, good Unicode handling and very practical/"batteries included" stdlib.
Of course, I also do most of my scripting in TCL, so I'm a wee bit biased.
In my experience what goes out of control are python scripts, with many dependencies.
Also the changes in the language tend to be much more intrusive and often than in scheme.
Aside from this issue, the Guile API is pretty good, but the best one by far is Lua's C API, which is just a thing of beauty. I'm curious to try it with Tcl.
This contrasted with Larry Wall and ethos/self-delusion of the Perl community - anyone critical of the language or its design was disregarded as simply lacking the intellect to appreciate the "poetry" of Perl - and the the language warts (better described as big pus-weeping boils) were actually features.
: ~; ls -l /lib/x86_64-linux-gnu/libtcl8.6.so /lib/x86_64-linux-gnu/liblua5.2.so.0.0.0
-rw-r--r-- 1 root root 216960 Dec 10 2022 /lib/x86_64-linux-gnu/liblua5.2.so.0.0.0
-rw-r--r-- 1 root root 1852968 Feb 1 2023 /lib/x86_64-linux-gnu/libtcl8.6.so
even guile is smaller: : bin; ls -l /lib/x86_64-linux-gnu/libguile-3.0.so.1.5.0
-rw-r--r-- 1 root root 1303112 Mar 5 2022 /lib/x86_64-linux-gnu/libguile-3.0.so.1.5.0
a small scripting language might be the 7th edition bourne shell or the 7th edition awk: : bin; ls -l sh awk
-rwxr-xr-x 1 user user 46126 May 11 1979 awk
-rwxr-xr-x 1 user user 17310 May 5 1979 sh
admittedly tcl is still not as bloated as perl or cpython: : bin; ls -l /lib/x86_64-linux-gnu/libpython3.11.so.1.0 /lib/x86_64-linux-gnu/libperl.so.5.36.0
-rw-r--r-- 1 root root 3823936 Nov 25 2023 /lib/x86_64-linux-gnu/libperl.so.5.36.0
-rw-r--r-- 1 root root 7732544 May 2 08:59 /lib/x86_64-linux-gnu/libpython3.11.so.1.0
and, at 47 megabytes, javascript makes even cpython look slim: : Downloads; ls -l /usr/lib/x86_64-linux-gnu/libnode.so.108
-rw-r--r-- 1 root root 47166144 Jun 22 09:21 /usr/lib/x86_64-linux-gnu/libnode.so.108
which is almost as big as java's 187 megs: : ~; du -sk /usr/lib/jvm/java-17-openjdk-amd64/lib/
187208 /usr/lib/jvm/java-17-openjdk-amd64/lib/
a small embeddable lisp might be xlisp or siod. or, in modern times, tinyscheme, which is a 103-kilobyte executable: : Downloads; ls -l /usr/bin/tinyscheme
-rwxr-xr-x 1 root root 102648 Jun 8 2020 /usr/bin/tinyscheme
though to be perfectly fair we ought to include its standard library: : Downloads; ls -l /usr/lib/tinyscheme/init.scm
-rw-r--r-- 1 root root 23806 Jun 8 2020 /usr/lib/tinyscheme/init.scm
which brings the total for tinyscheme up to 125k. siod and xlisp are easy to embed, but i haven't tried embedding tinyscheme in a c program, so maybe it's more of a pain than i imagine it would bereally small would be a forth. forth is basically a scripting layer for assembly language with an interactive shell and ide, and there are plenty of full-featured forths that will run in 16k of ram. unfortunately forth code is hard to read and easy to crash
garbage-collected pointer-graph languages like lisp, python, js, and perl5 tend to use a lot more runtime memory for a given amount of functionality; in tcl (or the bourne shell) a list of 10 numbers like {8 2020 23806 102 7 3 11 5 36 86} is stored as a string which might occupy 31 bytes, plus an allocation header of probably another 16 bytes on a 64-bit system, for a total of maybe 48 or 64 bytes. by contrast, in a lisp system each list item occupies a 16-byte cons cell, so you end up paying 160 bytes; and storage is not reclaimed promptly, so you typically have another multiplier of 1½–3 to keep from spending all your time in the garbage collector. lua is the same; perl and python are different in detail (usually reclaiming storage more promptly due to reference counting, but wasting space on reference-count fields, boxing integers in python's case, and bloated svs in perl's case) but broadly similar in outline
tracing garbage collection (as opposed to the much slower reference counting used by perl and cpython) tends to diminish easy embeddability, both because it's very tricky to do in standard c, and because it kind of wants to own your program's entire memory space
this stuff still matters a lot due to things like icache misses, embedded systems, and standalone executable size. people complain about the size of golang and rust binaries but they don't hold a candle to the cpython interpreter. but it mattered a lot more in the 90s!
amusingly, this xlisp package includes a tk interface—by embedding tcl
an earlier xlisp, i think for cp/m-86, is http://www.cpm.z80.de/download/xlisp.zip. it is written in c, about 2800 lines of c, which i haven't tried to compile, but i think the executable is under 64k. this might give the flavor of the language thus implemented:
; ::::::::::::
; :: Turtle ::
; ::::::::::::
; Define "Turtle" class
(setq Turtle (Class 'new))
; Define instance variables
(Turtle 'ivars '(xpos ypos char))
; Answer "isnew" by initing a position and char and displaying.
(Turtle 'answer 'isnew '() '(
(setq xpos (setq newx (+ newx 1)))
(setq ypos 12)
(setq char "*")
(self 'display)
self))
https://www.softwarepreservation.org/projects/LISP/picolisp/... purports to be a lisp interpreter in an 8-kibibyte executable. for cp/m. it looks like it's cp/m-80, since objdump -D -b binary -m i386 -M i8086,intel --adjust-vma=0x100 8kl.com produces gibberish. dz80 from the d52 package produces a reasonable-looking disassembly, but it's 6000 lines long, and i don't have a cp/m or cp/mish emulation environment set up at the moment, so i can't verify that it actually works. all the source code is includedstill, it seems like pretty strong evidence that you can do an ergonomic embedded scripting language in 8 kilobytes or so, not 1900 kilobytes
Lua is living proof of the opposite: small, easily embeddable, with a tracing GC
It's pretty terrible but honestly Python would be pretty bad too. What these tools really need is a proper API that you can hook into and then use any language you want.