On Tue, Sep 05, 2006 at 04:25:36AM +0900, M. Edward (Ed) Borasky wrote: > Chad Perrin wrote: [ snip a bunch of bad diagramming ] > > You can usually do something like this in Forth. As you're developing, > you save off the whole enchilada (the Forth interpreters and compiler > and assembler, along with your application code, all of which reside in > the dictionary) as an executable. When you're ready to release the > application, you take a special pass and strip out everything your > application doesn't use, getting a smaller executable that only contains > the pieces of the Forth environment needed to run the application. That's at least darned close. I'd have to learn more about what exactly it does to know how close. > > I haven't spent any appreciable time inside either Common Lisp or > Scheme, or for that matter Ruby, so I don't know how this would work in > any language except Forth. Maybe what you want is as "simple" as > implementing Ruby on top of Forth. :) Actually, now that I think about it, I wish something like that would be what they'd do for Perl 6 instead of wedding it to a VM if they want some kind of persistent compilation that doesn't preclude runtime dynamism. > > > There would likely be more binary size necessary, but considering that > > even an interpreter is (generally) a compiled binary that just operates > > on input, I don't see any reason to assume we cannot cannot compile > > dynamic language code into a persistent binary with accomodations made > > for the parts of the program that require runtime dynamic behavior. > No reason it can't be done. The question is only "should it be done?" :) I certainly think so, if only to provide an alternative to the "worst of both worlds" bytecode-VM approach. > > > This strikes me as a superior approach to a JIT compiler/interpreter > > approach like Perl's, a pure interpreter approach like Ruby's, or a > > bytecode compilation plus runtime interpreter VM like Java's, for > > performance. > > Java also has JIT, of course. Curiously enough, someone once told me > that if I looked at the JVM carefully, I'd see Forth. :) It's a quite different approach to JIT compilation than Perl's, of course. > > > Add to that the potential increased performance for some > > parts of a program written in a more dynamic language something like the > > following might actually run faster than the equivalent compiled program > > I diagrammed above: > > > > |+++++++--------| > > > > . . . depending on how well those dynamic bits (represented by the > > hyphens) optimize at runtime for a particular run of the program. > > Well ... maybe we should leave that to the chip? :) That's sorta the idea. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] "It's just incredible that a trillion-synapse computer could actually spend Saturday afternoon watching a football game." - Marvin Minsky