Live data from Hacker News

Ask HN: Resources for building a programming language?

news.ycombinator.com

21–30 of 87 posts

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

#21

This is for building a compiler for the language tiny: http://thinkingeek.com/gcc-tiny/ Otherwise, get your hands dirty with a parser generator(PEG parser generators[1] tend to be fairly forgiving). It is pretty easy to get started making an interpreter that way, and it is quick to prototype with. [1]: http://bford.info/packrat/

I would recommend keeping your hands clean and using ANTLR [1]. ANTLR4 is powerful lexer/parser generator. LL(*) is ridiculously powerful. Also, ANTLR is well documented and the his book [2] is quite readable.

[1] www.antlr.org

[2] https://pragprog.com/book/tpantlr2/the-definitive-antlr-4-re...

Also, if you're really only interested in the language then you should think about targeting LLVM IR or the JVM.

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

#22
Most of the responses so far are about implementing. My favorite intro to programming languages was http://www.eopl3.com/ (though the first edition was more fun and not quite so focused on being a classroom textbook). Working through it, you write interpreters, but that's to make the ideas concrete and testable, not to replace a compilers class. There are newer books that may be better -- I hope someone who's studied them will bring them up.

http://wiki.c2.com/?ProgrammingLanguagesAnInterpreterBasedAp... was very fun and surveys a wider variety of languages, though it's also very dated now.

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

#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.co/7MI5j7h

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

#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, Dave Beazley offers one: http://www.dabeaz.com/chicago/compiler.html

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

#27
Here's an ebook on the subject: "How to Create Your Own Freaking Awesome Programming Language"

http://createyourproglang.com

Here's what some programming luminaries had to say (lifted from the website):

“The book I want to read.” — Matz, creator of the Ruby language

“I really love this book.” — Jeremy Ashkenas, creator of the CoffeeScript language

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

#30
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 programming language design with the thought "I'm going to make an imperative, object oriented language" (with parallelism as an afterthought), you're doing it wrong. The world has enough of those already and you're going to invent something worse than what's already there.

Probably, instead of inventing a new language (say Matlab for matrix operations or Prolog for logical reasoning), you'd be better off implementing a library that handles the same concepts and embeds into another language (which is really what happened with Tensorflow or MapReduce to think of two examples).

(Grune's book "Parsing Techniques" is a great reference on parsing crap, but the secret is that if you design your grammar to be LL(1) you can parse your language using recursive descent: you only need a fancy parser if you designed a more complicated grammar (why'd you do that?))

Recommended book: The Reasoned Schemer. It's a cute (maybe too cute) book that shows how to implement a logic programming language (~datalog) using scheme as a base language. The Wizard book (structure and interpretation of computer languages) also has really cool examples that I think 60% of programmers I've worked with in industry don't fully appreciate.

Post reply on HN