Elf is a Perl 6 implementation project (2008 Q2-Q4, 2009 Q1). Its purpose is to help bring Perl 6 into existence by attracting developers, of which there are currently regrettably few. Its approach is to create an incomplete p6 compiler written in p6, self-compiling, usably fast, with a spec parser. The motivating hypothesis is that given a comfortable environment, in which to use p6 to implement a full p6 compiler, developers will come. Attracted by "Elf is written in p6, parses all of the test suite, compiles itself, is easy to develop, and is not significantly slower than p5. Perl 6 works. Xmass will be here just as soon as you write enough Perl 6 to make it so.".
Elf is a means, not an end
Elf is currently for people who wish to create a Perl 6 implementation written in p6.
If you wish to instead write random Perl 6, you may or may not be better off working with pugs or rakudo. Pugs can run small and sometimes medium sized programs, though you will have to work around pugsbugs, and development is currently (2008-Sep-23) inactive. Reefer Jacket
Parrot is more up to date, and is being developed, but has been focused on implementing language features, rather than on becoming generally usable.
The two biggest p6 files it runs are the rakudo implementation. Parrot/rakudo is mostly written in C and PIR.
But for the elf project, the critical point is that pugs and parrot/rakudo have been unable to attract many developers. Elf exists for the hypothesis that given the opportunity to work in p6, more developers will be interested in contributing to the implementation of Perl 6. Rakudo is developing the capability to write p6 prelude in p6. As that happens, elf can benefit from it too.
But it's not there yet, and it's not clear how large an impact the change will have. Pugs had part of its prelude written in p6 too. It was bottlenecked on haskell work.
Elf exists to encourage Perl 6 implementation development. That doesn't mean just elf implementation development. Your are encouraged to create derivatives. Elf is designed with hotswappable parts. For example, the usual way to build non-trivial new functionality is to fork a version of the current elf_letter version, -I'ing back to the original for all the parts you don't need. The elf_seoletter versioning permits derivatives to continue to run, without being maintained or broken by backwardly incompatible progress.
abstract: parser -> IR -> IR analysis -> emitter +> backend runtime + prelude current: STD_red => [IR -> IR analysis -> emitter +> some p5 runtime] +> p6 primitives partially written in p5 + prelude written in p6 ... small CL runtime] +> p6 primitives written in CL and p6 STD_blue => ... next: STD_green => ... then (objective): [elf-compiled STD -> IR -> IR analysis -> emitter +> small p5 runtime] +> p6 primitives partially written in p5 + prelude written in p6 ... small CL runtime] +> p6 primitives partially written in CL + prelude written in p6
- Elf is using an external parser, STD_red, written in ruby, based on an old version of the spec grammar STD.pm.
- The compiler core is written in p6. The repetitive portions are metaprogrammed (currently in p5).
- There is a working p5 backend.
- There is an almost-working SBCL Common Lisp backend.
- A p5-based regex implementation is being imported into elf, with its IR and analysis shifted into p6.
Elf compiles itself to p5 in under a minute. Typical edit-test latency is 10 seconds or so. Ruby 1.9 is needed for STD_red. Only *nix is supported.
- CL backend - Extend and debug. Milestone: elf self-compiles on it. Status: Can self-compile, but has a small unpursued diff when compiling the p5 elf.
- STD_blue - A new external parser which uses the up-to-date version of STD.pm. STD_blue is currently a thin p5 wrapper around the STD reference implementation src/perl6/gimme5, also p5. It may be necessary to fork at some point (for bugfixes, better Match node labeling, or to permit running with || in place of |, as a fast implementation of | does not yet exist (STD_red takes this approach)). STD_blue may currently be too slow to replace STD_red, but this is a step towards parsing happening within elf. Milestone: elf self-compiles on STD_blue. Status: Can self-compile, but gimme5 currently requires a small tweak to p5 elf to compile it.
- STD_green - A version of STD_blue, written in p6 instead of p5, compiled by STD_blue+elf, and using elfish/rx_on_re. Tasks are teaching STD_blue and elf to generate IR for STD.pm, integrating rx_on_re into elf. Minimum success criteria is elf self-compiling on STD_green. Ideal success criteria is STD_green generating identical output to STD_blue on all of elf and t/.
- Move the STD_green code into elf.
- At this point, the front-end, compiler core, emitters, and some of the runtime(s), will all be written in p6, and self-compiling on two backends.
Next steps will likely include some minor fiddling with preludes, code cleanup, and increased language coverage. Milestone (fuzzy): Time to aggressively solicit developers.
- Why Common-Lisp?
- A problem with p5 backends has been the tension between "correct but glacial" and "usably fast but non-spec". Common-Lisp is deeply similar to Perl 6, but faster than p5. It has good compilers, permitting an attempt at correctness while remaining usable.
- How does elf compare with other implementations?
- Elf is currently (2008-09-15) the only implementation which can handle a p6 program as large as elf itself.
- I don't like how X was designed. Can I pursue my own X?
- Yes. Elf was engineered to make it very easy to create derivative compilers.
- Why was this page created?
- moritz++ suggested a more easily accessible introduction to elf.
- Where from here?
- #perl6 on freenode.
- Callbacks? I want to use multi-methods! Elf exists to give you the possibility of writing a Perl 6 compiler using multimethods. Before elf, well, you could have started a p6 project written in common lisp. And struggled to find developers to help you. But specifically regards multimethods, yeah, I hope to switch over at some point. It just hasn't been critical path.
- I hate the elf IR nodes! I want a minimalist kernel! Me too. I decided it too risky for the early bootstrap. Elf is designed to allow its parts to be hot swapped. You can work on a new IR, now, in p6. That's why the current one is called IRx1. Not just experimental, but only the first experiment.
- So I can start my perfect p6 compiler now?! No. No full Perl 6 implementation yet exists. If one did, one would write a nifty compiler in ways no existing p6 implementation can run. This is a bootstrap process. What you can do, aside from helping improve elf, is write a "my compiler is profoundly better than elf" in an elf subset of p6. Perhaps you bootstrap, and go from there. If you create a better mousetrap, one capable of bootstrapping, and which doesn't have regressions, it may well be swapped in for elf. Elf is a service, a process, not a code base.
- Wouldn't all the deep p6 type analysis and optimization opportunities be better implemented in Haskell than in p6? Could be. Elf exists to attract developers to Perl 6 development, and increase the likelihood that a usable Perl 6 implementation will someday exist. Elf is in no way exclusive. An optimizing p6 compiler written in haskell would be great.
Even if it doesn't become peoples' favorite implementation, it could be come the optimization testing ground and baseline against which other implementations are measured.
- Is the subset of Perl 6 which elf supports documented somewhere? No. It has been growing, and will likely end up different between backends. Best bet is to look at the elf sources, and use the idioms there. Given that there was only briefly a second elf developer, documentation priority has been very low. Which regrettably hasn't been an issue yet.
- I'm not a compiler writer, so I guess I can't help? A language development effort is a community. There are things which would help, even things which are near-term critical path, which need little or no Perl 6 knowledge. Some which don't even require programming knowledge. As of 2008-Sep-23, no one has even gone through the p6 spec and pulled out all the prelude (standard library) functions names and argument types into a single file. Think "there are currently very very few p6 developers".
Please feel free to add questions and comments, here or in Talk:Elf