Wednesday, August 26, 2009

Introducing Surinx

In June of this year, I spent a few hours formulating a dynamic cousin to Duby. Duby, if you don't remember, is a static-typed language with Ruby's syntax and Java's type system. Duby supports all Ruby's literals, uses local type inference (only argument types *must* be declared), and runs as fast as Java (because it produces nearly identical bytecode). But with the advent of invokedynamic, Duby needed a playmate.


Enter "Juby". Juby is intended to be basically like Duby, in that it uses Java's types and Ruby's syntax. But it takes advantage of the new invokedynamic opcode to be 100% dynamic. Juby is a dynamic Duby, or perhaps a dynamic Java with Ruby syntax. It's not hard to comprehend.

But the name was a problem. Juby sounds like "Jewbie", a pejorative term for a Jewish person. So I sent out a call for names to the Twitterverse, ultimately ending up with far more names than I could choose from.

The name I have chosen, Surinx, has a simple story attached. You see, when James Gosling created Java, he originally named it "Oak", after the tree outside his window. So I followed his lead; the tree (a bush, really) outside my window is a lilac, Syringa vulgaris. The genus "Syringa" is derived from New Latin, based on a Greek word "surinx" meaning "shepherd's pipe" from the use of the Syringa plant's hollow stems to make pipes. Perhaps Surinx is building on the "hollow stem" of the JVM to produce something you can smoke (other dynamic languages) with. Combined with its cousin "Duby", we have quite a pair.

And in other news, the simple Surinx implementation of "fib" below (identical to Ruby) manages to run fib(40) in only 7 seconds on current MLVM (OpenJDK7 + invokedynamic and other tidbits), a five-fold improvement over JRuby's fastest mode (jruby --fast).

def fib(a)
if a < 2
a
else
fib(a - 1) + fib(a - 2)
end
end

Given that JRuby has started to support invokedynamic, the solid performance of Surinx bodes very well for JRuby's future.

Please welcome Surinx to your language repertoire!

18 comments:

Dag Fjeld Edvardsen said...

Extremely cool! :)

Kerry Buckley said...

>The genus "Syringa" is derived from New Latin, based on a Greek word "surinx" meaning "shepherd's pipe"

I initially read that as "shepherd's pie". Which would have just been weird.

Kenneth said...

Why not just use python? :P

Nimrod said...

How does Surinx + invokedynamic compare with Duby, performance-wise?

I.e., do you still see significant performance degradation due to dynamic typing when using the new JDK7?

Anonymous said...

using a language named Duby (Doobie) would be my pleasure.

Charles Oliver Nutter said...

Nimrod: At the moment, using fully-boxed math, Surinx is only about 1.75x slower than Java or Duby also doing fully-boxed math. It's certainly going to be a lot slower than Java or Duby doing primitive math, but I think I can narrow that gap as well.

Boris said...

Already creating discussion on StackOverflow:

http://stackoverflow.com/questions/1337137/whats-the-difference-between-duby-and-juby-and-why-would-i-need-either-of-them

Anonymous said...

How useful is duby now? Would you reccomend it instead of groovy or jruby?

markrendle said...

Are Surinx or Duby possible contenders for Android development? As in, would it be possible for the Android bytecode translator to work with compiled Surinx/Duby jars?

Charles Oliver Nutter said...

Boris: Thanks! I'll take a look.

Anonymous: Both Duby and Surinx are still in development, but since they're both written in Ruby it would be easy to help out. I could see both of them as real contenders once they're more complete.

markrendle: Duby could be used for Android development very easily, since it outputs normal JVM bytecode. Surinx also outputs normal bytecode, but it only supports JVMs with invokedynamic. If Android eventually supports invokedynamic, it will work too :)

markrendle said...

Charles: Excellent. I shall investigate Duby and hope that Google update Dalvik to work with JDK7.

Gary S. Weaver said...

@markrendle - not an expert on 7, but appears that the Java 7 milestones would indicate it might be Spring 2010 before a release candidate and Summer 2010 before a final version of Java 7 is available (assuming that it takes a few months for the first RC to come out after the last milestone release). I'm guessing that Google wouldn't make it available before Summer 2010 (assuming they stay on schedule)? Sounds exciting though!

Noel said...

On the subject of names, "Duby" is more or less how you would pronounce the plural of "oak" in Russian (s. "дуб", pl. "дубы"). For whatever that's worth.

Charles Oliver Nutter said...

Noel: Oh, that's just perfect :) Thank you for the information!

Jeff Miller said...

I'm fairly sure that the shepherd's pipes were meant for playing music on. But the metaphor would still work -- Surinx as the hollow reed upon which many tunes can be played.

Roger Pack said...

I assume the object passed into "fib" in your example is a java integer?
r

Mark Essel said...

Charles, any update on Surinx and possible integration into JRuby implementation? I'm curious of how JRuby or Surinx performance is on some simple benchmarks (alioth's shootout).

Charles Oliver Nutter said...

Mark Essel: The functionality of Surinx has been folded into Duby, which now supports a "dynamic" type for doing dynamic dispatch. I haven't tested its performance yet, since for numerics you still would need to (dynamically) treat all numbers as though they are Integer or Long or Float or Double instances. If we added some runtime support for dynamically invoking non-existent methods like #+ or #-, then it would look basically like Surinx.