On Jun 9, 2:10 pm, czerwonka <andy.czerwo...@gmail.com
> On Jun 9, 7:14 am, Rich Hickey <richhic...@gmail.com
> wrote:> On Jun 8, 1:28 pm, czerwonka <andy.czerwo...@gmail.com
> > I think Scala is interesting work, and I haven't spent much time with
> > it, so I'll just speak for Clojure, other than to say I've seen enough
> > to know that Clojure is substantially less complex than Scala.
> [czerwonka] I what way? Syntax? I definitely see the argument given
> Scala's implicit defs (witchcraft). Does this complexity cost come as
> a result of type safety? I think so in some cases.
Complexity comes as the result of the type system, object system etc.
Clojure has a very tiny core.
> > Clojure is predicated on my personal opinion, after many years of
> > doing it, that imperative programming is not a very good idea in most
> > situations.
> [czerwonka] I guess this is where I sit on the fence. Scala's default
> is to promote immutable data structures. It promotes 'val' over
> 'var'. It gives you a choice though, I think because unless one wraps/
> replaces all the Java libraries with their functional equivalent, you
> end up using imperative whether you like it or not. I guess that's
> really my argument. Interop forces you there. Doesn't it?
Not really. A lot of use of Java is on the I/O side of an application.
The logic and model can avoid Java, or use parts of it functionally.
If you build an immutable object out of Java/Scala final/val fields
you don't end up with a persistent data structure, so you don't have a
mechanism for change other than full copy. If you use Scala's
immutable collections, but then store them in Scala's unmoderated
'vars' as recommended to support change, then you don't have a
mechanism for change coordination other than locks.
Contrast with the Clojure approach of using Clojure maps as 'objects'
- they are immutable and efficiently persistent - and storing them in
one of Clojure's 3 reference types, all of which have concurrency
Giving people advice is different from giving people a complete
method, and using it uniformly in the libraries.
> > However, Clojure acknowledges the need for the illusion of change in
> > most real programs that are not merely calculations. That is, multiple
> > parts of a program may want to associate an identity with state that,
> > at different times in the program, may be different.
> [czerwonka] Scala has its Actor library which closely resembles
I question whether Erlang's actors-waiting-for-a-data-message-in-a-
blocking-switch-statement model is the right thing to emulate. Here
too, Clojure's holistic design comes into play, as both its
transactional refs and autonomous asynchronous agents support the same
change-as-function-of-state model, with both the altering function and
the state being the exact same functions and persistent data
structures you use everywhere else.
Contrast with the difference between interacting with Scala Classes/
Objects and Scala Actors. Everything that was a method in the first
case becomes a message data type in the second - very different.
> You're right though, given it's a library, it allows you to
> use shared state. I nevertheless do find it extremely powerful to be
> able to express a this DSL using a typed language.
I have no doubt Scala's flexibility will allow people to accomplish
almost anything. But when everyone can do almost anything, they do,
and then their pieces don't compose. If everyone using Scala takes a
different approach to mutability and concurrency, you won't be able to
compose reliable concurrent programs. I find it highly unlikely that
Scala programmers will eschew vars in their objects, in which case
they are no better off than in Java, which offers final fields just
like Scala's vals. That's not really functional programming and is not
going to yield its benefits.
If people do want to get the benefits of functional programming and
safe concurrency in Scala they will have to voluntarily adopt, and
enforce by convention, the same sort of 'restrictions' Clojure
holistically supports and enforces.
If they want those benefits in Clojure, they just use it.