Brian's Waste of Time

Fri, 21 Dec 2007

Loving Scala: Scripting

So, I generally have two classes of scripting needs: systemy/unixy stuff and systemy/application stuff. Most of the applications I work with in $dayjob are Java. Over the last year or two that means I use Ruby (MRI or JRuby) as the case may be. Tonight, prodded by the new book I broke out Scala for doing a bunch of in-REPL statistics crunching using the wonderful commons-math library.

I love it. Don't know if I love it enough to replace JRuby for typical Java-interaction hackery, but enough that I am going to switch back and forth for a while so I can decide.

Hadn't actually used scala in a few years, so is great to break it out again!

writebacks...

Doug

Scala scripting?
Brian, I'm bewildered how you can consider Scala to be a scripting language. It strikes me as being just about everything that a scripting language is NOT. o Scripting languages are optimized for quick coding of small tasks; Scala is "aimed at the construction of components and component systems". o Scripting languages are interpreted; Scala is compiled. o Scripting languages are dynamically typed; Scala has the most complex strong static typing system that I've ever seen. o Scripting languages provide simple syntax for commonly used operations like regular expression matching; Scala doesn't even provide a basic "for loop". Scala is an interesting language, but a scripting language it's not.

Brian McCallister

Scripting
So it doesn't fit into the classic definition of a scripting language, but it actually works pretty well in that role. You can #! it (mostly), use the REPL to incrementally build somethign up. The syntax is concise, and with type inferencing you can pretty much not worry (unless you hit an edge case) about a lot of the verbiage.

Doug

REPL and Scripting
I take your point on the value of Scala's REPL, but I'm far from convinced that a compiled language with an incredibly complex static type system suddenly becomes "a scripting language" if it also happens to have a REPL. I suspect that's just a question of terminology and that we'll simply have to agree to disagree on it. :-)

Doug

#! in Scala
How are you getting "#!" in Scala? I've only used the basic "scalac" and "scala" commands, so I've probably overlooked something useful. (And why can't I put paragraphs into my comments?)

Brian McCallister


"scripting needs" -- I don't really want to argue semantics of what "scripting language" means :-)

Brian McCallister


#!/usr/bin/env scala
!#
println("Hello, world!")

comment...

 
Name:
URL/Email: [http://... or mailto:you@wherever] (optional)
Title: (optional)
Spam Guard, translate l33t to English: (hint, it's an Australian animal, plural form)
Comments:
Save my Name and URL/Email for next time