| This is a proof-of-concept for compiling Groovy to native code. |
| |
| Goals: |
| - Better performance / reduced overheads (cpu, memory, start-up time). |
| - Appealing alternative to Perl/Python/Ruby/shell-scripts. |
| - Simple install (src tarball, RPM, dpkg, windows installer, OS-X whatever). |
| - No JVM required. |
| - Ability to use Groovy to access less Javaish libraries (POSIXy stuff, MFC, .NET). |
| - Ability to use Groovy (and Java) objects from other languages (C, C++, Perl, Python, Ruby, .NET, etc) |
| |
| WARNING: This is an experiment. It's a proof-of-concept. It probably won't work. But maybe it will. |
| |
| The first attempt at this package uses the GNU GCJ compiler. This is built on top of GCC and is |
| available for UNIXy platforms (including Linux and OS-X) and Windows (with Cygwin). |
| |
| These are the first set of goals for the experiment. |
| |
| |
| |
| *** Goal 1 : Native standalone executable of .groovy file. |
| [Complete] |
| |
| The existing Groovy compiler (running on a JVM) can compile .groovy files to .class files. |
| GCJ can then compile these .class files to .o binary objects. |
| GCJ can link these objects (together with a native version of the Groovy runtime library) into a |
| native executable. |
| |
| The challenge is building the native runtime library. In particular, identifying if the runtime |
| byte-code generation, custom class-loaders and dynamic proxies will cause problems when moved to |
| native code. |
| |
| Certain features of the Groovy language may be excluded to meet this goal and a JVM is still |
| required at build time. |
| |
| |
| |
| *** Goal 2 : Native Groovy libraries. |
| [In progress] |
| |
| Compile a collection of .groovy files into a .so that can be linked to from other Groovy or native |
| libraries. |
| |
| Provide samples for Groovy, C and C++ apps all linking to another Groovy library. |
| |
| |
| |
| *** Goal 3 : Native .groovy compiler. |
| [Not started] |
| |
| The actual Groovy compiler should be native (as well as the runtime) allowing Groovy to be developed |
| entirely without a JVM present. |
| |
| |
| |
| *** Goal 4 : Usable tool set. |
| [In progress] |
| |
| A set of simple wrapper tools should be provided for common features: |
| - Compiling and linking a Groovy library or standalone executable. |
| - JIT style interpreter (like Python) that runs a Groovy script directly by recompiling if necessary. |
| - #!/usr/local/bin/groovy style declaration for scripts allowing direct invocation. |
| |
| |
| |
| *** Goal 5 : Runtime interpreter. |
| [Not started] |
| |
| Allow Groovy snippets to be evaluated dynamically at runtime (the functionality of GroovyClassLoader). |
| This could get tricky. |
| |
| |
| |
| *** Goal 6 : Complete language features. |
| [Not started] |
| |
| Get all the unit tests running on the native Groovy. This excludes Java specific extras such as JMS |
| and Servlets. |
| |
| |
| |
| *** Goal 7 : Installation bundle. |
| [Not started] |
| |
| Provide a UNIX installation bundle that contains scripts and instructions for getting native Groovy |
| running on a machine. |
| |
| |
| |
| *** Goal 8 : Optimizations. |
| [Not started] |
| |
| Profile code to see how it can be made snappier. Especially important is the startup time. A plain |
| GCJ compiled Java file starts within <50ms, whereas Groovy is taking much longer. |
| |
| |
| |
| *** Goal 9 : Provide Groovy with simple access to native libraries. |
| [Not started] |
| |
| Extend the Groovy library and build tools to allow easy access to code outside of Groovy/Java from |
| Groovy classes. |
| |
| Something like: |
| |
| import ncurses // use libncurses/ncurses.h |
| class Thingy { |
| void doStuff(name) { |
| ncurses.printw("Hello ${name}") // print string |
| ncurses.refresh() // display it on screen |
| ncurses.getch() // wait for key press |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| - Joe Walnes <joe@thoughtworks.net> |