Friday, August 17, 2007

Scala: The Next Next Java!

Yeah, yeah. I know. It's only been recently that Erlang has started being touted as "the next Java". I just thought I'd get a jump on crowning the next next Java. Oh, sure, no one gets to officially be The Next Anything without a Pragmatic Bookshelf book backing it, but I'm sure it's just a matter of time before a Scala book is announced.

After all, Scala shares a lot of the advantages of Erlang -- principally, its support for Actor-based concurrent programming and hence its powers of super-scaling. But it also has a secret weapon that Erlang doesn't have: it runs on the JVM! Yes, that JVM! It also has access to the multitudinous multitudes of existing Java libraries out there, making for a (potentially) easier migration path.

No need to wait for Java 7 (or (possibly much (much)) greater) for closures in Java! Write some Scala scaffolding around your existing Java classes and have them today!

Le roi mort! Vive le roi!

10 comments:

Michael Nischt said...

IMHO Scala is too complicated (to learn and read), Erland excels here even compared to java. Further the Erlang"s main advantage is that there is NO shared memory!

However, I agree to a certain point: instead adding that complexity*, people should Scala. Actually, I would do it for some stuff, if there would be a nice netbeans plug-in...

* Java Programming Language: Design Principles and Proposals

David Rupp said...

Yeah, I'm not entirely sold on Scala's syntax, although the ability to leave out type names the compiler can infer is a good incentive for me to get used to it. That and the ability to use first-class/higher-order functions are the specific language features that made me start paying attention.

The fact that it runs on the JVM and can use existing Java libraries is huge, though. Until someone ports Rails to Scala (only a matter of time, I feel certain), those are the killer apps.

Jim said...

It may not be Rails, exactly, but lift looks like a pretty exciting web framework.

Qrilka said...

As far as I remember Bill Venners (from artima.com) is writing a book about Scala.
But regarding Scala vs. Erlang apart from Scala's complexity Actors are made almost like Erlang concurrency model but behave not so well across JVMs. To implement something close to Erlang in terms of scalability adn fault-tolerance you'll need the primitives implemented in VM like in Erlang BEAM Simulator. Also you'll need epmd functionality (tying Erlang nodes together) implemented. And OTP library is also missing.

David Rupp said...

@jim: Good call. I'm using the liftweb source code to help get me used to reading Scala and its idioms.

@qrilka: Interesting points. Can you elaborate on how Scala Actors don't deal well across JVMs? I thought the point of Actors was that, being about non-shared state, location wouldn't matter at all. Also, you clearly know a lot more about Erlang than I do. I'll have to catch up on the Erlang VM primitives you're referring to. Thanks for the thoughtful (and thought-provoking) comment.

Henry Ware said...

Scala is a better Java than Java. And while it is not as good an Eralng as Erlang, its not that bad either.

Also, Erlang is dynamically typed. Been there, done that, now please give me static typing with type inference.

Steve Jenson said...

Make sure to read Scala By Example, it's chock full of wonderful things.

David Rupp said...

@henry ware: "better Java than Java" -- hear, hear! That's definitely the impression I'm getting.

@steve jenson: Good call on "Scala By Example". In fact, all of the papers available on scala-lang.org strike me as being of very high quality, both in terms of their scholarship and their usefulness for learning. Good stuff.

Jon Harrop said...

If Sun added support for functional programming languages to the JVM (as Microsoft have done to IL), most notably tail calls, and anyone implemented an ML for the JVM then I would start programming in it today.

I have been using OCaml and F# professionally for several years and the product gain from functional languages is nothing short of obscene.

Anirudh Vyas said...

isnt erlang, dynamically typed?