August 13th, 2024

You should make a new programming language

Creating a programming language enhances understanding of design and execution, encourages learning through initial flaws, and fosters creativity. Guided projects and resources support beginners in this fulfilling endeavor.

Read original articleLink Icon
You should make a new programming language

Creating a new programming language can be a valuable learning experience for software engineers, despite the fact that most tasks can be accomplished using existing languages. The author reflects on their journey of developing languages, emphasizing that the process fosters a deeper understanding of language design, parsing, and runtime execution. By engaging in this creative endeavor, programmers can explore various paradigms, such as imperative or functional programming, and learn about the intricacies of grammar and syntax. The author encourages aspiring language creators to embrace the idea that their initial attempts may not yield a "good" language, which can liberate them to focus on learning rather than perfection. They suggest starting with guided projects, such as implementing existing languages, to build foundational knowledge. Resources like "Crafting Interpreters" and "Build Your Own Lisp" are recommended for beginners. Ultimately, the author advocates for the joy of creating a language as a means to innovate and expand the programming landscape, while also having fun in the process.

- Creating a programming language enhances understanding of language design and execution.

- Initial attempts at language creation are likely to be flawed, which can be liberating for learning.

- Guided projects and resources can help beginners grasp the fundamentals of language implementation.

- Engaging in language creation fosters creativity and innovation in programming.

- The process can be enjoyable and fulfilling, encouraging programmers to explore new ideas.

Link Icon 42 comments
By @tombert - 5 months
I've had two projects that end up being "oops, I made an interpreter".

It starts innocently enough, you just have a JSON that has some basic functionality. Then you decide it would be cool to nest functionality because there's no reason not to, so you build a recursive parser. Then you think it'd be neat to be able to add some arguments to the recursive stuff, because then you can more easily parameterize the JSON. Then you realize it might be nice to assign names to these things as you call them, you implement that, and now you're treating JSON as an AST and you're stuck with maintaining an interpreter, and life is pain.

By @lallysingh - 5 months
Every program expands until it becomes a compiler or checks mail. Emacs's sin was doing both.
By @Doches - 5 months
> It's special that we make our own tools

I've always taken this to heart, but not necessarily with programming languages. Any piece of software that helps run my business that I can reasonably make and maintain myself, I do. I build my own CI/CD app, orchestration/deployment tool, task planner, bug tracker, release note editing & publishing tools, blog editor, logstash/viewer for exceptions, etc.

Does building (and especially maintaining!) all of these tools take up a lot of time, and distract me from the primary business of building the software that I actually sell? Sure, of course it does. But it also keeps me fresh and forces me to expand the scope of ideas that I regularly work with, and keeps me from becoming "that guy who makes that one app" and who isn't capable of moving outside of his comfort zone.

And while that doesn't (yet) extend to building my own tools in my own languages, it certainly does extend to writing my own DSLs for things like configuration management or infrastructure. My tools may be homerolled and second-rate, but they're mine (dammit!) and -- this part is important -- no one can take them away from me or catch me out with a licensing rug-pull.

By @norir - 5 months
I think many people underestimate how easy it is to get started writing a language. It is a bit like improvising music: it's just one note followed by another note followed by another. Almost any intermediate level programmer can write a program that parses a hello, world program and translates it into the language they already know. Once you have hello, world, you add features. Eventually you realize you made mistakes in your initial design and start over but your second design will be better than the first because of the knowledge that you now have. After enough iterations, you will have a good language that you like (even though it won't be everyone's cup of tea).
By @JohnMakin - 5 months
One of the most fundamental experiences I ever had was attempting a graduate level course at the end of a long series on compilers. You really get an eye opening view of how languages are translated into the language the machine understands. After going through a few toy languages and then finally tackling creating a simple JVM, here is the #1 thing I would go back to myself and scream until I was blue -

Make your initial grammar SUPER simple. Like, don't go guns blazing and try to add all these cool features you saw in another language or always thought about. Start stupid, stupid simple, get that working, then build on top of it.

By @Jeaye - 5 months
Anyone wanting to work on a new language is most welcome to help out on mine: jank. It's a native Clojure dialect on LLVM with C++ interop and all the JIT goodies one expects from a lisp.

jank is currently part of a mentorship program, too, so you can join (for sree) and get mentored by me on C++, compiler dev, and Clojure runtime internals.

1. https://jank-lang.org/ 2. https://clojureverse.org/t/announcing-the-scicloj-open-sourc...

By @graypegg - 5 months
I think maybe a good middle ground is write an interpreter for an already spec'd esoteric language like brainfuck. [0]

It's really fun. Brainfuck specifically is great because there's a lot to optimize with only 6 total operations. (An example, multiplication has to be done as repeated addition in a loop, make a multiply AST node! [1]) and you could knock out a (BF => AST => Anything you want) compiler in an afternoon!

Bonus, there's a lot of really impressive brainfuck scripts out there. Nothing compares to seeing your compiler take in some non-sense ascii, and spit out an application that draws the mandlebrot fractal.

[0] https://esolangs.org/wiki/Brainfuck

[1] https://github.com/graypegg/unfuck/blob/master/src/optimiser...

By @danielvaughn - 5 months
Last year I tried to build a language and I wholeheartedly agree - it's amazing how much it teaches you. My particular language was merely meant to be transpiled to other languages, so I didn't get into the runtime or compilation stuff. But I quickly learned why braces and ignoring whitespace is so important. I also had to think extremely hard and carefully about the exact syntax and what each token meant. It's a very rewarding intellectual activity.

One thing I'd like to add is that even though you can totally write your own parser, it's an absolute joy to use Tree-sitter:

https://tree-sitter.github.io/tree-sitter

I plug it every time I get a chance. It makes refactoring your grammar incredibly easy, and lets you just focus on your syntax.

By @cvoss - 5 months
I've dreamed about making my own language for about 10 years or so. Started out just messing around. My vision for what it would be and its purpose has changed over time. About 2 years ago, I "got serious" about designing and implementing it, though that doesn't mean I've spent a serious amount of time on it yet. But it's happening!

It's a language for the domain of writing and verifying formal proofs. Basically, I didn't enjoy the experience of working with the couple of proof assistants I tried, so I'm doing my own thing. My objective is to create a language where I can document "everything I know" about math, if for no other reason than to prove to myself that I know those things, and to return to that knowledge if it ever slips away.

It's so much fun!

By @zX41ZdbW - 5 months
It will be good to add "Programming Language Checklist" to the references: https://www.mcmillen.dev/language_checklist.html
By @rzimmerman - 5 months
I spent time on a compile-to-JS language and found it very rewarding: https://github.com/rzimmerman/kal

This was before async/generators were added to JS and callback hell was quite real. I wanted to shape it in the way I’d learned to program in Visual Basic. Very human readable. The result is no longer useful, but it was a fun goal to have the compiler compile itself.

By @kstenerud - 5 months
I haven't made a programming language (and never will), but I did build a BNF-inspired metalanguage for describing text and binary formats to scratch the itch of trying to describe a binary data format I was developing:

The metalanguage: https://dogma-lang.org/

It's even got a syntax highlighter: https://marketplace.visualstudio.com/items?itemName=ksteneru...

The binary format I wanted to describe: https://github.com/kstenerud/concise-encoding/blob/master/cb...

By @cardiffspaceman - 5 months
Landin wrote a paper called, "The next seven hundred programming languages."[1] The paper predicts quite a bit of the present. So I named my programming language, DCC.

[1] https://www.cs.cmu.edu/~crary/819-f09/Landin66.pdf

By @liamilan - 5 months
I built Crumb (https://github.com/liam-ilan/crumb) a year ago, before starting university. It completely changed the way I conceptualized programming as a whole. You start feeling deja-vu every time you open a new language, and the "ah-ha!" feeling you get when you see something in another language you had to think about when implementing your own is super rewarding.

A year later (this summer) I used Crumb to land my first job at a pretty cool startup! The payoff was way more than I could have ever expected.

By @morning-coffee - 5 months
The timing of this article is great for me as lately I'm fascinated by the Forth language and the simplicity behind its apparent strangeness. I've been tempted to start playing with similar ideas just for fun.

(https://ratfactor.com/forth/the_programming_language_that_wr... is a great read, btw.)

By @Lerc - 5 months
I still hope to make one, but a combination of ADHD, depression and so many things to do and learn keep getting in the way.

At my current rate I'll know everything and be ready to get started on the day I die.

But my feature wishlist is

First class functions, Garbage collection, Transparent parallelism, Explicit parallelism, Type inference with strong type consistency, Dynamicly typed by annotation, Operator overloading (every language should either have vector/matrix operators or the ability to build them)

And a few more that I can't recall just now. I've made it hard for myself.

Failing that maybe just a hacked JavaScript without implicit type conversion between objects/strings etc. (the source of most "Wat?"), frozen array tuples, operator overloading. Implied "this." on identifiers defined and used inside class definitions.

By @mjhay - 5 months
> It will be a bad language, and that's okay

This same advice could be applied to most hobbies. It doesn't have to be good, and it certainly doesn't have to make money. It just has to be fun and rewarding. If you learn something, even better.

> Go Forth, make something fun

*golfclap*

By @atum47 - 5 months
Long time ago I was stuck at the airport and I end up writing a interpreter in Python. I stop the project at arithmetic, so, basically a fancy calculator. After that I saw a really interesting video about Shunting Yard algorithm, so I gave that a got as well [1]. At some point, I want to try to write a programming language, I know a little bit about assembly but it is most theory; haven't done much programming using it (only basic stuff, back in college) but I find it fascinating.

1 - https://github.com/victorqribeiro/shuntingYard

By @PodgieTar - 5 months
I made a little toy compiler for a university project many years back, and I agree with the article - it's quite a nice way to get hands on with syntax and helps you think a bit more deeply about what is actually happening.

https://github.com/Podginator/Rattle/tree/master

It used JavaCC, which I found to be a pretty simple way to get up and running.

I also worked a job that used yacc to create their own DSL for a piece of software. Same thing, really. Easy enough to get up and running, and messing around with.

By @tunesmith - 5 months
I've had a pet idea for a long time that is nonsensical but I still wish existed. I'd like a programming language that encodes the "why", like forces you to compile in the business reason for the code in question. And then it'd automatically survey you, and if your prior business assumptions are no long true, then compilation would fail, forcing you to remove or rewrite until the code fits your "why" again.
By @pclmulqdq - 5 months
One project I started recently was a dice rolling discord bot. Halfway into it, I realized that I really wanted an AST for dice roll expressions to avoid a whole bunch of bugs and special cases, so that project is now mainly a compiler.

More seriously, I have been very tempted recently to make a programming language specifically for cryptography, but I am holding off until I can no longer stand assembly.

By @lifeisstillgood - 5 months
I just realised I went down the rabbit hole yesterday. I needed to track work to be done on my work project - so I started writing Todos. And then grepped them, and started extracting things from the todos - like a dotted name (foo.component.feature) and now I have realised it’s a DSL and I should have used lexx not regexes and … it’s a good idea through !
By @systemBuilder - 5 months
When I was in high school I learned about BNF and so i wrote a program that let you type in BNF rules and then it would run a recognizer on an arbitrary string to decide if the string met the BNF rules. I don't know if I could write that again, but it was a definite eye-opener and I learned a ton from that project ...
By @TrackerFF - 5 months
In woodworking you make tools all the time, namely jigs. So much of woodworking, whether it is making cabinets, musical instruments, art, or whatever involves making your jigs, templates, and a bunch of other stuff. Hell, even larger projects like complex workbenches.

You rarely make actual tools, though. It's unheard of that a woodworking goes on to make their own router, band saw, planer, jointer, chisels, etc. - but you can learn a ton by starting with the absolute bare basics, before investing a ton in expensive tools.

Kind of makes me wonder where this analogy fits (if at all) in the world of software engineering: Some tools are probably either too complex, or don't really make sense making, if you're going to use it to actually build something.

I mean, it is a good intellectual exercised for the curious, and you pick up a bunch of things underway, but at some point it is probably good to ask yourself if your time is better spent on something else.

By @mikewarot - 5 months
Making a whole new software/hardware ecosystem is what happens if you keep going... behold... the BitGrid.

Turing Complete, Actually performant, and possibly crazy enough to work

[1] https://esolangs.org/wiki/Bitgrid

[2] https://github.com/mikewarot/Bitgrid

And my latest attempt at things, because Pascal isn't popular enough, includes C and a Web emulator

[3] https://github.com/mikewarot/Bitgrid_C

By @bitbasher - 5 months
I've been thinking about programming languages a bit and I agree. I was looking at Odin and some other languages.

I find it fascinating a language can be purpose-built, like Odin. It's a language that was built for game development. It got me thinking what a language built for web development may look like.

It also got me thinking, we have 'game engines' which are tools built around the same idea. Why don't we have web-CRUD engines? Sure we have frameworks, but we don't have entire purpose built applications for building fullstack applications.

By @elashri - 5 months
It is always my dream to write an interpreter for my imaginary language that does provide a more human readable syntax to write scripts. It is basically language that compiles to bash because it is everywhere but I really hate writing bash although I write bash/zsh code a lot.

Yes I can use python (other scripting language for that) but this is not cool as writing your own programming language and also you don't always have access to python environment. Bash just runs everywhere (at least for me). It is also my motivation to learn about compilers and how they work.

By @news_to_me - 5 months
This is so true. I feel like I've learned more about programming in the last two years making Cassette[1] than in the past decade of professional software development.

Every developer should make a language at some point. I want to see everyone's weird, half-baked languages! I want to hear about what other people struggled with, and the tradeoffs they've made!

[1]: https://cassette-lang.com

By @martyalain - 5 months
I learned that all programming languages come from the lambda calcul, created in the 30s, ten years before the computer era, a simple text rewriting machine using nothing but 2 operators, abstraction and application, working on a sea of words. Something like the Yin and Yang of TAO. More in http://lambdaway.fr .
By @flobosg - 5 months
“Beautiful Racket” comes to mind: https://beautifulracket.com/
By @Moon_Y - 5 months
Similar to woodworkers making their own tools, as programmers, we have the ability to create everything from operating systems to tools. This privilege is rare in other fields, allowing us to get closer to the tools we use. This autonomy enables us to have a deeper understanding and mastery of the tools and technologies we rely on.
By @looneysquash - 5 months
Are there some good resources for learning type theory?
By @codr7 - 5 months
Highly recommended! And I do mean new. Because having an opinion is good, and validating it is even better. I find it to be mostly educational, humbling and fulfilling; but occasionally VERY frustrating because there's just no end of things to fix and improve.

https://github.com/codr7/sharpl

By @IWeldMelons - 5 months
https://old.reddit.com/r/ProgrammingLanguages/ is a treasure trove for those who wants to engage in the quest.
By @DeborahWrites - 5 months
Every ~3yrs an article like this floats across my screen.

Every time, I think it sounds SO fun.

And then do nothing.

Given this time I have the excellent excuse of a new job, I don't expect to break the trend this year.

But one day . . . one day . . .

By @bsnnkv - 5 months
My version of this was building my own tiling window manager (I also ended up building my own hotkey daemon with its own syntax and parser along the way)
By @kabdib - 5 months
Write the debugger first. Or at least, very early.

You're going to need one anyway . . .

By @allanren - 5 months
Seems the future of programming language is natural language
By @AnimalMuppet - 5 months
No. No, I really shouldn't.

Yes, I might gain a better understanding of how things work. I can do that lots of ways; others may be a better use of my limited time. (For that matter, doing other things that don't give me a better understanding of how things work may be a better, more valuable use of my limited time.)

Yes, I could get a language that fits what I need better... in theory. In practice, it would be buggy, inconsistent, and incompletely implemented. It would not actually fit what I need better than existing languages.

By @napierzaza - 5 months
I remember when I was making music. It was really fun and engaging. Then I learned about microcontroller projects for making my own synthesizer. It was fun and it took me two years to build my synth. At the end of it I had not made music for long enough to have lost the knack, and I was sick of even learning how to use the synth because I was worried I would have to debug it. So I just didn't make music ever again. Why consume yourself with some sub project that goes nowhere?