What are your experiences when writing a new programming language, where and how did you start?
Ask HN: What's a starting point for learning how to write programming languages?
1–10 of 105 posts
I've been thinking about writing my own programming language for some time. This to gain a deeper understanding of how programming languages, and by extent, computers work. I've bought the Flex and Bison book by John Levine to have a resource on parsing and lexing. I have come to realize however, that writing a complete language like Java, Python, Ruby, from bottom to the top, is of course not a small task. So therefore I started to think of writing maybe a compiler for another language, writing a "simple" language like SQL, Markdown etc. to begin with.
Re: Ask HN: What's a starting point for learning how to write programming languages?
#2I would suggest looking at Niklaus Wirth's Compiler Construction book and even the Oberon compiler. This is one of the best ways to learn about compilers and writing programming languages. See: https://www.inf.ethz.ch/personal/wirth/
Another approach is to look at SICP, it is Scheme oriented and more oriented towards macros. See: https://mitpress.mit.edu/sites/default/files/sicp/index.html
SQL is a deceptively complex language, the optimisations that it performs are very complex. Markdown, on the other hand, is more of a transpiler to HTML and is not Turing Complete.
Re: Ask HN: What's a starting point for learning how to write programming languages?
#3[deleted]
Re: Ask HN: What's a starting point for learning how to write programming languages?
#4I'm going through this book right now, i find it to be pretty good! https://www.amazon.ca/Writing-Interpreter-Go-Thorsten-Ball-e...
Re: Ask HN: What's a starting point for learning how to write programming languages?
#5This awesome essay by Steve Yegge: http://steve-yegge.blogspot.com/2007/06/rich-programmer-food...
Re: Ask HN: What's a starting point for learning how to write programming languages?
#6Types and Programming Languages (TAPL) is required reading, in my opinion: https://www.cis.upenn.edu/~bcpierce/tapl/
Re: Ask HN: What's a starting point for learning how to write programming languages?
#7Check out "Writing An Interpreter In Go" https://interpreterbook.com/
It uses Golang to make an interpreter for a simple C-Style language and it's "only" 200 pages long. I'm about a third in and my head is smoking.
Re: Ask HN: What's a starting point for learning how to write programming languages?
#8Build Your Own Lisp (http://buildyourownlisp.com/) is as good a starting point as any. You learn to implement a high-level dynamic programming language in C, which is a common choice of implementation language for interpreters (e.g., CPython, Ruby). I really can't recommend the book enough.
Re: Ask HN: What's a starting point for learning how to write programming languages?
#9This awesome essay by Steve Yegge: http://steve-yegge.blogspot.com/2007/06/rich-programmer-food...
[deleted]
Re: Ask HN: What's a starting point for learning how to write programming languages?
#10Beautiful Racket[0] is a good starting point that covers a lot of nice small examples that incrementally build up your understanding of the different components involved in making languages. And it uses Racket[1], which incorporates the idea of crafting many small "domain-specific" languages to solve different problems into its entire philosophy[2].