yozzeff thinks

musings about programming

Montag, Dezember 27, 2004

Choosing a Scripting Language for the JVM (Part II)

Jython


Actually i wasn't realy looking for a new language because i already had one: Jython.
Python and Jython are incredible fun to work with and i was enjoying hacking it every single time. But at the end of last year i had my very doubts about the future of jython. The last real relase has beed done at the end of 2001 (v2.1) and a alpha release has been done at the mid 2003 (v2.2) and then there was not very much volume on the mailing lists for the last 18 month.
All of this seems to change at the moment as Samuele seems to be close to a beta release for a Jython 2.2 and the email volume seems to have uncreased as of late.
But then again python lacks a features that i definitly want for my scripting language: it should lend itself rather well for the creation of small (declarative) languages. In short: P|Jython syntax is to complex for defining a concise language. This sounds sort of ridiculous as python has certainly the most concise syntax one can imagine. But the lack of a simple closure syntax or a macro mechanism makes defining languages on top of python a rather painfull exercise.
As long as you stay purely declarative it works somehow thou its errorprone if the users of the new language do not know about python. The above example might look like this in jython:


foo = "AFOO"
bar = "BAR"

Parent = [
child(foo),
{
child("a_new_foo"):
[
grand_child(bar),
include("/foo/bar/module1.mod")
]
},
child("something different"),
include("/bar/foo/module2.mod")
]

Actually python syntax leaks to much here. To many commas, to many brackets and braces. If you dont know what a list is in python and what its syntax is you are lost. And you have no easy way to escape. What if you like to have module1.mod included only on a certain condition?
Using the decorator syntax for Python 2.4 it gets better but not very much.


foo = "AFOO"
bar = "BAR"
child="child"
parent="parent"

@closure
def parent():
@closure
def child(arg=foo): pass
@closure
def child(arg="a_new_foo"):
@closure
def grand_child(arg=bar): pass
def include(arg="/foo/bar/module1.mod"):pass

One could write a decorator function that executes a function directly after definition and which examines the argument declaration and builds up a tree
representation of the multiple functions. But to be honest: this is far to much XML alike.

Groovy


Groovy was very much all the hype across the first half of 2004. I fell for the hype to. Well its not all hype. Groovy has some interessting concepts to it. And to be fair. Groovy's AntBuilder and examples made the need for closures very much evident to me. And i very much like the way optional typing is planed.
But than again Groovy has a host of really serious problems which simply forbade it to introduce it into production system:

  • It's creators focus|focused far to much on saving keystrokes. This very often opened hard to solve syntax errors as it is not clear if the compiler and programmer speak the same language

  • Error reporting consists largely of java stacktraces

  • Groovy tries to be to many things at once

  • There was a long period where development stalled


To be fair things seem to improve right at the moment. A lot of syntactic (and therefore semantic) problems are worked on (thou results have not been
published entirely yet). There was a new beta a week ago and a lot of stacktrace issues seem to be solved.
Nevertheless i remain a sceptic right now. Groovy is far to perlish for my taste and i am still not convinced that all semantic issues have been resolved.
Maybe i am going to revisit Groovy in 6 or 12 month time from now. Meanwhile i have chosen the language i am going to use for now:

JRuby


Lets explain my selection of JRuby with the example i used at the beginning


foo = "AFOO"
bar = "BAR"

parent do
child(foo)
child("a_new_foo") do
grand_child(bar)
include("/foo/bar/module1.mod")
end
child("something different")
include("/bar/foo/module2.mod")
end

This is as concise as I like it (you can even replace do and end with braces) and I can easily escape to imperative style if I need to.


foo = "AFOO"
bar = "BAR"

parent do
child(foo)
child("a_new_foo") do
grand_child(bar)
if arg[1] == "X" then
include("/foo/bar/moduleZ.mod")
else
include("/foo/bar/moduleX.mod")
end
end
child("something different")
include("/bar/foo/module2.mod")
end

Of course JRuby has its own host of problems:

  • The development of jruby has stalled for over 2 years. But in march version 0.7 was released and version 0.8 is imminent any day.

  • Two-way-integration with java is still weak. Meaning if you use JRuby by executing it from your java program there are some workarounds you have to apply. But again java-integration should be improved very much in 0.8.

  • There's almost no documentation. I will try to improve that.


So lets see how my decission works out.

1 Comments:

At 12:34 nachm., Blogger Jose said...

http://www-106.ibm.com/developerworks/linux/library/l-cpdec.html

Surely you know already, but it can be useful for you.

 

Kommentar veröffentlichen

Links to this post:

Link erstellen

<< Home