Riscyforth: an update


Last Christmas I started work on a Forth for RISC-V single board computers (SBCs): Riscyforth.

Riscyforth is written in RISC-V assembly, with the aim of providing a good balance between the ease of use that comes from a programming language that can both be run in an interpreted “immediate” mode and compiled if speed is the priority.

Forth is a stack based language – commands operate on what’s on top of the stack, hence:

2 2 +

Computes 2 + 2 and so on. It can sometimes make the code hard to read, but it’s also a powerful and extensible language – very much out of fashion these days but also very hacker (as in coder/experimenter) friendly.

At the time I began no SBCs existed, but they were expected. Since then, one has turned up – the Nezha – while the one we were all expecting, the Beagle V, was cancelled but it is looking better for 2022.

Progress on Riscyforth has been slower than I probably expected, certainly slower than reading the book on “threaded interpreted languages“- my initial inspiration – led me to expect: but the delays in hardware have also given me more time.

So how does it look?

Well, it’s now pretty mature – I have implemented a substantial part of the Forth 2012 core specification (and some other extensions too), but there is still a lot of work to be done:

  • Output is still pretty basic – you get lines of text and there is no support for nCurses type output, never mind graphics.
  • Some basic structures are still missing (such as the Forth equivalent of switch/case – but I have recently finished a restructuring of code/ pay down of technical debt that makes all this much easier to implement.
  • Despite the initial idea of writing this to give developers faster access to the hardware, all the work has gone into the core language and no hardware specific extensions have yet been written.

But it works, and works well. A couple of crude tests show it is doing basic looping about 10 – 20% faster than GForth, the GNU Project’s Forth compiler (which works well for RISC-V) – though you are getting a lot else besides with GForth.

If you are at all interested your comments and – perhaps – participation in the project would be very welcome.

A great Christmas present?


I haven’t quite finished it yet – but I do want to strongly recommend Ananyo Bhattacharya’s “The Man from the Future: The Visionary Life of John von Neumann” – not just because the author was very gracious when I, as some random on the Internet, tweeted him to tell him of a (very small) error in the text, but also because it’s such a stimulating book that – like its subject – covers so many areas from nuclear war to Conway’s Game of Life and back again.

I am not a great one for biographies that go in for long examinations of the subject’s childhood, schooling and dietary preferences, and this book gets the balance right by looking principally at von Neumann’s scientific and engineering work. But it also covers lots of other ground – reintroducing me to this massive tome for instance (which I bought on a whim years ago and did read some of, but didn’t quite get the point of – now I have a better idea).

Years ago, as a(n astro)physics under-graduate I was pretty sniffy about von Neumann – after all he was a big friend of Teller and Teller was evil, right? Well, I haven’t particularly changed my opinion of Teller but I have of von Neumann and this book has certainly accelerated the journey. Not that “Jonnie” is a great hero – in many ways he sounds pretty hard to take – but because his contribution to science, maths and engineering is just so huge. (Thankfully not all of his ideas – such as “pre-emptive” nuclear war were acted on)

Definitely a good book as a Christmas present for curious sixth formers and older.