PDA

View Full Version : Clojure and Scala


Walker
01-07-2011, 12:51 AM
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?

derekwhite
01-08-2011, 01:11 AM
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:

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


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

Jeanne Boyarsky
01-08-2011, 08:18 PM
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.