September 22, 2005

Which language is it anyway?

I've started a new section, Cola notes, to track some of the things I'm putting into Cola. They should get documented in the cola distribution itself, but this is as good a spot as any to make notes on what's going on.

Things were always designed with multiple languages in mind, but one of the things we never really did deal with was how to actually get an executable of the appropriate name to act as the language in question, rather than as parrot. Kind of an important omission, but since parrot was so far from being production it didn't much matter. Given that I've decided that it was a mistake to not have parrot actively hosting a HLL for real and quickly (that's a matter for the post-mortem) I want to rectify it with cola.

Ultimately we'd like to be able to do:

foo

where foo is some language, and have cola invoke the foo compiler and do whatever it is that language does when invoked.

In this case, I'd like cola to treat this the same as if it were invoked as:

cola -L foo

that is, invoke the foo language compiler. This is something that's also not currently in cola, but is going to be added. Like all the other languages we care about, there's going to be a defined on-disk layout of the library, including a defined spot for language compilers.

Basically whenever cola gets invoked it checks the name under which it was invoked and, if it isn't cola, it'll assume it's been invoked as a language and go load up that language's compiler module and Do The Right Thing. (For carefully and well-defined values of "right thing", of course, but that's a metadata issue for later, and another post)

I'm kind of hoping something like this can be ready for qarte reasonably soon. While it isn't anywhere near the language that Parrot was originally designed for, it'll be good to have a working language to futz with.

Posted by Dan at September 22, 2005 01:23 PM | TrackBack (0)
Comments

Speaking of qarte, is there a free Forth online somewhere defined entirely in Forth?

I'm trying to teach myself interpreter / compiler design by implementing Forth (seemed like a fun place to start). Unfortunately, I find the ANS Forth documents seem to assume you already understand how all the words fit together, and just need a ruling of some sort. Given that I'm teaching myself Forth at the same time . . . this doesn't apply.

It occurs to me though that seeing the Forth needed to build a Forth system would help me understand the bigger picture. Unfortunately, Google leads me to a number of discussions of self-hosting (and some Forth books, which I may pick up), but so far no luck in actually getting to free self-hosted Forth interpreter / compiler code.

Any ideas?


-'f

Posted by: Geoffrey Broadwell at September 23, 2005 01:35 PM

Well, as far as learning forth, probably the best book out there is Leo Brodie's Starting Forth. It's out of print, though, and last I heard used copies were kind of pricey. There are a couple of versions of it out on the web -- google for "starting forth" and you'll find 'em.

I'm not sure I can be of all that much help with a self-hosting forth compiler. I admit, I don't think being entirely self-hosting is that big a deal, though you don't need that much non-forth code to get a forth system up and running. One of the joys of a simple language and all, if you skip the self-hosting parts (which are potentially squirrely, as anything which generates executable code directly tends to be) the core can still be nearly entirely self-hosting, and still be intelligible.

Posted by: Dan at September 23, 2005 03:45 PM