Building a programming language in twenty-four hours
ersei.net
ersei.net
- Be armchair-interested in programming languages
- Take some PL-whatever courses in college
- Read about PLs
- Read about progressively niche PL stuff…
- Get idealistic (get ideas)
- Read about the grueling design process of useful-in-the-real-world languages
- Eventually realize that There Are Always Tradeoffs
- Realize that the Tradeoffs are like two thousand parameters that might interact in super-weird and non-obvious ways
- Realize that a dozen super-competent PhD-wielders and multi-decade practitioners can easily spend a decade on developing the core of a language
- eh, why bother
> eh, why bother
This is absolutely the question you need a deep answer for. You need a problem that is burning you up and whose only solution is a new programming language. This might never happen. If it ever does, you're the person to do it, exactly because of all the ups and downs and half-started ideas you've thrown away. But you're right: the "why bother" stage is not to be ignored. It's the most important one.
Because you will learn a ton and become a better programmer for it.
- yolo
This is super ambitious, but a great project to work on to better your understanding. And I applaud you, especially as an undergrad student( I assume as you stated final exams in the post). I wish I'd done more projects like this back when I was starting out. You are way ahead of where I was lol, I barely did any projects outside classes. And you got some attention on HN. Good stuff!
At least, that was the idea I got from watching a presentation by Dr Felleisen [2].
What is your problem domain? What don't you like about the currently available languages? Why do you want to kill yourself doing so? Can you afford to do so? Is this something you consider fun?
Understand yourself first and be willing to spend the time learning and sure go ahead, knock yourself out.
Just keep in mind that there are a small number of language classifications and yours will fit into one of these:
COBOL style languages: COBOL, Common Lisp, C, C++, C# and Java are examples here.
Fortran style languages: Fortran and all its variations.
ALGOL style languages: ALGOL 60, ALGOl 68, Simula, Scheme, Pascal and others,
Functional style languages: ML, Haskell, Clean, OCAML, etc.
Forth style languages: FORTH, Postscript, Factor, etc
SNOBOL oriented languages: SNOBOL 4, Icon, Unicon, etc
and a couple of other more minor kinds.
Language classifications normally antagonise people and tagging Lisp as essentially COBOL is well chosen for that. You're missing the prolog family and proof languages (coq/isabelle/lean etc). Also smalltalk (from which one might draw self and javascript).
Knowing exactly what one has rejected about existing languages is useful as a guide.
I am currently trying to [understand] the quirky translation of ScratchPad to Common Lisp used within the Axiom/FriCAS systems.
You see the same sort of problems in Maxima to Common Lisp translations.
Way too many [Dad jokes] or in my case [Granddad Jokes].
I started writing a JIT compiler in C here: https://github.com/samsquire/compiler
It's a toy and incomplete but I've worked on compiling MOV and ADD instructions.
https://thenewstack.io/brendan-eich-on-creating-javascript-i...
it was way more instructive than following the standard path.
interesting read though :)
Some of us should start the meta-project of cleaning our house by just making our bed.
> and long before the internet made it easy, it was the kind of thing i would do in my lunchtime at an office job.
This gives me vibes of "I think I'm really impressive and I want people to know it." Maybe that's uncharitable though... Talking to people online has made me too cynical haha. I appreciate the alternative perspective.
That was a long time ago and I didn't know nearly as much about PL design and implementation as I do now, but it set me on the path. Funny thing was I started that project just to prove to myself that I could still write C since I'd been doing a ton of Perl.
I suppose I could do something like that. This project is almost 3 years old now. I might have to pull it out and dust it off. :D
[0] https://ttssh2.osdn.jp/manual/4/en/macro/command/goto.html
The basic ideas are:
1. All allocations (e.g. consing) take from the stack.
2. Tail calls are stack calls, so we keep consuming stack.
3. No function ever returns; all calls are tail calls. The Lisp code is CPS-transformed. (Since functions in the compiled code don't actually return even when appearing to, the stack-allocated objects remain nicely valid.)
4. When the stack reaches a certain limit, we rewind it. At that point, all the data which we consed on that stack which is still reachable is relocated to the heap, so they remain valid while we clobber the original stack.