Will Java 8 Kill Scala?
ahmedsoliman.com
ahmedsoliman.com
Java is necessarily very conservative with adopting language features, because it is very careful to maintain backwards compatibility. Java is a bit like Debian stable - out of date compared to Debian testing or even other distros - but solid as a rock. For features to make it into Java, they really need to be proved first in other languages or in external libraries.
This isn't the first time Odersky has advanced Java either - he worked on Pizza, which showed how to add Generics to Java. Scala demonstrates how to add functional features to Java. Generics were a huge advance, and I think lambdas will be as consequential.
So if Scala does die, it will be as a sacrificial lamb, rather than as a casualty of an unseen war.
As the article says, "type inference, traits, vals, implicits, case classes, value classes, static objects, pattern matching, type variance, macros, immutable datatypes, lazy vals, existential types, higher-kinded types, type classes".
(Pattern matching is amazing, I don't know how I lived without it)
I do consider some of those other features important, and wish we could have them in Java, but they aren't as well-proven yet. (For me, it is easy immutable classes; I like pattern matching but can cope without it.)
I respectfully disagree. if anything did that, it was Kotlin.
Pattern matching and specifically algebraic data types are probably the most important to me since I find algebraic data types to be such an incredibly powerful data modeling tool. I find that almost any problem I encounter in my daily work can easily be modeled using algebraic data structures and from there the code is always some set of "trivial" set of pure pattern matching functions. Unfortunately the full power of pattern matching (compiler-checked exhaustiveness/consistency checks, specifically) can only really be emulated with the visitor pattern in Java -- which is just too much boilerplate syntax to make it useful outside of special cases.
It could just be my indoctrination into Python's more of Explicit Over Implicit, but I hate it when things mysteriously turn into things or get passed as implicit arguments because something was in scope. My most hated form is nested implicit conversions, it kills code readability immediately if you can't figure out what type or object actually got passed in. And I'm using IDEA btw, so about as much tooling on hand to interpret said code as I'm likely to get.
Of course, you don't have to use implicits, but so much idiomatic Scala code (if I can interpret Typesafe's output to indicate idiomatic Scala) uses it, so I guess it's here to stay.
I do love the pattern matching though, especially when it's destructuring.
But to name a few (some were referenced by the OP)
Everything is an expression, For comprehensions (especially with multiple futures, resolving the callback triangle of death in a beautiful syntax IMHO), Implicit conversions, Case classes, Pattern Matching, Tuples, The fact that everything has equals and hashcode already correctly implemented (so I can put a tuple, or even an Array as a key in a map), string interpolation, multiline string, default parameters, named parameters, built in dependency injection, most complex yet most powerful type system in any language I know of, type inference (not as good as Haskell, but better than the non existent in Java). The fact I always get the right type returned from a set of "monadic" actions thanks to infamous things like CanBuildFrom (which are pure genius). Let's not forget pass by name arguments and the ability to construct a DSL. Extractors (via pattern matching). And many more.
I think Scala is here to stay, at least for Scala developers, I am 100% sure you will not find a single Scala developer that will say: "Java 8 got lambdas? great, goodbye scala forever!". Only reason I can think of is compile time and binary compatibility. If we ignore those two, all I can say is that this just proves how Scala is in the right direction (since Java 8 lambdas and default interface methods and steams are so clearly influenced)
I do wish however that Scala will improve Java 8 interoperability, e.g. support functional interfaces the same way. and add new implicit conversions to Java 8 collections as well as take advantage to improvements in the JVM.
I will replace Scala as soon as I find a language that gives me what Scala does and does it better. So far I didn't find such a language (examined Haskell, Clojure, Go, Kotlin, Ceylon, Dart, TypeScript, Rust, Julia, D and Nimrod, Ruby Python, JavaScript and C#, some of them were very promising but since I need a JVM language, and preferably a statically typed one, it narrowed down the choices pretty quickly)
Java 8 is by far not even close, sorry. Great improvement, I'm very happy for Java developers that will get "permission" to use it (might be easier to adopt than Scala in an enterprise) but this is not a reason for a Scala shop to consider moving back to Java.
Otherwise, Java 8 is not a game changer for the simple fact that the enterprise moves at a snail's pace in terms of adoption. Teams with the flexibility to switch from pre-Java 8 to Java 8 will likely also have the freedom to choose an alternate JVM language, or perhaps even Haskell if they're not tied to the JVM.
I don't get it why people fuzz over languages without a context of tools.
Because many rather stay in 1970 era of PDP11 command line and text editors and never experienced with the 1960 ideas implemented in Xerox PARC 1970 languages and 1980 GUI environments.
I'd really much rather get both, I want AST editors in the spirit of paredit.
A plain text editor cannot reproduce the live code experience from such environments.
The only area where I have ongoing issues with my IDE (Scala IDE) is with the play template plugin, can really wreak havoc in both template and controller layers with spurious errors that break mouse-hover type inference click-through-to-type functionality. Even here there's been a ton of improvement, 2 years ago in the template layer there was no semantic highlighting, no indication of _valid_ errors, and stack trace error lines pointed to lines in the generated template, not the .scala.html source file, fun times o_O
Recently switched to XML literals in place of Play's @ templates, not surprisingly the above issue has disappeared, and am now left with a fully functional IDE, code completion, refactoring, and the all the rest, pretty thrilled about the IDE story in Scala to be honest.
> one of the biggest is IntelliJ's capability as Java IDE
That's a pretty shallow reason if you ask me, because the speed of writing code is not the point and IntelliJ IDEA 13 is also very, very good for Scala development.
> I just dislike Scala's monstrosity. I have high hopes for Kotlin
Well, there's your problem. You thought that Scala is something that it isn't, like a "better Java". If you approached it like that, without delving in its FP capabilities that Java 8, Kotlin, Ceylon, Groovy cannot match (or whatever "better Java" is the fad du jour), then of course it was a bad experience.
Next time you'll have some time to burn, start here: http://www.manning.com/bjarnason/
That said, it is improving and closing the gap rapidly.
Becoming professional, and gaining experience has given insight in helping to choose stack in respect to matureness, stability, tool support, documentation etc. It's not that you cannot write Scala code for production and be happy about it. But I rather not. Writing fast is only one part of it. IntelliJ supports the whole aspect of development cycle, and it's good to hear Scala plugin is catching up. Just my opinion.
Interesting choice of languages. Out of that list, only Haskell is suitable for the argument you're trying to make.
Is that SML or Ocaml? If that's SML, well it's a really poor choice. And what makes you think Clojure is better for functional programming? I'm not arguing that it isn't, it's just interesting seeing it in a list of what are supposed to be better choices for FP. Because in my opinion, Clojure is just as dirty as Scala or maybe even more so. And it's also a Lisp and the styles and patterns used tend to be different in Lisps, than what you do in Haskell or Scala.
That book I linked is not about Scala, but about FP and just happens to use Scala as the language. It's a good book. If you preordered it, it would be a waste to not read it.
I'm playing with Haskell as well. Cool language, the ecosystem does suck a little.
(I don't think Scala's a thousand-year language, but I think Kotlin drops too much of what makes it good; I'd look to the likes of Ermine as a potential future replacement. But more to the point, Scala is production-ready today - I know because I use it in production)
Deploying is another matter, full builds lag far behind Java, something that will not be changing anytime soon, scalac is doing a ton of work under the hood.
I actually favor Clojure to Scala as a matter of personal choice, but Java has lots of valid use cases dealing with tooling and compatibility to existing systems.
Personally, I think Scala is a decent research language for testing out language features, but it is not a right fit for adoption in large organizations. Obviously, others will disagree, but that's not the point.
The point is that some organizations and developers want to use cutting edge languages, and the majority are more conservative. Neither of them is "right", and both are necessary. Early adopters show the way by trying new things sometimes successfully and sometimes less so, and without them we'll be stuck in our old ways. But if everyone were an early adopter, the industry would frantically jump from one language to another, re-inventing libraries and not getting much actual work done.
Don't assume because Pizza's purpose was to get generics into Java then Scala's purpose is to get lambdas into Java. Scala's purpose could've been to lead Java developers onto Haskell by providing a stepping stone at the halfway point. And of course purposes can change: Scala's aim may now be just to make as much money as possible for Typesafe's owners. It wouldn't be the first programming language to have been repurposed in that direction.
Surely some people that just want Java with closures will not move to Scala anymore. Some people that moved because they wanted a better Java, may move back to Java, because Scala is actually painful when used as a better Java. But Scala will thrive, as it's a very well designed language that achieves the best combination between OOP and FP available.
In fact Java 8 is good news for Scala, because of the JVM improvements and because Java developers will be more comfortable in consuming libraries built with Scala, like Play and Akka. This is extremely good news, because with the Java ecosystem being so massive, Scala will gain more users than it will lose once people start seeing the possibilities.
I just wonder to which language such soulless corporations with move to.
Edit: Why the downvotes?! I do like Java 8.
Just thinking out loud about those soulless corporations I happen to visit from time to time in consulting gigs.
I mean, take a look at this presentation: http://parleys.com/play/514892250364bc17fc56bb15/chapter0/ab...
And I'm not even ranting about the generics being based on type-erasure, like so many other people are doing. Type-erasure is actually one of the best features of Java, since reification implies doing damage in the runtime which would have impacted other languages and with a good type system, you wouldn't need reification anyway.
Actually, in terms of alternative FP JVM languages, I am more into Clojure than Scala, even though I am a big ML fan.
So I my Scala knowledge is currently at Scala 2.8 level and I wasn't aware of it.
While I love Scala, I'm yet to see a better type system than Haskell's.
Pretty sure I won't be going back to Scala.
I think that Java 8 is such a large improvement that I will use Java more often, and use Clojure less often for back ends.
> So, I don't think Java 8 will Kill Scala by any means.
And he gives valid and compelling reasons why.
"What about type inference, traits, vals, implicits, case classes, value classes, static objects, pattern matching, type variance, macros, immutable datatypes, lazy vals, existential types, higher-kinded types, type classes."
Agreed, Why Java 8 is actually good for Scala (or even Java Folks, Welcome to Planet Lambda!) would have made a better (though less link-baity) title
Lambdas are dead common. They're in practically every language other than Java, and now finally even Java has them. It's good that Java now gets them too, but if that was enough to kill Scala, then Scala wouldn't have been anything special.