Dog Sighting

Sorry about such a string of offtopics but now that I’ve posted something SD-related, I just have to tell you about literally bumping into Beth and Duane “Dog” Chapman at the airport. Tina and I were over in Honolulu a few days ago, all bleary-eyed and coffee-deprived from an early morning flight, and I had to grab Tina and yank her back lest she knock over this bottle-blonde woman with huge knockers making her way to the curb. “Beth” I mouth. (If you haven’t seen the show Dog The Bounty Hunter you might think I’m a sexist pig for characterizing a woman by the size of her breasts. If you have seen the show, you’ll understand that it’d be like not describing Yao Ming as “tall.”)

So anyway, sure enough, it’s all there — Dog, Baby Lisa, the big black SUV van. A guy taps me on the shoulder and says “I’m going to call my mother and put you on the phone. You have to confirm that we’ve actually seen Dog.” So I do that, and she starts crying because her favorite people in the world are: Dog, Elvis, and Princess Diana. How’s that for company?

I know I have to alert my friend Fabian, who cracks up at the show. I send a text message “Beth n Dog at airport.” As luck would have it, Fabian’s in the airport in San Juan, Puerto Rico when he gets the SMS. Now apparently, Fabian doesn’t have my cell phone in his cell phone, so he just gets the text message from an 808 area code. As you can imagine, his first thought is “Beth and Dog are in Puerto Rico?” and his second thought is “Why are they telling me?” and his third thought is “I guess they need a ride.” So about thirty seconds later I get a phone call and through a bad international connection I hear this very tentative “Huh…hello?”

Okay, back to regularly scheduled programming…

Writing Your Own Language: Choose a VM or Native?

Andrew Binstock has a good post on “Writing your own language — How to choose a VM.” In the post, he says that “Most of these VMs encourage your compiler to output not bytecodes but source code using their native language.” But at the level of code generation, you’re talking low-level output, it’s much harder to take advantage of the abstractions of a high-level language. In other words, I don’t think that for code generation, it’s that much harder to output C than it is to output Ruby (or Lua or Java or C# or Haskell or whatever). And, if so, I have to wonder if targetting a VM (which all, as far as I can tell, are more constrained than the ‘portable assembly language’ of C) is not more trouble than it’s worth.

Of course, my argument only holds true for writing a new general purpose language: a domain-specific language that is primarily additive (for instance, a language that specifies the structure of a particular type of game cough cough) can, when targeting a VM, accept huge swaths of functionality, like type systems and control-flow structure and so forth.

And also, of course, whether you’re building a DSL or a general-purpose language, you will most likely end up using a parser generator. I personally like ANTLR, which like most generators allows you to alter the generation target between C and higher-level languages (right now, the significant upgrade to ANTLR 3 is being tracked by contributors writing code generators for Java, C++, C#, C, Objective C, Python, Ruby, LISP, Perl6, PHP, and Oberon).