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.
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…
(Oops, forgot to tick subscribe to comments!)
BTW for the benefit of others there is a list of JSR 223 script engines here:
https://scripting.dev.java.net/
Justin,
Yeah, JavaScript should be supported. I haven't done anything with it, but if it "behaves" in the context of the JSR 223 spec, shouldn't be any problems.
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!
Busy? I turned out 77 lines of CFML over three days. If I was "busy" like that at work, Ron would fire my ass. ;) Of course, they're 77 kickass lines, but it's still only 77 lines.
But you're right, running PHP right from ColdFusion should allow us to really leverage our language skills and build some kickass applications. No more wondering how to implement feature X in CFML, just shell out to PHP (or Python, if you're Joshua – silly man), and you're done!
How does this compare to Sean Corfield's "Scripting for CF8″ (http://scripting.riaforge.org/)? Is it just a different implementation?
anthony,
The primary difference is that Groovy is the primary focus of CFGroovy, and supports it out of the box, with no JAR dependencies. Beyond that, not a whole lot of difference. I've tested with Groovy, PHP, and Python, he tested with PHP and Ruby. I have a single tag () that accepts an optional 'lang' attribute, while his is custom tags per langauge, if I recall correctly.
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.