Lisp In 99 Lines Of C With TinyLisp

As one of the oldest programming languages still in common use today, and essential for the first wave of Artificial Intelligence research during the 1950s and 60s, Lisp is often the focus of interpreters that can run on very low-powered systems. Such is the case with [Robert van Engelen]’s TinyLisp, which only takes 99 lines of C code and happily runs on the Z80-based Sharp PC-G850V(S) pocket computer with its 2.3 kB of internal RAM and native C support.

The full details on how TinyLisp was implemented and how to write it yourself can be found in the detailed article that’s part of the GitHub project. It supports static scoping, double-precision floating point and features 21 Lisp primitives along with a garbage collector. Two versions for the Sharp PC-G850 (using BCD (i.e. NaN) boxing) are provided, along with a number of generic implementations, using either double or single precision floating point types. A heavily commented version is probably the version to keep alongside the article while reading.

TinyLisp is – as the name implies – very tiny, and thus more full-featured Lisp implementations are widely available. This includes two versions – linked at the bottom of the Readme – also by [Robert] that use a gargantuan 1,000 lines of C, providing a more advanced garbage collector and dozens more Lisp primitives to handle things like exceptions, file loading, strings and debug features.

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.

Learn C With A Lisp

One reason Forth remains popular is that it is very simple to create, but also very powerful. But there’s an even older language that can make the same claim: LISP. Sure, some people think that’s an acronym for “lots of irritating spurious parenthesis,” but if you can get past the strange syntax, the language is elegant and deceptively simple, at least at its core. Now, [Daniel Holden] challenges you to build your own Lisp as a way to learn C programming.

It shouldn’t be surprising that LISP is fairly simple. It was the second-oldest language, showing up in the late 1950s with implementations in the early 1960s. The old hardware couldn’t do much by today’s standards, so it is reasonable that LISP has to be somewhat economical.

With LISP, everything is a list, which means you can freely treat code as data and manipulate it. Lists can contain items like symbols, numbers, and other lists. This is somewhat annoying to C, which likes things to have particular types, so that’s one challenge to writing the code.

While we know a little LISP, we aren’t completely sold that building your own is a good way to learn C. But if you like LISP, it might be good motivation. We might be more inclined to suggest Jones on Forth as a good language project, but, then again, it is good to have choices. Of course, you could choose not to choose and try Forsp.

A RISC-V LISP Compiler…Written In Lisp

Ah, Lisp, the archaic language that just keeps on giving. You either love or hate it, but you’ll never stop it. [David Johnson-Davies] is clearly in the love it camp and, to that end, has produced a fair number of tools wedging this language into all kinds of nooks and crannies. The particular nook in question is the RISC-V ISA, with their Lisp-to-RISC-V compiler. This project leads on from their RISC-V assembler by allowing a Lisp function to be compiled directly to assembly and then deployed as callable, provided you stick to the supported language subset, that is!

The fun thing is—you guessed it—it’s written in Lisp. In fact, both projects are pure Lisp and can be run on the uLisp core and deployed onto your microcontroller of choice. Because who wouldn’t want to compile Lisp on a Lisp machine? To add to the fun, [David] created a previous project targeting ARM, so you’ve got even fewer excuses for not being able to access this. If you’ve managed to get your paws on the new Raspberry Pi Pico-2, then you can take your pick and run Lisp on either core type and still compile to native.

The Lisp-Risc-V project can be found in this GitHub repo, with the other tools easy enough to locate.

We see a fair few Lisp projects on these pages. Here’s another bare metal Lisp implementation using AVR. And how many lines of code does it take to implement Lisp anyway? The answer is 42 200 lines of C, to be exact.

Get Your Lisp On With The Dune Shell

Lisp is one of those programming languages that seems to keep taunting us for not learning it properly. It is still used for teaching functional languages today. [Adam McDaniel] has an obvious fondness for this fifty-year-old language and has used it in several projects, including their own shell, Dune.

Dune is a shell designed for powerful scripting. Think of it as an unholy combination of bash and Lisp.

Dune is designed to be highly customisable, allowing you to create a super-optimised workstation for your admin and programming tasks. [Adam] describes the front end for Dune as having turned up the cosiness dial to eleven, and we can see that. A cosy home is personalised, and Dune lets you customise everything.

Dune is a useable functional programming environment with a reasonably complete standard library to back it up, which should simplify some of the more complicated sysadmin tasks. [Adam] says the language also supports a few metaprogramming concepts, such as a quote operator, operator overloading, and macro programming. It’s difficult to describe much more about what you can do with Dune, as it’s a general-purpose programming language wrapped in a shell. The possibilities are endless, and [Adam] is looking forward to seeing what you lot out there do with his project!

The shell can be personalised by editing the prelude file, which allows you to overload functions for the prompt text, the incomplete prompt text (so you can implement intelligent completion options), and a function that deals with the formatting of the command response text. [Adam] gives us his personal prelude file, which defines many helper functions displaying useful things such as the current weather, a calendar, and an ASCII art cat. You never know when that might come in handy. This file is written in Lisp, so we reckon that’s where many people will start as they come up the Lisp (re)learning curve before embarking on more involved automation. Dune was written in Rust, so you need that infrastructure to install it with Cargo.

As we said earlier, Lisp is not a new language. We found a hack for porting a Lisp interpreter to any old language and also running Lisp bare metal on a Lisp machine. Finally, [Al] takes a look at some alternative shells.

The ’80s Multi-Processor System That Never Was

Until the early 2000s, the computer processors available on the market were essentially all single-core chips. There were some niche layouts that used multiple processors on the same board for improved parallel operation, and it wasn’t until the POWER4 processor from IBM in 2001 and later things like the AMD Opteron and Intel Pentium D that we got multi-core processors. If things had gone just slightly differently with this experimental platform, though, we might have had multi-processor systems available for general use as early as the 80s instead of two decades later.

The team behind this chip were from the University of Califorina, Berkeley, a place known for such other innovations as RAID, BSD, SPICE, and some of the first RISC processors. This processor architecture would be based on RISC as well, and would be known as Symbolic Processing Using RISC. It was specially designed to integrate with the Lisp programming language but its major feature was a set of parallel processors with a common bus that allowed for parallel operations to be computed at a much greater speed than comparable systems at the time. The use of RISC also allowed a smaller group to develop something like this, and although more instructions need to be executed they can often be done faster than other architectures.

The linked article from [Babbage] goes into much more detail about the architecture of the system as well as some of the things about UC Berkeley that made projects like this possible in the first place. It’s a fantastic deep-dive into a piece of somewhat obscure computing history that, had it been more commercially viable, could have changed the course of computing. Berkeley RISC did go on to have major impacts in other areas of computing and was a significant influence on the SPARC system as well.

Forsp: A Forth & Lisp Hybrid Lambda Calculus Language

In the world of lambda calculus programming languages there are many ways to express the terms, which is why we ended up with such an amazing range of programming languages, even if most trace their roots back to ALGOL. Of the more unique (and practical) languages, Lisp and Forth probably range near the top, but what if you were to smudge both together? That’s what [xorvoid] did and it resulted in the gracefully titled Forsp programming language. Unsurprisingly it got a very warm and enthusiastic reception over at Hacker News.

While keeping much of Lisp-isms, the Forth part consists primarily out of it being very small and easy to implement, as demonstrated by the C-based reference implementation. It also features a Forth-like value/operand stack and function application. Also interesting is Forsp using call-by-push-value (CBPV), which is quite different from call-by-value (CBV) and call-by-name (CBN), which may give some advantages if you can wrap your mind around the concept.

Even if practicality is debatable, Forsp is another delightful addition to the list of interesting lambda calculus demonstrations which show that the field is anything but static or boring.