Live data from Hacker News

Ask HN: Resources for building a programming language?

news.ycombinator.com

31–40 of 87 posts

Re: Ask HN: Resources for building a programming language?

#31

I'd probably start by using Racket (Racket is a scheme is a lisp) which has a whole toolkit for language building. Arc is written this way, for instance. Often these are lispy languages but there is no reason they have to be. A starting point: http://beautifulracket.com/stacker/ or https://www.hashcollision.org/brainfudge/ That will get you started rediculously quickly and give you things like GC and JIT for free. Yo…

Note that Hacker News which we are now using is written in Arc, which was written in (a now older version of) Racket.

Re: Ask HN: Resources for building a programming language?

#33
post #13

If you're looking to create a dynamic language with reasonable performance, you could look at implementing it with RPython [1], which is used for PyPy, or for the Parrot VM [2], which is used for Perl 6. Once it becomes a little more mature, Zeta VM [3] may also be a good target. [1] https://rpython.readthedocs.io/en/latest/ [2] http://www.parrot.org/ [3] https://github.com/zetavm/zetavm

I don't think Parrot has been used in some time. Now P6 has the Rakudo distribution using the MoarVM I think. It's always confused me a bit.

Re: Ask HN: Resources for building a programming language?

#34

I'd probably start by using Racket (Racket is a scheme is a lisp) which has a whole toolkit for language building. Arc is written this way, for instance. Often these are lispy languages but there is no reason they have to be. A starting point: http://beautifulracket.com/stacker/ or https://www.hashcollision.org/brainfudge/ That will get you started rediculously quickly and give you things like GC and JIT for free. Yo…

It's worth mentioning that Pyret followed this path. It was originally a Racket #lang. Once we got the design off the ground and decided to primarily target the browser, we wrote a new implementation in JavaScript and Pyret. The tools in Racket (including ragg [http://docs.racket-lang.org/ragg/]) were invaluable in getting started quickly.

This archives the state of the system when we made the switch:

https://github.com/brownplt/pyret-lang/releases/tag/pyret-20...

Some things, like the grammar (https://github.com/brownplt/pyret-lang/blob/5f22ec7c8affde15...) have survived largely intact from that prototype for years.

Re: Ask HN: Resources for building a programming language?

#35

Using Forth as a substrate lets you focus on the more interesting aspects to an even higher degree than Lisp. The last thing you want is detailed instructions; unless you're just building another whatever, which never really made sense to me. Build the most simple and naive thing possible that works the way you want it to, and go from there. That's how Snabel was born: https://github.com/andreas-gone-wild/snackis/blo…

Therein lies my problem with Forth. Yes there is a ton of power, but that is inaccessible to a lot of users. I know I can look at Jones Forth & MeCrisp, but I honestly couldn't see where to start. I'd like to see a tutorial start with either an assembly or C base and then teach Forth fundamentals such as how to start your dictionary and choose between direct/indirect threading and how to implement each. I'm always curious how so many Forth users got to that stage.

Edit: It looks like Snabel is a Forth inspired concatenative language written in C++ with some perl like features. That's pretty cool. If you ever get the chance I think I'd enjoy it if you made some video tutorials explaining the design and some of the code choices.

Re: Ask HN: Resources for building a programming language?

#36
post #24

Understanding Computation by Tom Stuart [0]. While not soley dedicated to creating a language, the first couple of chapters deal with building semantics of a simple language using Ruby as the implementation language (but easily done in any other language you're familiar with). Implementing the virtual-machine the language runs upon in a language you already know provides some really wonderful insights. [0] http://a.c…

That book is not for the faint of heart. It gets deep fast haha.

Re: Ask HN: Resources for building a programming language?

#37
post #12

I strongly suggest you build something esoteric and fun first. This should be a "bare minimum" VM or interpreter. Here's one of mine that I wrote like a 8 years ago[1]: https://github.com/dvx/zeded/ Don't start off with YACC/Bison as they hide a lot of stuff under the hood. It's cool learning things from scratch. The most commonly-suggested book on compilers is known as the Dragon Book [2] and if you want to take thi…

For the dragon book, the first edition is significantly cheaper. Is there anything in the new version making it worth over 10x as much?

Re: Ask HN: Resources for building a programming language?

#39
post #25

You'll want the Dragon Book as a reference, not necessary to get started with, but to build the semantic tree on which you will need to pin concepts on. https://www.amazon.com/Compilers-Principles-Techniques-Tools... If you aren't yet committed to any language, you can start building a parser with PyParsing. It's really easy. http://pyparsing.wikispaces.com/ If you want to take a quick (albeit expensive) class on it,…

Hmm. This might be kind of blasphemous, but I think I'd recommend against the dragon book? As I remember, the emphasis in that book is on syntax-directed translation. I might argue that the less you're thinking about syntax and lexing/parsing crap the better. (For that reason: ignore other answers that tell you to learn about a particular parser generator (e.g. ANTLR). That's just fluff.) Really, if you're coming to…

This might be kind of blasphemous, but I think I'd recommend against the dragon book?

I agree! It's hard to criticize a book rightly regarded as a classic, but I think it solves the wrong problems, or at least emphasizes the wrong areas.

if you design your grammar to be LL(1) you can parse your language using recursive descent

Yep, that's the way to do it.

Post reply on HN