Field

Primitive Scala Support

In keeping with Field's goal of being a truly experimental platform for writing code, it's always been a given that we're interested in programing languages as a first-class concern (you can see this in our Python-based wriggling around). This is part of what drove us to make the block transforms elements in the text editor in the first place. These elements allow you to make "local languages" because when they are executed they are actually passed off to a (Python) function of your choosing. It's simple to then pass the code to a network socket (for example for Maya integration) or to AppleScript to poke and prod applications across the operating system.

Recently we've been hacking away on supporting a different programming language altogether: Scala. Like Field's use of Jython, Scala is a programming language that's built on-top of the Java VM and that is integrated into it. But there the similarities end: Scala is really an altogether different kind of language from Python. Strongly typed but with type inference and a very interesting type system, and with a real sense of it's functional programming influence, Scala wants to be a better Java than Java.

This contrast with Python arguably makes it a more interesting thing to include in Field than, say, some other JVM scripting language that's compatible with JSR-223. It also makes it much harder — the Scala community simply isn't that interested in "scripting" per-se.

So, we get to the punchline: the initial Scala support inside Field (using the ScalaPlugin, of course) lets you do this:

The code really sums it all up (I've left the preamble that defines the "scala" block transformation in there so that you can see that it's really nothing, I'll wrap that up and put it in a separately included .py file soon). ScalaPlugin is careful to share the namespace between the Scala world and the Python world, so you can define things (things = vars, objects and classes) in Scala and manipulate them freely in Python.

Much work remains to be done: certainly the idea of the Block Transform finally has to be extended to include a syntax highlighter, certainly there needs to be better error reporting, and all of the EmbeddedUI shims need to be updated to know what language they are actually in. It would be nice to be able to write banana("something") rather than banana.apply("something") and so on. But we're off to an interesting, and above all hybrid, start.