Hacker News new | past | comments | ask | show | jobs | submit login
Create Your Own Programming Language (Book) (createyourproglang.com)
64 points by laktek on Sept 9, 2009 | hide | past | favorite | 64 comments



This is a scam. Take a look at the toc to see how many pages are devoted to the interpreter, the VM and so on. It is impossible to learn how to write a complete interpreter or compiler, (leave alone VMs etc) in such a small "book".

The blurb says

"Become the next Guido Van Rossum, Matz, Larry Wall or Rasmus Lerdorf by creating your own revolutionary programming language in a few days"

yeah right! :-D.

If anyone is really interested in learning to build an interpreter or compiler, here is a book list to work through in order.

(1) SICP (do all the exercises in Chapter 4 and Chapter 5). There is an incredible amount of learning there. Once you've done this, you can write a basic interpreter/compiler for languages with s-expression syntax. [The semantics can be anything you imagine]

(2) Essentials of Programming Languages. This will teach you how many language features work (lazy evaluation, object systems, static type systems ..)

(3) Lisp in Small Pieces - how to implement byte code compilers, macro systems, compilation to C, lots of good stuff here.

(4) A book on lexing and parsing so you can give your language any syntax you want. I prefer Modern Compiler Design by Gries. If you understand the first three chapters you can write your own lex/yacc equivalents. (the book has a lot more to it than these chapters, but it is the best I've seen on lexing/parsing).

(5) Now take a look at the source of your favorite language. ((Lua and the lcc compiler (it even has a book explaining its design) in particular, are very educational).

(6) If you are REALLY serious about optimization, Steve Muchnick's book, Advanced Compiler Design and Implementation.

I have all these books and have derived an incredible amount of learning and joy from them.

yes it is a bit of work, but it is fascinating journey. Enjoy.

EDIT: If you want to go deep into type systems (say you want to grok Haskell's type system from first principles, (or add OCAML like modules to your language, say) Benjamin Pierce's Types and Programming Languages - You are in good shape to work through this after you've finished EOPL


The source to Lua is quite good, though not commented heavily. There's a roadmap by Mike Pall at http://www.reddit.com/comments/63hth/ask_reddit_which_oss_co... , and some other notes on the Lua users's wiki at http://lua-users.org/wiki/LuaSource . Lua has been kept small for embedding, and its designers are adamant about portability, so the code is very clean. (It's also one of my favorite languages.)

Also, _Modern Compiler Implementation in ML_ by Andrew Appel (http://www.cs.princeton.edu/~appel/modern/ml/) is quite good. It uses SML, but is pretty understandable if you're familiar with OCaml or (perhaps) Haskell. I found it vastly more readable than the Dragon Book.


Your advice is good, but you're being a snob. The complexity of a simple compiler is not that high. My language (http://plausible.org/nasal) has a core of about 3-4000 lines of C, well under the size of the Unix kernel explained (very well) by Lions in his classic book.

Sure, language design is a deep field, with lots of subtlety and complexity. And people spend years studying it. That doesn't mean that every language requires a huge tome of background to implement.


"Your advice is good, but you're being a snob. The complexity of a simple compiler is not that high. "

Sure reccomending someone work through SICP chapters 4 and 5 (enough to write an ultra simple compiler/interpreter) is "snobbery". ;-)

So be it. :-P

That doesn't mean this book (referred to in the original posting) isn't a scam. It is.

Any reccomendation on the internet (including mine) is worth only the electrons it consumes. Caveat Emptor!

I've worked through the books I reccomended (and was careful not to reccomend great books like CTM which I have no experience of).

This is the best way I know how to get this knowledge. I am not claiming it is the most efficient method. feel free to provide better paths.

If that strikes you as "snobbery" , bleh to you ;-)


The part that strikes me as snobbery is your statement that you cannot learn language design from a small book. Based on my actual experience in the same regime, some of which involved reading books but far more of which involved thinking through code, I think you're just wrong.


"The part that strikes me as snobbery is your statement that you cannot learn language design from a small book. "

I stand by that. Design in any endeavor can't be learned from books, small or big. Before you can "design" you need the nuts and bolts skill to implement your designs.

The books I reccomended, if sincerely worked through, give you the nuts and bolts knowledge to implement the designs you do conceive. Reading through the source of languages you admire, will teach you a lot (I reccomended that too).

Since I never said you could learn language design (vs learning how to build interpreters and compilers - I started my reccomendation list with "If anyone is really interested in learning to build an interpreter or compiler, ..." -) by working though books, I fail to see what you are reacting against?

I maintain that a 44 page book (particularly this one which is an outright scam) doesn't have the space to cover even the basic implementation techniques, leave alone "design".

Please provide counter examples of such "small books" that teach "language design" if you disagree. One counter example is worth a lot of internet debate!

The shortest introduction I know capable of turning you into an interprter/compiler writer is Chapters 4 and 5 of SICP (and there is a lot of stuff in the previous 3 chapters that lead to these chapters).


Writing a compiler is pretty much trivial. Writing a good optimizing compiler is close to rocket science.


I doubt rocket science is as much harder than everything else as people make it out to be.


That is great advice if you are building an enterprise ready language, have no job and a year to devote to reading and digesting all that literature. This isn't an ivory tower book, it's how to bootstrap your own language quickly using open source tools (which is surprisingly simple once you know how, but very complicated if you don't know where to start).

I love when people create small books, video tutorials about complex subjects. They are an introductory peek at what is cool about a complex subject. Then you have the opportunity to learn more about the parts the interested you, rather than buying "Modern Compiler Design" and realizing you have no interest in writing your own lexer or parser.

Not to say the books/sites you recommend aren't great, they are just overkill.


" it's how to bootstrap your own language quickly using open source tools (which is surprisingly simple once you know how, but very complicated if you don't know where to start)."

You can't "bootstrap a language quickly" using open Source tools unless you already know what you are doing.

Learning how to build a decent language (leave alone an "enterprise ready" whatever that is) language does take more than a few days. Promises to make you the next Matz and Guido "in a few weeks" is outright fraud.

"rather than buying "Modern Compiler Design" and realizing you have no interest in writing your own lexer or parser."

It is obvious you haven't read the book before making this comment. MCD teaches you how grammars and grammer processors work.

Without understanding this you can't use lex/yacc etc properly. Being able to build your own lex/yacc type tools is a bonus.

"they are just overkill."

if you think EOPL, an undergrad text focusing directly on the core of your language interpreter (hint, lexing and parsing are not the core) is "overkill", I have nothing to say to you!

Good Luck with the "build a revolutionary programming language in 21 days" approach!

Coming up next, "Build an Operating System in 21 days and become the next Linus Torvalds!"

;-)


Ignore everything he said except this: "They are an introductory peek at what is cool about a complex subject. Then you have the opportunity to learn more about the parts the interested you..."

It's not a book that'll teach you how to actually do any of this stuff. It's an overview, a gloss, an extended Wikipedia entry in guide form, that shows you the work that goes into creating a programming language. It's like the show "How It's Made." If, at the end, you think you actually want to write a programming language, then by all means, read your set of books. (That's not to say that this was their goal--it was probably a stupid attempt to actually let people design and implement a language after reading one book--but this is what you should take away from it, and a perspective from which reading the book would be useful.)


Another neat book is "The Elements of Computing Systems" (http://www1.idc.ac.il/tecs/)

It is basically a really high level overview of a whole bunch of stuff from EE/CS, from logic gates through VM design through compilers (and sort of OSes, but not really). Each chapter is a project and build on each other (but you can actually do them in any order).

It isn't as in depth as many of these other books, but might be an easier first book.


Don't forget Peter van Roys excellent Concepts, Techniques and Models of Computer Programming


"Don't forget Peter van Roys Concepts, Techniques and Models of Computer Programming"

yes I have this too. But I haven't worked through it so I didn't want to reccomend it blindly. Many talented hackers(e.g Peter Norvig) say good things about this book so I am sure it is great. The language it uses (Oz) is a bit flaky wrt syntax but VERY powerful.

Another recent lovely book, though a bit on the formal side is Gifford and Turbak'S Design Concepts In programming languages. (Another 1000 + pages !! - the road to compiler gurudom has many 1000 page books to work through!).I am working though this and I am enjoying it thoroughly. I hope to finish it by the end of this year.


CTM is a great book, but not about programming language implementation so much as a tour through the big ideas in different programming paradigms. I can't recommend it too highly - it's one of the most readable textbooks I've seen, and it's refreshingly non-dogmatic about the subject material. Usually, language books are heavy-handed about OOP / Lisp / FP / whatever being best, but CTM's thesis is that, since they all have strengths and weaknesses, it's most practical to learn what they do best and how to use them in a complementary fashion.

It covers declarative programming, functional programming, several concurrency models, logic programming, object-oriented programming, dataflow programming, and probably a half dozen things I'm forgetting. The book uses Oz* , with major asides using Haskell, Erlang, Java, Prolog, and probably a couple others.

There's a draft PDF floating around, but if you like it, I'd highly recommend buying the book. (Same with SICP.)

* Which seems like an interesting language, though I've never gotten it to build on OpenBSD, so I've done exercises in OCaml, Lua, or Scheme instead.


By the way, thanks for the book suggestions - some great ones there that I have yet to read!

CTM is good, it covers a lot of theory of programming techniques and IMHO a must read for anybody interested in programming language design. Oz syntax is a bit quirky and weird, but the language seems to be quite powerful and very flexible, supporting many varied types of programming. I have not read all of it yet, but most - not exactly light reading :-)

I will definitely check out the other books which you mentioned though.


"By the way, thanks for the book suggestions - some great ones there that I have yet to read!"

You are welcome! I had to work through some really awful books before I put all the pieces together and stumbled onto the good books.

Even most good books omit some crucial piece (E.g EOPL , as good as it is, doesn't say anything about how to write a garbage collector/memory management infrastructure, SICP doesn't deal with lexing/parsing or type checking and so on.)


I think it's fairly in jest. Marc-Andé Cournoyer is a pretty smart guy. I'd say that this is most likely a nice light overview. That being said, I haven't read it, but I have looked at his code on GitHub.


$40 is a pretty hefty price for a jest, especially one that's only 44 pages and could soon get even more expensive.


Seems more like a prank than like a scam... Anyone tried actually buying it?


No, but clicking buy brings you to paypal.


Hey, I'm the author of the book. I agree the marketing site is not perfect, I'm still looking at ways to improve it, sorry if if it sounds like a scam.

Any tips on improving the copywriting or anything are greatly appreciated!


I think most of us on HN realize it's gonna take more than a few days and a few pages of reading to truly understand what it takes to create a programming language, not to mention becoming the next Guido or Matz. The table of contents looks more like it's an introduction to the concepts with the added bonus of having working code by the time you're done reading. Don't get me wrong - I think the concept and content look great. It's just that you're telling me I'm going to be Larry Wall by Friday and I know that's not true. The message undercuts the content IMO.

My other gripe is with the price. $40 seems high for a 44-page document. I'd buy it if the price was lower.

BTW - thanks for Thin! Because I know your name and work the content came off as sarcasm to me at first, but I could definitely see how someone without this prior knowledge might think it's a scam. Best of luck with this book; it does truly look cool.


Thanks for the comments, you're right, I'll definitely change the copy on the site.


The copywriting is a little over the top, but my suggestion is for the book itself.

I'd like to see more details. Your sample chapter on Lexers, for example, would be much stronger if you went into more details (maybe 3-4 pages) on how a scanner identifies a token, how it knows when it has reached the end of a word, how it recognizes and handles whitespace, why it's important to keep track of indentation and newlines, what is the difference between keywords and other identifiers, etc. Maybe also give a written explanation describing what each section of your lexer for Awesome is doing.

Please consider this as constructive criticism: I think the book is a good idea, but I also think it needs more meat. I don't know how easy it is to revise it at this time, but I think you'd have better luck if you added more details.


"The copywriting is a little over the top,"

a little?

"Become the next Guido Van Rossum, Matz, Larry Wall or Rasmus Lerdorf by creating your own revolutionary programming language in a few days"

Heh heh!


Lose 120 pounds in six minutes!


...even if you only weight 80 pounds.


I've always wanted to weight -40 pounds; where do I sign up?


I sure do take this as constructive criticism :) The idea of the book is to build a simple language not the strongest or more complete one ever. I'll add more details and change the copy on the site. Thx a lot for the suggestions!


I, for one, enjoyed the humor of the parodying of get rich quick sites. If need be you could put a disclaimer, for those that don't detect the humor in the hyperbole, that the book is a playful introduction rather than a comprehensive tome.


$39.99 for a 44 paged PDF? On Amazon.com I can buy a hardcopy version of Compilers: Principles, Techniques, and Tools (2nd Edition) for $86.29 and its got (according to amazon) 1000 pages.


I have a few reams of paper (about 2000 sheets) you can buy for $40 if you want. That's even better value than the book you suggest.


Depends on your definition of value. Aho Sethi Ullman will teach you rather more about compilation of programming languages than 2000 sheets of paper ;-)


It will go up to $49.99 after 500 copies will be sold (ok, another marketing tool I guess)


Yeah, as if he's going to sell 500 copies at $39.99.


I bet it weighs more too :)


I feel the copywriting of the site is a little over the top. The subject matter is interesting enough that most geeks should want to have a look.

Is this a sign of the times? (See also: http://perl6.org). Sure there's nothing wrong with dressing tech up and making it look fun, but at some point it becomes a turn-off, which is a shame. 2600 et al did not need fancy fonts and bright colors to appeal to hackers.

tl;dr - get off my lawn!


Seems like the "book" (44 pages in PDF) is a walkthrough to using compiler building tools and the like. Not a bad idea.

A lot of what surrounds it sounds way too much like a mix of spam and infomercial for my taste. Then again, I am most likely not the intended audience. I must say it makes me smile seeing this marketed as a "cool thing" tough.


Hmm. Are you sure this is not some tongue-in-cheek prank?


Yeah, it kind of reads like ParrotSecrets.com for hackers.


I agree that learning how to create a programming language is a valuable lesson in and of itself -- I may even buy the book to see what it's like -- but claiming that you can create a "revolutionary" programming language within a few days conveys the wrong message.

Creating programming languages is not difficult but designing good programming languages is.


I am designing a (hopefully) revolutionary programming language. (At least, revolutionary in its target domain; a general purpose DSL, if you will).

To do this, I am not reading a 44 page PDF to tell me everything I need to know, instead I'm reading thousands of pages of material(1), I've been prototyping code, talking to people and reading a lot of Lambda the Ultimate discussions. You just can't learn all the fundamental concepts, all the theory and the practical details (language and implementation/compiler/vm) from 44 pages...

1: Some of the stuff I've been reading especially for this: Concepts, Techniques and Models of Computer Programming - 930 pages of fundamental programming language theory. Structure and Interpretation of Computer Programs - 657 pages of Scheme goodness. Advanced Topics in Dataflow Computing and Multithreading - 460 pages of research. Countless SIGPLAN papers. God knows how many web pages and random PDF's.

And thats just the theory, I've yet to get reading the actual COMPILER books. Near the top of my list is the dragon book - another 1000 pages.


Creating a new programming language is trivial. I just invented one called "awesomepython". It's just like python, except that the keyword "and" is replaced by "awesomeand", "if" is replaced with "awesomeif", and so forth. The compiler is one line of awk.

Creating a language that's actually good for something is a very different sort of challenge...


"Creating a new programming language is trivial. I just invented one called "awesomepython". It's just like python, except that the keyword "and" is replaced by "awesomeand", "if" is replaced with "awesomeif", and so forth. The compiler is one line of awk."

Coffee all over keyboard! Damn you!! :-D

Hilarious! Upvoted! Now to clean that spilt coffee!


yeah the marketing is too traditional!, but hey it didn't mention "become the next programming rockstar" :-)

But I mean, if it is a walkthrough then for people interested in the JVM it could be useful.


I'm buying it because I found clear, comprehensive literature explaining the fundamentals of the JVM severely lacking (suggestions welcome, however!).


You can start by playing with the ASM library. It's a java library to parse, generate and analyze JVM bytecode. Here's the official guide: http://download.forge.objectweb.org/asm/asm-guide.pdf

While learning how to use ASM you will also learn about the instruction set of the JVM. It also includes a disassembler that, given a .class file, outputs the java code necessary to generate that class using ASM.


Wow, thanks! You'd be amazed how long I spent looking for the advice which probably took you a couple of minutes to type.

That's an interesting observation, touching on the education discussion - that the bottleneck in advancing individual learning/human knowledge questions is still that of finding someone who knows the answer. Universities provide one solution by creating a "critical mass" of smart people nearby that you can go to for advice. And although maybe my academic network is lacking, I couldn't quite get the same quality of advice reaching out personally as what you gave. StackOverflow and news.YC help [1], but didn't quite give me the solution I was looking for either (until now).

If I was convinced I could consistently good advice from a service, I'd pay well for it - upwards of a thousand dollars a year, I'd imagine.

1. http://news.ycombinator.com/item?id=451655


Became the next Guido Van Russom, Matz... with just reading a book? Seriously?

Edit: it looks like a good website but I'm still skeptical.


The tone seems tongue-in-cheek to me. The page is a humorous parody of get rich quick sites. The product itself is real and, if it gives somebody a quick way to get up and running exploring the basics of language, it's likely worth the $40.


I ctrl+w'd at "your own freaking awesome programming language."


The Dragon Book!


I think its great that we've reached a point in technology that we have people (rather than teams or large companies) creating languages that people can use.

However, if you are looking at books to learn HOW to create a new language you likely haven't answered a more important question: WHY.


Actually, lone people developing languages is not that a rare occurrence. It probably dates back to the beginnings of programming languages.


Stevey answered the WHY question a long time ago:

http://steve-yegge.blogspot.com/2007/06/rich-programmer-food...


What do you mean, why? How many reasons do you need to write code that does something cool?


Writing something cool is one thing. writing a language is another. What I'm saying is if you are using an ebook to create your language (on the jvm no less) I expect there are several other languages that people have spent YEARS on that I bet would solve most of the issues you could ever have if you learned them a bit better

* The JVM is awesome. But there are lots of "hosted languages" already on that platform that likely will suit most peoples' needs.


How writing a compiler not cool? Just because someone uses a book and targets the JVM, which is a great target platform for a lot several reasons, doesn't mean they aren't doing it just because it's fun.


But why pay $40 for fun when you can do it with free information on the net? If you're doing it for fun, then that information is more than adequate. If, however, you're doing it because you want a real language that people should/would use, then a 44 page PDF is not nearly enough, regardless of how good and densely packed it is. For a real (as opposed to a toy) language, you require theory on language design, on compilers, on programming paradigms, on syntax, on computation models and so much more.


Why are you writing this argument? It has been made on the Internet multiple times, and others spent more time writing their argument and explained your point better.


You obviously didn't read the site:

Impress your employer and peers with a résumé that says: I created my own programming language.

That's why ;-)


for fun!


Why not write a book that lets you create your own programming languge in javascript ??

That way you at least get something useful out of the exercise.

(Ducks)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: