Picking a compiler book

[I posted this on Hacker News. Reposting it here to reach a different audience.]

For years I have been interested in programming languages and their implementation. I have made many attempts over time to create my own (experimental) programming languages, mostly interpreters.

The problem is, my knowledge of this area of computer science is fragmented, to say the least. I picked up things here and there, but I never learned how to properly implement a compiler, interpreter, virtual machine, or even a parser.

So, I have decided to pick a book and work my way through it. I just don’t know which book. They all seem equally intimidating. A few candidates that I am considering are:

  • The Dragon Book (new version, 2006); seems awfully big though, making me wonder whether I should pick a book that is a bit less comprehensive first, then come back to this one later;
  • The Dragon Book (old version, 1986)
  • Engineering a Compiler, by Keith Cooper and Linda Torczon
  • Parsing Techniques – A Practical Guide, by Dick Grune; focuses on parsing though rather than the whole package

So my question is, which of these books, or any others, do people recommend? (My main interests would be interpreters and languages that compile to bytecode, either custom or targeting existing VMs. “Traditional” compilers that produce a standalone executable, not so much.)

Thanks in advance!

:: Comments (8)

It’s that time again…

…time to launch a new blog… (in progress, so bear with me…)

:: Comments off

Anybody know a good comment system?

I’m working on a new website, and I’m looking for a decent comment system. I checked out Disqus, but it doesn’t look good with the site’s design; also, it seems to be overkill. I don’t need people to engage in “discussions” and have “comment threads” and whatnot. Something simple would suffice, e.g. something like this blog’s comment system (which is part of WordPress, so I don’t think I can use it separately).

Most modern comment systems seem to focus on the discussion idea, though; Intense Debate and Echo (formerly JS-Kit), for example. HaloScan would have done the job, but it’s gone. :-(

Anyway, if anybody reading this knows of a simple comment system that doesn’t suck, please let me know. ^_^

:: Comments (2)

Muggles

Hey, I didn’t know that “muggle” was in the Jargon File… Apparently it has been there for quite a while too (since version 4.2.2, which came out in 2000). Never noticed it… maybe I should read up on it some more.

:: Comments off

Dependency hell, how I missed thee.

[semi-rant]

It’s one of those days again. I am trying to install fish on my iBook G3. The laptop is ancient, but it runs Tiger and MacPorts and has the latest XCode, so there really should be no problem. Yet there is. The MacPorts version of fish seems to think it needs all kinds of graphical libraries… cairo, libtiff, freetype, and much more, none of which I need for a command line shell. Needless to say, at some point installation chokes on one of these libraries or another. Is there a way to tell MacPorts that I just want the text mode version? Who knows? It’s easy to use when everything goes right, not so much when things go wrong.

So, I figured I’d download the fish source, and compile it “by hand”. That might have worked elsewhere, but not here. I don’t even get to the compilation stage, because ./configure complains that there is no libiconv present, and this is a requirement to build fish, so it stops unceremonially. Problem is, I have four different versions of libiconv sitting on the blasted machine. Four! Three via MacPorts, one I compiled and installed manually. And it somehow can’t find any of them?!

This kind of dependency hell happens all the time, and is the main reason why I am interested in trying GoboLinux. It’s just not fun anymore when you have to wait for hours while the system attempts to fetch, build and install a gazillion dependencies and then chokes somewhere, with no obvious reason as to why it did so, or what can be done about it. I’m not sure if Gobo fixes all these issues, but if it can alleviate them even just a bit, it’s worth it.

(To be fair, fish does install without problems, using MacPorts, on my MacBook Dual Core. But with other packages, I have just as many problems on that machine, if not more. Plus, you get the nice “oh, you have x86_64 libraries installed, but I only accept i386/universal/whatever” (or some variant thereof) error messages.)

I would love a system where these things “just work” and where you don’t have to dive into all the gory details of a library you’re not even remotely interested in, but that somehow indirectly is required to install the software you do want. I mean, this *is* a Mac right?!

:: Comments off

vi, again

I’m in the process of reorganizing a few things here. Development-related things. One of the changes I want to make is to make more use of vi for editing.

I’ve been using (several variants of) vi since the mid-90s (in addition to other editors), but by some definition you could say that I’ve never really used it. What I’ve been doing is trying to make it work like most mainstream editors, with a few commands thrown in. You know, moving through text using the cursor keys, selecting things by holding Shift, etc. Vim makes this particularly easy. But by doing so, I’ve never really experienced the real power of vi.

Some people argue that this is not optimal, to say the least:

Turns out, this is just a completely wrong way to use vi or vim. Using vi/vim properly, you don’t use it modally. You are always in normal mode, and only enter insert mode for short bursts of typing text, after which you press <Esc> to go to normal mode.

So it may be worth exploring that. Fortunately vi clones are available for pretty much every operating system, so if I want to I can use it on Windows, Mac OS X and Linux. The learning curve may be steep, but it’s probably worth it.

What I do wonder is, is there any reason to use a different version than vim? There are other clones; nvi, elvis, to name a few, but it seems like those haven’t been updated in years. Vim seems to be the 800-pound gorilla of vi implementations, and it’s not hard to see why, given its abundance of features, and the fact that it’s being actively developed.

:: Comments off

Building Io on Mac OS X

Io has a new build system. Questions aside whether it’s an improvement or not, I did find that it wasn’t completely obvious to use. Eventually I did get it to work; I’ll describe the process here.

  • Make sure you have a recent version of git installed. I had 1.5.x or so and it failed to clone the Io repository correctly, quitting halfway with vague errors. 1.7.1 works fine; older versions might too, but if you encounter problems during checkout, you should probably upgrade.
  • Also, should you be using Mac OS X 10.4 still (as I do on my G3s), then make sure you have the most recent XCode installed. For Tiger, this is XCode 2.5, which can be downloaded from the Apple site. (Login required, so no link.) (Of course, even if you’re using 10.5 or 10.6, it’s still a good idea to have the latest XCode.)
  • To use the new build system, you’re also going to need cmake (which can be fetched from MacPorts, for example).
  • Check out the latest version from the github repository. Just do a git clone; alternatively you could fetch the 2010.06.06 tag from the downloads page, but this contains the previous build system, for which most of these instructions don’t apply. (Note that this tag might still come in handy if the new build system doesn’t work for you…)
  • Once cloned, you should have a directory called io. Edit io/addons/CMakeLists.txt in your favorite editor. You’ll see a whole bunch of lines like this: add_subdirectory(Foo). These are the addons that will be (attempted to be) built. Comment all of them out.
  • Now run ./build.sh. Since all the addons are disabled, this should build the Io VM only. It *should* complete with no errors on OS X 10.5 and higher. On 10.4, there’s a good chance that gcc will choke since it doesn’t know what an “ulong” is. If that happens, edit io/libs/coroutine/source/power-ucontext.h and add a typedef near the top, like this. (There may be better ways to do this, but for now it will allow us to proceed.) Run ./build.sh again after the code change.
  • If all went well, now run sudo ./build.sh install, which should install the Io VM. Run io from the command line to see if it works. (The build date will still be listed as “20090105″, by the way.)
  • If everything works, you can now add and install addons, one by one (or multiple at once if you’re feeling adventurous). Some of them require third-party libraries to be installed (e.g. zlib, libevent, etc.) As far as I can tell, you’re pretty much on your own to figure out which libraries are needed, although there might be some clues in the source. If you use MacPorts, this is a good time to do a sudo port selfupdate, then install the required libraries before you try to install the addons. To try and install one, go to io/addons/CMakeLists.txt again, uncomment the addon of your choice, and rerun ./build.sh. If all goes well, there will be no error message and in the output you should see the addon mentioned (for example, when building the Python addon, you should see “IoPython” listed in the output). If things build properly, don’t forget to do a sudo ./build.sh install again.
  • Update 2011-01-11: If you specify an addon which cannot be built, the entire build will not fail; rather, the failing addon will be skipped more or less gracefully, and sometimes a helpful message is displayed. For example, to build the Regex addon, you’ll need libpcre; I didn’t have it installed on this machine, and near the top of the build output I saw “checking for module ‘libpcre’” and “package ‘libpcre’ not found”. Also, notice that in some cases, addons depend on other addons. In the case of Regex, it needed Range to be installed, so I uncommented that as well in CMakeLists.txt.
  • If an addon doesn’t build correctly, you can take a look at the files in io/build/addons/name-of-addon, or io/addons/name-of-addon, which may provide some clues as to what is needed, in addition to the output of make.

That’s it! It’s a bit of work, admittedly… although I’ve seen worse. (As usual, I find that installing some of the addons is a pain, not because of Io or the build system, but because of dependency hell, version conflicts, MacPorts issues, etc. I guess it can’t be helped.)

Hope this will be of use to someone… anyone… Also, if you know more about the build system, and have tips or corrections, feel free to leave a comment below.

:: Comments off

Decisively flawed

This is pretty ridiculous:

To summarize, FIFA is no longer going to show repeats of “controversial decisions” during games. These would be goals that should have been flagged but weren’t, or vice versa, as we’ve seen quite a few times already this tournament. The “interesting” part here is that they are not striving to make better decisions, but rather to just let them stand (even in the face of overwhelming evidence) and cover things up.

I’m not sure there have been more bad decisions during this championship than usual; it may simply be the case that they are more obvious than they were before. Even so, FIFA’s staunch refusal to upgrade their decision-making methods is staggering. When you watch a game on TV, and someone scores or a card is given, a few seconds later the repeat is shown and it is usually immediately clear whether the referee’s decision was correct or not. How difficult would it be to have the referee (or an assistant) watch the repeat for a moment and then decide whether the original decision stands or not?

In fact, what the article suggests, is that FIFA officials *do* watch the repeat right away, and if the decision was “controversial” (i.e. wrong), they censor it (by refusing to show it again), rather than fixing it…!

This kind of stuff is no longer going to fly during the internet age… I suspect FIFA will have to change their ways real fast, or professional soccer as we know it will die out. What’s the point of watching games that are essentially made or broken by the referee?

~

Update (2010-06-29): This is more like it:

(FIFA big boss apologizes and says video technology will be be considered in future.)

:: Comments off

Another color blindness test…

http://www.archimedes-lab.org/colorblindnesstest.html

For fun and profit, a color blindness test… I only got Test A correct, and half of test H. :-( *blush* The rest is mostly a blurry mess where I can occasionally make out half a number of something.

Also see: http://critiquewall.com/2007/12/10/blindness

It’s interesting… on my MacBook, the images in the aforementioned blog post look almost the same to me… but on my netbook, which has tweaked color settings, they don’t look the same at all. (The effect is limited though… I still cannot pass the Ishihara test. :-)

:: Comments off

Chickadee

In other news, there is a new documentation server for Chicken Scheme online. It’s called Chickadee and it looks pretty damn useful. You can look up built-in functions, SRFIs and eggs. I’m currently working on a little project that uses Chicken, so I guess I’ll be using this a lot. ^_^

IMHO, Chicken and Gauche are the two most desirable Scheme implementations at the moment. They both have a pragmatic approach that isn’t always present in other implementations. (Although I haven’t tried every single one of them…)

:: Comments off

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »