
Scala: The Static Language that Feels Dynamic (Bruce Eckel) - peod
http://www.artima.com/weblogs/viewpost.jsp?thread=328540
======
zmmmmm
Scala definitely needs more people like Bruce Eckel to start explaining it. I
understood several concepts from this article that have eluded me so far
because every other article I found descended in to abstract concepts of
language or type theory without explaining what the practical uses of things
were.

Unfortunately I think it may have missed it's peak opportunity to catch on
because of this kind of problem - and a chronically buggy and unstable Eclipse
plugin - but we'll see.

------
MrMan
This post may garner some down-vote for being non-rigorous, but I will offer
my opinion on Scala so far. I accept it's good points readily enough when they
are presented in list form, but when I read the language and try to reason in
it, I just don't like it. Scala just doesn't feel like where I want to go. I
do not want to embrace endless complexity in the form of hard-coded language
features layered onto the language. XML literals instead of macros???? Please,
I say. I have decided that Clojure will take the place in my dev life that
Java and C# have occupied for the last 12 years. I hope that is the right
decision.

~~~
thomaslangston
I only have one complaint about Clojure. It is very unfortunately named.
Closures, the programming construct, and Clojure are too similar sounding.

If I could rename Clojure and GIMP I'd do so in a heartbeat.

~~~
cletus
I actually like that both Clojure and Scala have names that otherwise don't
mean something else. This unambiguity means you can more easily search for
related pages and get more meaningful data out of Google Trends. Java will
bring up some coffee references and the island in Indonesia. Python is, well,
obvious. Just as two examples.

I'd much rather everything not also be something else.

GIMP is actually appropriate because AFAIC the program is completely crippled.

~~~
a_strange_guy
Scala is actually a really bad name for trying to google it.
<http://en.wikipedia.org/wiki/Scala>

------
kenjackson
Maybe I missed something, but there is nothing in there that gives me the feel
of a dynamically typed language. What he describes feels more like Haskell
than Python.

~~~
andrewflnr
Perhaps by "feels like a dynamic language" he means "is succinct".

~~~
contextfree
Reminds me of this classic comment by Frank Atanassow on Lambda the Ultimate:
<http://lambda-the-ultimate.org/node/1562#comment-18623>

> "Dynamic" is technical jargon used by programmers, meaning "good". It
> derives from the Latin dyno mite, meaning "I am extremely pleased", and is
> first recorded in the historical work Bona Aetas of noted Roman sage and
> pundit J.J. Walker. Its meaning evolved in the 4th century after monks
> copying an obscure manuscript on programming linguistics in their ignorance
> tried to deduce its meaning from context. [...]

(the comment continues at the link; read the whole thing, it's pretty funny
whether or not you agree with the sentiment)

~~~
andrewflnr
Thank you sir. That is hilarious.

------
spullara
The biggest thing that is still in the language that they should have removed
early on is the native XML syntax support. If I were them I would take it out
in 3.0 and break from that bad decision.

~~~
jorgeortiz85
See my answer on Quora to "Will Scala ever remove XML literals?"
<http://www.quora.com/Will-Scala-ever-remove-XML-literals>

Summary: No. At the time that Scala was started, built-in support for XML
showcased one area were object-oriented decomposition failed and functional
programming proved quite useful. Today the benefits of FP are more well known,
and it's generally agreed that if Scala were starting from scratch it would
not include XML literals. However, given that XML literals are in the language
already, that large code bases have come to rely on them, and that they
generally don't get in the way if you don't use them, it's unlikely that they
will be removed.

~~~
_sh
Solution: move it to a library, like perl did with it's format syntax, and
take it out of core.

~~~
jorgeortiz85
This is hard because Scala's XML support affects the parser. At the lexical
level. Scala does have compiler plugins, but it doesn't have parser plugins.

~~~
corruptmemory
Agreed.

Macros and reader macros ;-)

~~~
jorgeortiz85
Let me know when you figure out how to statically type check those. You could
publish a paper or two, I'm sure.

~~~
corruptmemory
Nemerle already does it: <http://nemerle.org/macros.html>, so does Template
Haskell: <http://www.haskell.org/haskellwiki/Template_Haskell>

------
srean
I believe JVM now supports some restricted form of class re-definition at run
time in debug mode. But it is quite limited. This is probably old hat for JVM
hackers, I do not keep myself updated on the Java/JVM side of things.

I came across Sun's (now Oracle's?) open-source(GPL) fork of the JVM that
allows for changing class internals on the fly. The following analogy comes to
mind DCE VM : JVM :: DLR : CLR

I quote:

    
    
      The class data structures of the Java HotSpot virtual
      machine are immutable during the execution of a program.
      While new classes can be loaded, it is not possible to
      change existing classes (e.g. add/remove methods or
      fields). This projects tries to relax this condition to
      allow arbitrary changes to existing Java classes
      (including changes to the class hierarchy) while running
      a Java program.
    

This looks interesting <http://ssw.jku.at/dcevm/> and wonder if runtimes of
dynamic languages could make use of this.

~~~
contextfree
I'm not familiar with the DCE VM, but DLR is a library on top of the CLR, not
a different version of the CLR.

~~~
bad_user
It is a library on top of the CLR, but it cannot function without CLR-specific
capabilities.

For example DynamicMethod, which represents a method reference that can be
created at runtime and garbage-collected when no longer in use; similar to the
lightweight method handlers in JSR 292.

That said, modifying existing classes on top of the CLR is not possible,
unless it inherits from something like ExpandoObject, but you can pull the
same trick in Java (though not as easily until JSR 292 comes out).

------
rvasa
one of the better written articles out there for some one new to the language.
Also like the fact that some of the funamentals of functional programming are
also briefly introduced in context.

------
vorg
> I find it one of the most promising things about Scala -- it is not
> determined to become an instant boat anchor by committing to early decisions
> that are later revealed to be suboptimal, or outright mistakes.

The fact that Scala uses the JVM, with a hacky workaround for type erasure, is
suboptimal.

~~~
gaius
The Scala team have plans afoot to target LLVM and .NET too.

~~~
stonemetal
Do they have actual plans though? There has been talk of .NET support since
the beginning. Basically I wouldn't hold my breath.

~~~
illicium
Scala already compiles to the CLR, but support for it is nowhere near that for
the JVM.

~~~
ppog
Last time I looked (early 2009), Scala compilation to the CLR was a bit of a
joke. It targeted version 1.1 of the CLR, which had been superseded nearly 4
years earlier. I think the problem was with the predefined libraries.
Supposedly you could get it to work with v2 but I never did.

They also did themselves no favours by having the Scala compiler dump out MSIL
assembler code rather than a .NET assembly. You had to separately run the
ilasm tool to get an executable. Obviously for a production environment you'd
package this up in a build file, but for experimenting with the language it
was a bit of a speed bump.

This is without even looking at the language features and libraries that were
supported on the JVM but not on the CLR (e.g. structural types, parser
combinators).

My experience may be out of date here, but the scala-lang page on .NET support
is still datestamped July 2008, so I'm not too optimistic. A great pity, as
Scala always seemed a great fit for the CLR and would provide some nice
competition to C# and F#.

~~~
contextfree
This looks pretty active: <http://lamp.epfl.ch/~magarcia/ScalaNET/>

I'm not sure what relation his work has to the core Scala project or team,
though.

------
carsongross
Gosu has the same dynamic feel in a statically typed JVM language, with much
less complexity. (I should mention Fantom too, although I'm much less familiar
with it.)

Artima appears to have gone all-scala-all-the-time at some point in 2010.
Weird.

~~~
cageface
Scala looks complex on paper, but my experience has been that in practice it's
not that bad. If you're designing a library you need to think hard about types
but you can put together an app very quickly in Scala and with a lot fewer
initial bugs than in a dynamically typed language.

~~~
jshen
I wonder if there is value in making it easy to make library? I feel like the
ruby eco system gains a lot for the rate at which people can try out ideas for
libraries.

~~~
cageface
Scala forces you to consider your library interface more carefully. This makes
it more work to build a library but I think it pays off in a cleaner, more
consistent and self-documenting library. Scala makes you think a little harder
in general but, in my experience, you also write better code.

All that painful refactoring and modularization that went into Rails 3 would
have been a lot easier and, I suspect, less necessary if Rails had been
written in Scala.

~~~
jshen
I think of it more in terms of natural selection. If, and this is a big if,
diversity is greater in language x than in language y due to ease of trying
ideas, then there is more opportunity to hit on good ideas.

~~~
cageface
The barrier to entry in Scala is definitely higher, and I do think this has
limited its growth. To be honest, I don't think Scala is going to be the FP
lang that really goes big, although I wish it were.

I just hope Scala gets enough traction that I can find real work in the
language. After using it for a while languages like Ruby and Python just feel
primitive.

~~~
jshen
I hope any of them get enough traction that I don't have to fight to code in
something other than java :)

------
eegilbert
Somehow I missed parallel collections in 2.9. I'm in love.

------
Egregore
So we'll be waiting for "Thinking in Scala" book...

