CFYourFavoriteLanguage (Formerly CFGroovy)

CFGroovy grew some wings this afternoon.  It retains it's core functionality of running Groovy code in a CFML environment, whether you have it installed on your classpath or if it's transparently loaded from the local copy of the JAR.  However, it now supports any JSR 223 scripting language as well (assuming you're on a 1.6 or newer JVM).  Of the various choices, Groovy seems the best fit for CFML developers (hence the focus on this language), but I also tested Python (via Jython) and PHP (via Quercus).

Of the CFML engines, Railo 3.1 was the champ, running all three guest languages flawlessly.  ColdFusion 8.0.1 refused to run the Python example, not really sure why.  Open BlueDragon refused both Python and PHP.  All three run Groovy, of course, even with the conversion to use the JSR 223 interface (for consistency) instead of the "normal" GroovyClassLoader interface.

You can access any installed languages via the new 'lang' (or 'langauge') attribute; Groovy remains the default, of course.  Here's an example for PHP:

<g:script lang="php">
<?php
  $variables["myArray"][] = "it's some PHP";
?>
</g:script>

The empty brackets mean "create a new item at the end", so that line appends a string to the named array.

Latest mods are in Subversion, of course.

9 responses to “CFYourFavoriteLanguage (Formerly CFGroovy)”

  1. Justin Carter

    Barney, that is super slick :) Does this mean that Rhino (JavaScript) would also be supported now? I have some unfinished business with Rhino that I could never solve with your old CFRhino project :) Hehehe…

  2. Justin Carter

    (Oops, forgot to tick subscribe to comments!)

  3. Justin Carter

    BTW for the benefit of others there is a list of JSR 223 script engines here:
    https://scripting.dev.java.net/

  4. Honey

    You sure get busy when you go to conferences. This is awesome! I can't wait to use PHP in my CFML. It's like a dream come true!

  5. anthony

    How does this compare to Sean Corfield's "Scripting for CF8″ (http://scripting.riaforge.org/)? Is it just a different implementation?

  6. Sean Corfield

    Mine was a proof of concept focusing on JSR 223 from the get-go. I never really developed it beyond that state. Once Barney's CFGroovy appeared, there seemed no point in adding Groovy support to my project and now, with other JSR 223 languages supported by CFGroovy, I think I'll retire my project completely.