> To be safe one often retains a > stub compiler for some subset of the language written in another > language, and then implements the rest of the language in the stub > version.
This makes a lot of sense. So basically, a subset of Clojure could be ported to whatever language you'd want to target, and then that could be used to bootstrap the rest of the language? Sounds like a neat route to go. On Jul 9, 12:18 pm, Daniel Lyons <[email protected]> wrote: > On Jul 9, 2009, at 10:07 AM, Paul Mooser wrote: > > > > > Since clojure is a compiled language, and is going to just end up > > generating java bytecodes, I wouldn't expect it to be particularly > > slower if it was written in itself. Maybe that's naive ? > > It's not naive. This is called self-hosting and it is very common in > programming language implementation. To be safe one often retains a > stub compiler for some subset of the language written in another > language, and then implements the rest of the language in the stub > version. This is what GHC does for Haskell with Core and PyPy does > with RPython for Python (though GHC ultimately converts all Haskell > into core before compiling it). GCC works similarly, first building > xgcc which is a simple C compiler to compile itself, and then it > recompiles itself with itself, which is why it's such a time consuming > process. > > Another approach is to go whole-hog and depend on a previous version > of the language to build the language. This is what CMU Common Lisp > has been doing (not sure if they've changed this recently or not). I > think Erlang is in a similar situation (the original host language was > Prolog, believe it or not). > > Other languages retain a C or Java implementation forever. This is the > approach of the scripting languages, such as Python and Ruby et al. > There's nothing wrong with that either. > > IMO, the principal advantages of self-hosting are that it forces you > to optimize in places you might not want to and that it gives you a > nice language to write your language in. :) It's also a good exercise > in general and it makes it easier for someone who only knows the > language the ability to work on the language. > > — > Daniel Lyons --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
