7 ms·
It isn't that Java 8 will kill Scala, it is that Scala has demonstrated the utility of lambdas to the point where they can safely be incorporated back into Java
by justinsb 13y ago
It isn't that Java 8 will kill Scala, it is that Scala has demonstrated the utility of lambdas to the point where they can safely be incorporated back into Java. So Scala has "won", but in my opinion likely Scala will now fade away.
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.
- saryant 13y agoI like to think of lambdas as the hook that shows Java developers how Scala can help their code but its other features are what make them stay. 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)
- justinsb 13y agoAgreed: there's definitely still more features in Scala. But Java has taken "Scala - the good parts"; or at least, what they consider the good parts. That'll be enough for many people, and my guess is it will suck the air out of Scala's room. 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.)
- eranation 13y ago> But Java has taken "Scala - the good parts"; I respectfully disagree. if anything did that, it was Kotlin.
- deleted 13y ago[deleted]
- lomnakkus 13y agoI think it's more that they've taken one good part, but in their defense it's probably one of the best parts :). 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.
- EdwardDiego 13y agoI loathe implicits with the heat of a thousand suns. I mean, I love implicit conversions for easy addition of syntactic sugar, but they should be used very sparingly. 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.
- eklavya 13y agoYou do know implicit conversions are marked by underlines, (both in IDEA and Eclipse) right?
- EdwardDiego 13y agoYes, but when an implicit conversion has been applied to an implicit conversion has been applied to a... ...well, underlining it helps but can't convey all that has gone on.
- eranation 13y agoAs a Scala and Java developer, I am not even slightly tempted to replace Scala as my main language for my next project with Java 8. If I'm forced to write Java, it might better be Java 8, but if I have a choice, there are so many things (as the OP correctly states) that make Scala compelling for me beyond Lambdas that just adding that feature to Java doesn't really mean anything to me. Ruby has Lambdas, so does Python and JavaScript, Dart and I'm sure any other modern language. I like Scala because of so many other things other than lambdas that a single comment is not enough. 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.
- jimmaswell 13y agoI wonder if Java's syntax and use of lambdas will be near how nice it is in C#. They're extremely useful and convenient in c# especially with all the automatic casting around them. Adding to an Event with a simple myEvent += (int x) => {doThing(x);}
- thescrewdriver 13y agoI don't think there's much chance of Scala "fading" away. If anything Java is increasingly being seen as legacy code.
- pron 13y agoI also think Scala has shown Kotlin the way, and Kotlin – in terms of adopting features based on maturity – is half way between Scala and Java, which is a better place to be, IMO, at least for those companies that want to try new things but don't want to mess with the cutting edge, either. 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.
- vorg 13y ago> 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. 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.
- joostdevries 13y agoI just can't imagine going back to Java. The cumbersome object definitions. The endless type declarations. The lack of case classes (algebraic types). The lack of pattern matching. The lack of named arguments. The difficulty in creating immutable objects. Even implicits; they can be overused but in my mind they're just a better way of dealing with contextual information than stateful objects like ThreadLocal.