6 ms·
Writing your own compiler - demystifies compilers, interpreters, linkers/loaders and related systems software, which you now understand. This understanding wil
by jll29 3y ago
Writing your own compiler
- demystifies compilers, interpreters, linkers/loaders and related systems software, which you now understand. This understanding will no doubt one day help in your debugging efforts;
- elevates you to become a higher level developer: you are now a tool smith who can make their own language if needed (e.g. to create domain specific languages embedded in larger systems you architect).
So congratulations, on top of other forms of abstraction, you have mastered meta-linguistic abstraction (see the latter part of Structure and Interpretation of Computer Programs, preferably the 1st or 2nd ed.).
- glouwbug 3y agoTook me seven years to do my own dynamic one that ended up being very similar to python2 with curly braces. Every programmer should try it
- Waterluvian 3y ago“Crafting Interpreters” is a phenomenal place to start. It’s very accessible. If you think you’re “not good enough” to write a programming language, it will show you just how wrong you are. Really boosted my confidence. (Hi Bob!)
- glouwbug 3y agoYeah that's where I started
- eru 3y agoWriting your own interpreter can be a lot of fun. Not sure if most people will get much extra out of writing their own compiler, too?
- mighmi 3y agoHow do later editions of SICP differ? I have no idea which I used.
- stevage 3y agoI dunno. I did a compiler writing course once, writing a compiler for a subset of Pascal in Ada, generating a kind of quasi assembly. It was a team project. I did most of the codegen and static optimisation. It was super fun and interesting. But I wouldn't say it was a terribly useful exercise that has greatly enriched me as a programmer. And somehow I have ended up with a very strong bias against DSLs.
- eru 3y ago> And somehow I have ended up with a very strong bias against DSLs. Most DSLs are bad, partially because most people are bad at designing languages. Embedded DSLs can be quite neat. Eg Haskell makes it easy to embed something like DSLs inside your Haskell code. (If you squint a bit, the ability to define your own functions in any language goes in that direction of allowing you to define your own mini-sub-language that handles your problem better. Haskell (and the Lisps) just dial that kind of approach up to 11.)
- stevage 3y agoI don't necessarily think the DSLs are badly designed. But personally I find the overhead in learning and remembering a new language to be enormous. I instantly drop from extremely high productivity in my language of choice to fumbling around like a newbie. And often DSLs are used for smallish tasks that you work on, write the code, then leave for a long time. Then you come back to it and have no idea how that language worked, its pecularities, etc. It had better have an extremely high payoff to justify that cost.
- eru 3y agoEmbedded DSLs have much lower learning overhead, since they are just embedded in the language you are already using. Eg in Haskell, they are still valid Haskell programs. So they eg inherit the control structures from the host language, and most of the tooling in your editor, like 'jump to definition' also still works. See http://wiki.haskell.org/Embedded_domain_specific_language http://wiki.haskell.org/Embedded_domain_specific_language Because the overheads are lower, the payoff doesn't have to be as high to make it worthwhile. (However, there's still some overhead, otherwise you wouldn't really label them as embedded-DSLs.)
- deleted 3y ago[deleted]