I spent this weekend writing a Forth designed for music synthesis, and it reminded me what a joy writing programming languages is! I have a big list of programming language experiments that I want to…
Article word count: 893
HN Discussion: https://news.ycombinator.com/item?id=19656666
Posted by zdw
(karma: 34373)Post stats: Points: 141 - Comments: 90 - 2019-04-14T00:15:48Z
I spent this weekend writing a Forth designed for music synthesis, and it reminded me what a joy writing programming languages is! I have a big list of programming language experiments that I want to try, but itʼs mostly been in my head so far. Hereʼs a living document of some of the languages I want to write.
A language with dependent types and borrow checking
A dependent type system is one where a type can depend on a value - for instance, a functionʼs return type could depend on the value of one of its arguments. Idris is perhaps the most famous dependently typed language.
Having dependent types allows for a huge amount of expressivity at the type level, preventing runtime bugs.
However, all current dependently typed languages are garbage collected.
Rust is the first (well-known) language to not use either garbage collection or manual memory management, instead relying on borrow-checking to allocate and free memory. Carp is a lisp that uses a borrow checker (they call it a "lifetime analyzer") for memory management, and compiles to C.
It would be interesting to combine dependent types and borrow checking.
Some useful places to start with this:
Itʼs probably incredibly hard to make a language like this ergonomic and performant, but I think itʼs an important design space to explore.
A productionized stream processing language
When I started working at Google, saw that everything was protobufs, and I assumed that the tools for dealing with protobufs would be amazing. Turns out, nope, youʼre writing thousands of lines of guiced up Java to perform what are, conceptually, simple transformations of protobufs.
jq is a stream processing language for JSON - it allows you to easily express transformations of JSON. (faq is another cool tool in this space, although I havenʼt tried it yet)
I want to be able to write servers in jq, except communicating in a typed format that has a real schema. The real work here is tying this together with a DB and reasonable frontend framework, but I think thereʼs something interesting in the idea of jq with types.
An effect system for Forth
Itʼd be interesting to write an effect system for Forth - thereʼs already been plenty of research into analyzing the stack effects of forth words - it seems like interesting design space to use these as annotations for forth words, MyPy style. Iʼm not sure exactly what effects one would care about for forth - the most obvious are stack effects, but forth seems like an interesting playground for all sorts of taint-tracking things.
A python-esque language with algebraic data types
Algebraic data types allow you to express many types of data in your type system.
Python is a wonderful scripting language, and is the language that I can most quickly throw together scripts in, but the lack of typing makes it untenable for large programs, and unpleasant for small ones.
Iʼd love to have a python-esque language with algebraic data types. Some people tell me that Pyret is this, so I should probably look at that first.
A lisp that compiles to C++ template metaprograms
C++ template metaprogramming feels surprisingly like writing a functional language - most everything is immutable, and recursion is the only looping.
It seems to me that it shouldnʼt be too much effort to write a Lisp that compiles down to C++ templates. I started writing this at the Recurse Center (and got as far as compiling prefix notation arithmetic expressions), but put it down. Iʼd love to return to it some day.
I donʼt think this would be useful, but it would be hilarious.
I think that a lot of people are confused as to why people write programming languages - we have so many already, what could the new programming language youʼre writing possibly bring to the table? But in reality, thereʼs a ton of design space in programming languages that hasnʼt been explored yet! Itʼs important that we continue to explore this space, not because every language will be good, but because some of them might bring new ideas to the table, or cause us to see how a combination of old ideas is amazing together. No one knows what itʼd be like to program in a borrow-checked language with dependent types, because there isnʼt one that exists!
Also, writing a programming language can be a lot of fun! It really demystifies what a "programming language" actually is, and what computers are actually doing. (If writing a programming language seems scary, Iʼd recommend reading "My first fifteen compilers" by Lindsey Kuper - it turns out that compilers (and programming languages) come at all different levels of complexity, and you can probably implement a very simple compiler or language in a few days!)
I wish more people were writing strange programming languages, or at least talking about what programming languages they want to write. What programming languages do you want to see?
Last update: 12 April 2019
If youʼre in NYC and want to meet up over lunch/coffee to chat about the future of technology, get in touch with me.
HackerNewsBot debug: Calculated post rank: 124 - Loop: 304 - Rank min: 100 - Author rank: 120