Listening To Reason

random musings about technologies by Andy Norris

10 June 2006

Book Review: Build Your Own .NET Language and Compiler by Nilges

Summary: Very good for what it does.

First, some clear demarcation about what this book isn't: if you want a book with a really strong theoretical background in compiler design, this isn't it. I have Programming Language Pragmatics by Scott, and I recommend it.

Second, if you want a book about compiling to IL for direct execution, this isn't that book either. Frankly, this book is poorly titled in that respect. I don't yet have Compiling for the .NET Common Language Runtime by Gough, but it supposedly focuses specifically on this topic.

So what is this book? It's a practical, highly readable book about how to build a scripting language interpreter in VB.Net. A compiler theory textbook can teach you the principles involved in scanning and parsing, but it's likely to leave you wondering how you actually put any of that to use in real code. This book fills in enough theory to have an idea of what you're doing (with a little to spare), and lets you dive right in and work with practical real-world algorithms and code for actually doing it.

If you are a working programmer and you want to add a scripting language to an application you've written, it's easy to conclude that it's way too complicated to do all that stuff. This book is a fantastic antidote for that. It goes through things like tokenization, formal grammars, and recursive descent parsing in plenty of detail, any anyone who understands the basic CS building blocks of data structures and algorithms should find the coverage easy to follow. The text sometimes meanders a little too much, but it's still far more readable than anything else on the topic that I've run across.

My main criticism of this book is that it's a lot better about how to read in a language than how to do something with the result once you've read it in. The included interpreter operates on top of its own limited stack-based virtual machine, and the parser emits opcodes for it. This isn't covered in nearly enough detail, and my sense is that it's because the author isn't really thrilled with his interpreter. My gut feel is that this is kind of a neither-fish-nor-foul solution. A powerful solution for emitting opcodes would generate legitimate IL for the CLR, which the author gives a brief overview of, but doesn't follow through enough to produce real-world code. By contrast, I think a simpler solution for purely interpreted code would produce directly evaluatable function, statement, and operator objects, and not worry about emitting a language or dropping variables on a stack. The author's solution would seem to lack either the performance advantage of the former solution, or the simplicity and conceptual clarity of the latter. The only advantage I can see is pedagogical: it teaches you how to generate opcodes from a parse tree without wading through the complexity of a real-world imtermediate form like IL, GNU RTL, or Java bytecode.

Still, as long as performance isn't paramount, this is a solution that will actually work as an interpreter for a scripting language in the real world. This book covers a lot of ground, without ever completely losing its practical approach. Even though there are some flaws, and some areas I would have loved to see covered in greater detail, this is a tremendously useful book for the right audience.

Tags: , , , ,


At 11:38 PM, Anonymous Anonymous said...

Thanks for this very thoughtful review.

Edward G. Nilges

At 11:40 PM, Anonymous Anonymous said...

It is the goonzu gold which make me very happy these days, my brother says goonzu money is his favorite games gold he likes, he usually buy some goonzu online gold to start his game and most of the time he will win the buy goonzu gold back and give me some cheap goonzu gold to play the game.

At 12:50 AM, Blogger Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.

At 3:43 AM, Anonymous Anonymous said...

i dont know if there suitalbe to write something good website i meet here, for i hope every body could have a good shopping experience online.

here i want to introduce this website, mainly selling nfl jerseys,
ghd, christian louboutin, and air max 95.

they offer 24 hours online service, and very very good customer service.
i buy the air max 90 shoes online on the website, nice design and good quality. that is why i strongly introduce you here.

it is not a advertisment, just share my shopping experience with everybody. hope you have a nice day, and could enjoy the good shopping.

At 1:10 AM, Anonymous Microsoft Office 2007 said...

Office 2010
Microsoft Office 2010
Microsoft word
Office 2007
Microsoft Office
Microsoft Office 2007
Office 2007 key
Office 2007 download
Office 2007 Professional
Outlook 2010
Microsoft outlook
Microsoft outlook 2010
Windows 7


Post a Comment

<< Home