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 articleCreating 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.
Related
I Probably Hate Writing Code in Your Favorite Language
The author critiques popular programming languages like Python and Java, favoring Elixir and Haskell for immutability and functional programming benefits. They emphasize personal language preferences for hobby projects, not sparking conflict.
Crafting Interpreters
The book "Crafting Interpreters" by Robert Nystrom is a detailed guide on creating programming languages. It covers parsing, semantics, bytecode, and more. Nystrom provides free online access and additional resources.
Objective-C is like Jimi Hendrix (2014)
The author compares Jimi Hendrix's influence on guitar music to Objective-C's impact on programming, noting how perceptions of its features have evolved as newer languages emerged, reflecting on programming history.
How to Compile Your Language – Guide to implement a modern compiler for language
This guide introduces programming language design and modern compiler implementation, emphasizing language purpose, syntax familiarity, and compiler components, while focusing on frontend development using LLVM, with source code available on GitHub.
You should make a new programming language
Creating a programming language enhances understanding of design and execution, fosters creativity, and provides valuable insights. Implementing existing languages and choosing different implementation languages can deepen learning experiences.
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.
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.
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.
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...
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...
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.
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!
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.
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...
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.
(https://ratfactor.com/forth/the_programming_language_that_wr... is a great read, btw.)
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.
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*
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.
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.
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.
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
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.
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.
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!
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 . . .
You're going to need one anyway . . .
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.
Related
I Probably Hate Writing Code in Your Favorite Language
The author critiques popular programming languages like Python and Java, favoring Elixir and Haskell for immutability and functional programming benefits. They emphasize personal language preferences for hobby projects, not sparking conflict.
Crafting Interpreters
The book "Crafting Interpreters" by Robert Nystrom is a detailed guide on creating programming languages. It covers parsing, semantics, bytecode, and more. Nystrom provides free online access and additional resources.
Objective-C is like Jimi Hendrix (2014)
The author compares Jimi Hendrix's influence on guitar music to Objective-C's impact on programming, noting how perceptions of its features have evolved as newer languages emerged, reflecting on programming history.
How to Compile Your Language – Guide to implement a modern compiler for language
This guide introduces programming language design and modern compiler implementation, emphasizing language purpose, syntax familiarity, and compiler components, while focusing on frontend development using LLVM, with source code available on GitHub.
You should make a new programming language
Creating a programming language enhances understanding of design and execution, fosters creativity, and provides valuable insights. Implementing existing languages and choosing different implementation languages can deepen learning experiences.