Why Java folks should look forward to Scala
blog.dhananjaynene.com
Why Java folks should look forward to Scala
1–10 of 36 posts
Re: Why Java folks should look forward to Scala
#2 def apply() = l map (_())
println (users filter (_.age
The first two uses of () are anonymous functions, the last is a tuple. The only way to tell them apart, best I can tell, is the use of _ turns the scope of the surrounding parens into a lambda.Clojure uses the reader macro #() to indicate an anonymous function.
#(
For me, at least, having a visual clue to distinguish between abbreviated lambda syntax and other kinds of expressions (tuples in the case of Scala) greatly improves code readability.Re: Why Java folks should look forward to Scala
#3My first Scala program rolled off my fingers and worked the first time. My second one ran headlong into a number of difficulties; people pointed out that the newest version of Scala added some things (not in the book I had) that would make things easier and they were right... sorta.
Now I've been doing fit-and-finish work on a mixed Scala-Java system written by people with PhD's in computer science and personally I think they'd have been better off writing the whole thing in Java.
Re: Why Java folks should look forward to Scala
#4I knew I felt some unease with Scala's abbreviated lambda syntax, but couldn't pin down what it was that bothered me. Seeing these examples clarified it: def apply() = l map (_()) println (users filter (_.age The first two uses of () are anonymous functions, the last is a tuple. The only way to tell them apart, best I can tell, is the use of _ turns the scope of the surrounding parens into a lambda. Clojure uses the…
Re: Why Java folks should look forward to Scala
#5Java programmers who are looking for "a better Java" would probably be happier with C# than they would be with Scala, although C# doesn't run on the JVM. The "Manifest" mechanism undoes some but not all of the damage done by type erasure in the JVM, so to some extent building a more richly typed language on the JVM is like driving a car with a broken window. My first Scala program rolled off my fingers and worked the…
It is clearly a better designed language, which of course "borrowed" a lot (90%?) from Java - and then improved it.
Re: Why Java folks should look forward to Scala
#6I knew I felt some unease with Scala's abbreviated lambda syntax, but couldn't pin down what it was that bothered me. Seeing these examples clarified it: def apply() = l map (_()) println (users filter (_.age The first two uses of () are anonymous functions, the last is a tuple. The only way to tell them apart, best I can tell, is the use of _ turns the scope of the surrounding parens into a lambda. Clojure uses the…
Re: Why Java folks should look forward to Scala
#7Java programmers who are looking for "a better Java" would probably be happier with C# than they would be with Scala, although C# doesn't run on the JVM. The "Manifest" mechanism undoes some but not all of the damage done by type erasure in the JVM, so to some extent building a more richly typed language on the JVM is like driving a car with a broken window. My first Scala program rolled off my fingers and worked the…
I can definitely relate to that. I was in a discussion a while ago with 2 friends, and I was "the Java guy". After that chat, I decided to go back to C# and give it a second chance, despite my Microsoft allergy ;) It is clearly a better designed language, which of course "borrowed" a lot (90%?) from Java - and then improved it.
I was at a conference back in 1997 where we came up with a wish list of features we'd like in Java for high performance computing. We all knew it was useless to ask this from Sun, but we did anyway.
The first version of C# had everything we asked for in it, and even early versions of C# had a 'delegate' mechanism that was, more or less, method pointers.
C# 3.0 introduced support for functional programming; it's certainly not like CaML, but there's a reasonably fluent syntax for real closures -- with a little work in adding syntactic sugar it's not bad.
LINQ is amazing and people have barely scratched the surface of what's possible like it. There's a system for manipulating "Expression Trees" that lets you do LISP-style metaprogramming.
C# 4.0 added covariant and contravariant inheritance for generics and, unlike JVM-based languages, it works the way it is supposed to without any lame workarounds.
Comparing C# to Java as a ~language~ is like comparing modern italian to ancient latin. Changes happen in Java at a glacial rate after a tortuous process that ensures that when JDK 7 hits the streets it's going to be four years obsolete.
That said, the Java platform has an incredible ecosystem around it; using maven gives me the feeling I'm in Manhattan and can plug into an infinite library of amazing stuff.
The .NET ecosystem, on the other hand, feels like being a crossroads town in the middle of Iowa. Occasionally you get something good like NUnit, but open source offerings are anemic or absent, and commercial libraries often come across like ads in the SkyMall catalog. (Often you can implement the 5% of the library you need yourself in the time you'd spent talking to salespeople)
Re: Why Java folks should look forward to Scala
#8The Scala syntax, I must say is not as readable: def apply() = l map (_())