Realistic Functional Programming in the Java Platform


I need to produce software to run in the Java Virtual Machine, but I have no restriction on which language to use, so I'm not stuck with Java the language.

I thought at first about using Scala or Nice: both support functional programming along with OO and other paradigms, and integrate well with the Java API.

So I'm left to decide which one to use. From a quick overview, Scala seems to have more language "features", but lack some serious editor support (I didn't see any emacs mode, and the Eclipse plugin is not in a good state right now). Nice has an emacs mode but the latest version of the language distribution is somewhat old, which made me think if it's still being actively developed. As I've seen many people around LtU report experiences with these two languages, I'd like some comments about the two of them, comparing them if possible. That would help me to decide.

And I'm willing to consider other options too. My main requirements are: 1) multi-paradigm language with good support for functional programming; 2) good editor support (emacs or eclipse); 3) generates code for the JVM; 4) integrates well with Java, being able to both use Java classes and APIs and generate classes that can be used by Java code. As a bonus, having lexer/parser generating tools would be great. Haskell and OCaml are two of my current favorite languages. I like Scheme too but tend to be a statically-typed guy.

Thanks for any help.

[EDIT: added a fourth requirement that I forgot to mention]

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


You might want to look into Armed Bear Common Lisp:

"Armed Bear Common Lisp (ABCL) is an implementation of ANSI Common Lisp that runs in a Java virtual machine. It provides a runtime system, a compiler that compiles Lisp source to JVM bytecode, and an interactive REPL for program development."

In the Lisp vein, there are also Bigloo and Kawa.

The advantages of the Lisps are that they have extensive Emacs (and other editor) syntax support; I suspect you might be able to get a decent SLIME setup running with ABCL.

There's quite a list of languages for the JVM here.


Outside of having some nifty features like CLOS and the MOP, I'm not a big fan of Common Lisp. Besides, ABCL is still somewhat alpha-quality, and I don't think it integrates that well with Java code, but I may be wrong.

About Bigloo and Kawa, I'll take a look at them again, but my impression was that Kawa in particular didn't generate very efficient code, mostly due to difficulties in implementing some scheme features in the JVM. Bigloo seems more interesting.

And yes, I am aware of the list of languages for the JVM, I just find it fruitful to consider the experiences of fellow LtU users, especially regarding Scala versus Nice.

Thanks for the pointers. Bigloo looks more promising now than it did the last time I checked it.


You might also try SISC. They claim to be faster than any other JVM-based Scheme; I've never tried to benchmark it, but it's always been fast enough for what I want. The major drawback is that there isn't a way to save a running image.


I don't really know much about it, but Scala is apparently a functional language (which looks a lot like Java, I believe by design) which generates JVM code. Might be worth a look.

Scala update

So, although not mentioned anywhere I could see in the homepage, it happens Scala does have an emacs mode (along with modes for many other editors).

And there are no lexer/parser generators, but there's support for parser combinators. Very nifty.

I am now taking the time to go through tutorials, documentation and writing some test programs in Scala. Unless I happen to hit against some wall, this is the language I'll be using. Thanks for all the suggestions and replies.

python (Jython) could work

Well you can program python in a functional way, and it seems to offer easy access to your Java stuff if you use Jython.

If your stuck on purely functional programing it might not be the best choice. However if you have other practical considerations it might be useful. There is a fairly large set a python libraries that you can use, which might (or might not) save you a lot of dirty work.

Scala vs Nice

Scala and Nice are quite similar. I have a slight preference for Scala because its type system feels a little more powerful/precise. But I haven't coded non-trivial programs in either so you really should take an in-depth look at both.

A few things I prefer about Scala:

A few things I prefer about Nice:

  • Option types (like Haskell's "Maybe") and a type checking scheme that allows you to use normal C-style null check syntax.
  • Tuple syntax
  • Optional parameters