Clojure and Scala

To pass the time until kickoff, I’ve been writing a few utility apps for robotics using Clojure and SWT. Programs that would calculate seeding points, things like that. A thought hit me while I was working on this project: could you write the code for the robot using either Clojure or Scala? (Two new languages created on the JVM that are getting a lot of popularity.)

Not having a lot of experience with the JVM, I don’t know exactly how the packaging process works with Clojure. I know that it can produce an executable jar just like Java can, and I know that there is a build dependency on the clojure libs, but does the executing JVM still require any pre-installed Clojure files? If it didn’t, then how hard would it be to tell Netbeans to add the Clojure libraries to the classpath and dependency list, compile the clojure files, and send that jar to the robot?

The same goes for Scala, which I’ve pretty much only heard of, although most of what I’ve heard are good things. Has anyone experimented with the form of Java on the cRio like this?

I don’t know the implementation details for Clojure and Scala, but often languages that are implemented on top of a Java VM use advanced features like reflection***.

The Java system provided for FRC is a “Java Micro Edition” version of Java (Java ME) that doesn’t support reflection.

*** Reflection is an interesting feature that allows you do things like:

  1. ask “hey object, what fields do you have”
  2. given that info, get or set field values.
  3. similarly discover and call methods on an object

In Java Standard Edition (Java SE) the reflection classes are in the java.lang.reflect package.

As a more definitive no:

  1. As Derek noted JME (Java Micro Edition) is memory constrained and does not support all the features of Java. Scripting languages are a known item that doesn’t work.

  2. As of last year, the cRio wasn’t on the latest version of Java. (I believe it was on 1.4). Scripting language integration with Java didn’t exist in 1.4 (or 5) in even full versions of Java.