I’ve been learning Rust for a little while now, and I’m a firm believer that the best way to learn a new language is to actually build something with it. Not something like an example project from a book or tutorial for the language, but something non-trivial that you actually find interesting.
In that vein, I’ve been thinking a lot lately about a building a small programming language. It’s something that I find interesting, and Rust is a good fit for it. It’s also something that lets me start out relatively small and simple, but still always have opportunities for growing more complex.
This post, and the posts that follow it are going to be a sort of experiment. Ordinarily, with an ongoing project, I would just post about it on the fediverse. This time, I’m going to try to write blog posts about it. I expect I’ll continue to post in-the-moment stuff on the fediverse, but I also want to write more semi-regular posts about how it’s going overall. They probably won’t be super detailed, and they certainly won’t be tutorials, but they will be more detailed and more explanatory than much of what I post on the fediverse. And, as with what I would otherwise write on the fediverse, these posts aren’t going to be perfect. I’m not an expert at this; there are going to be mistakes, and I’m going to end up backtracking. But I figure that’s slightly more interesting to read about than if I did everything correctly on the first try.
With that, a few thoughts about the programming language I intend to build:
The biggest thing is that I don’t have a super comprehensive plan. I have some general ideas about what I want to do (and how to do it), but mostly I’m just going to see what happens. I don’t really need to use the end product for anything, I just want to have some fun building it.
The language is going to be interpreted. Building a compiler from scratch is not something I’m interested in (for now), and writing just a frontend for, say, LLVM, doesn’t seem terribly interesting either.
It will be weakly typed, because building a good, sound type system is more complicated than I want to deal with. There may be some static typing features, but it won’t be a focus.
It’s going to be mostly imperative. I’ll probably build more functional-language features at some point, but it’s going to be imperative first.
I’m also going to write everything by hand. No parser generators or combinator libraries. On a related note, there isn’t going to be a formal grammar or spec. The definition of the language will be whatever the parser does.
And with that, here goes nothing.
$ cargo new toylang