On Feb 13, 6:10 am, Robert Fischer <[email protected]>
wrote:
> Why does it have to be Clojure *or* Scala? While Clojure no doubt has
> theoretical purity on its
> side,
Clojure doesn't have any theoretical purity. A theoretician will tell
you that it's an impure functional language in that you can have
arbitrary side effects in any function including mutation and IO.
What Clojure does have is a stronger practical emphasis on
immutability. In Scala you can make things mutable about as easily as
you can in Java. In Clojure you have to jump through an extra hoop or
two. But I wrote a post somewhere once on how easy it would be for an
end user to create a library for mutable variables that would be just
as easy to use as Scheme variables (Scheme being a Lisp where every
variable is mutable whether you want it to be or not).
So from a theoretical standpoint the important difference between the
languages are the static/dynamic typing differences. Everything else
is, AFAIK, what's called "macro expressible" from one language to the
other. That just means that transformations from one language to the
other can all be local. That's quite different from translating
Clojure or Scala to Haskell which might require a global restructuring
because Haskell is pure.
>From a practical stand point they're much further apart. Because you
have to jump through hoops to get mutability in Clojure you probably
think harder about it (which is a good thing!). Also, Clojure comes
out of the box with a very nice syntactic meta-programming facility.
The Lispy syntax makes it easy to use. Such a thing doesn't exist
right now for Scala. It would be possible, and there are plenty of
languages with such facilities (Template Haskell and Nemerle come to
mind), but they're just not as easy to use as "the Lisp way."
> and its lispy hearitage allows it to pull all kinds of
> wild and crazy stunts, including more advanced concurrency stunts and
> allowing you to program in
> whatever paradigm you'd like, as long as that paradigm is expressed in lists
> and parenthesis.
Two points. One, historically Lisps have been terrible at
concurrency. The big Lisps (Common Lisp and Scheme) allow anything to
be mutated by anybody. (This, BTW, is also a real challenge for
popular "dynamic" languages like Groovy, Ruby, and Python which tend
to let you mutate even the structure of classes.) Also the standards
for CL and Scheme don't specify much about concurrency, so concurrency
is bolted on differently by each implementation.
Second, Clojure really can't do more advanced concurrency stunts. All
the concurrency primitives in Clojure can be built (and have been
built in various forms) as Scala libraries and many, like STM, will
likely end up in the standard library soon. Like I say, the
difference here is practical rather than theoretical - it's a little
easier to create fine grained race conditions in Scala than it is in
Clojure, but it's certainly possible to do in Clojure.
> Hell, were I to be a Clojure evangelist, I'd be ecstatic whenever I saw
> people pushing Scala,
> because the shift from Scala -> Clojure is a Hell of a lot smaller than Java
> -> Clojure. Were I to
This is true along many dimensions. Both are functional languages,
both have direct tail recursion support (oddly, Scala's is more
traditionally functional whereas Clojure's has a more imperative
look), neither has full tail call support but both can express it via
trampolining, both have cleaner ways to dispatch on multiple runtime
types than the visitor pattern or instanceof/casts. Also, both were
deeply influenced by SML and Haskell.
> I'd simply view Scala as a gateway language into functional programming, and
> a necessary stepping
> stone to help those poor OO people get a real grasp.
Of course, that would miss Scala's powerful type and module system.
But since you were assuming a Clojure evangelist, presumably those
wouldn't be as important to you as syntactic metaprogramming and built
in support for STM. :-) A Haskell programmer might view both as
gateways to the world of pure functional programming. A Scalar would
laugh at Haskell's module system and a Clojurer would wonder why
syntactic metaprogramming was so much harder.
As you can probably tell, I like all three languages and look forward
to what they bring next. Of the 3, though, my assessment is with you,
Robert: Scala has the best chance of making more "mainstream"
inroads. Haskell really is too pure to swallow for most right now
(which is too bad, because theoretical purity brings real practical
advantages), and I don't see the world becoming any less allergic to
the parentheses of Lisps (which is too bad because if you can get past
them for a little while you learn why they can be a Good Thing).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---