What is your preferred scripting language in java world (scripting language on JVM) and way? [closed]
Asked Answered
T

8

8

What is your preferred scripting language in java world (scripting language on JVM) and way? When do you prefer your scripting language over java (in what situations for example for prototyping)? Do you use it for large projects or for personal projects only?

Ticktock answered 18/3, 2009 at 7:45 Comment(0)
J
4

My favorite is Jython, and I use it by embedding a Jython interpreter in my Java application. It is being used in commercial projects, and it allows to easily customize the application according to the customers' needs without having to compile anything. Just send them the script, and that's it. Some customers might even customize their application themselves.

Jennifferjennilee answered 18/3, 2009 at 7:55 Comment(0)
E
5

For me, Clojure wins hands down. Being a Lisp, it's concise and dynamically typed, it has enormous expressive power so I can write a lot of functionality in a few lines. And its integration with Java is unsurpassed – I'm only partly joking when I say Clojure is more compatible to Java than Java itself. As a result, the entire breadth of Java libraries, both from the JDK and 3rd party, is fully useable.

Finally, with a little care Clojure code can be as fast as Java code, so I'm not even losing performance.

Enate answered 11/12, 2009 at 21:56 Comment(1)
+1 - as Stuart Halloway has pointed out: Clojure is a better Java than Java.Hayward
J
4

My favorite is Jython, and I use it by embedding a Jython interpreter in my Java application. It is being used in commercial projects, and it allows to easily customize the application according to the customers' needs without having to compile anything. Just send them the script, and that's it. Some customers might even customize their application themselves.

Jennifferjennilee answered 18/3, 2009 at 7:55 Comment(0)
A
4

I've successfully used Groovy in a commercial project. I prefer scripting languages because of duck typing and closures:

def results = []
def min = 5
db.select(sql) { row ->
    if (row.value > min)
        results << row;
}

Translation: Run a SQL query against the database and add all rows where the column "value" is larger than "min" to "result". Note how easily you can pass data to the inner "loop" or get results out of it. And yes, I'm aware that I could achieve the same with SQL:

def results = []
def min = 5
db.select(sql, min) { row ->
    results << row;
}

(just imagine that the String in "sql" has a "?" at the right place).

IMHO, using a DB with a language which doesn't offer rich list operations (sort, filter, transform) and closures just serves as an example how you should not do it.

I'd love to use Jython more but the work on Jython 2.5 has started only recently and Python 2.2 is just too old for my purposes.

Alviani answered 18/3, 2009 at 9:30 Comment(2)
Not only could you achieve the same with SQL, it would be more efficient and easier to read if you did...Asuncionasunder
... and I wouldn't have a simple example that would fit into five lines and which everyone here could understand without 10 lines of explanation. Mind the intent, Sir.Alviani
L
3

I might prefer Scala, but I can't say, still learning. At the moment using Groovy to write small utility programs. Haven't tried even Groovy on Grails. Heard lots of good about Lift Framework for Scala as well.

Limited answered 18/3, 2009 at 7:56 Comment(1)
I was a Scala fanboy for a while (not intended as an insult, it's directed at myself, not you) but I found myself annoyed by its pedantry concerning types and its somewhat complex syntax. It feels like a language with too many kitchen sinks bolted on. I found Clojure to be more comfortable. Of course, everybody's mileage may vary.Enate
A
3

JavaScript Rhino has a compelling advantage -- it is included with the JDK. That being said, later versions of Rhino than the one with Java 6 have nice features like generators, array comprehensions, and destructuring assignment.

I favor using it whenever the ceremony of handling Java exceptions clutters up the code for no real benefit. I also use it when I want to write a simple command-line script that takes advantage of Java libraries.

Asuncionasunder answered 18/3, 2009 at 9:15 Comment(0)
Q
3

Java. Seriously. It's a powerful, easy-to-use (if a tad verbose) language that everybody knows. The integration with Java is great.

Quadrireme answered 18/3, 2009 at 11:35 Comment(0)
S
1

The company I work for embeds Groovy into a Java/Spring website, which is deployed on a number of sites. The scripts are stored externally of the compiled WAR file, and allow us to manipulate some of the site logic without having to roll out new WAR's to each site. So far, this approach has worked very elegantly for us.

A particularly nice feature of Groovy is that it can closely resemble Java code, which makes it very easy to port existing Java classes to it.

Supersede answered 18/3, 2009 at 11:47 Comment(0)
C
1

How about SISC (Second Intepreter of Scheme Code)?

REF: http://sisc-scheme.org/

Conductive answered 23/10, 2009 at 12:8 Comment(1)
+1 for pointing this language out. Looks very cool, especially if you're a seasoned Scheme specialist unwilling to switch to Clojure.Enate

© 2022 - 2024 — McMap. All rights reserved.