84 points · by wpietri · 12y ago · 32 comments
New features in the 2.11 series
This release contains all of the bug fixes and improvements made in the 2.10 series, as well as:
Collections
Immutable HashMaps and HashSets perform faster filters, unions, and the like, with improved structural sharing (lower memory usage or churn).
Mutable LongMap and AnyRefMap have been added to provide improved performance when keys are Long or AnyRef (performance enhancement of up to 4x or 2x respectively). BigDecimal is more explicit about rounding and numeric representations, and better handles very large values without exhausting memory (by avoiding unnecessary conversions to BigInt).
List has improved performance on map, flatMap, and collect.
See also Deprecation above: we have slated many classes and methods to become final, to clarify which classes are not meant to be subclassed and to facilitate future maintenance and performance improvements.
Modularization
The core Scala standard library jar has shed 20% of its bytecode. The modules for xml, parsing, swing as well as the (unsupported) continuations plugin and library are available individually or via scala-library-all. Note that this artifact has weaker binary compatibility guarantees than scala-library – as explained above.
The compiler has been modularized internally, to separate the presentation compiler, scaladoc and the REPL. We hope this will make it easier to contribute. In this release, all of these modules are still packaged in scala-compiler.jar. We plan to ship them in separate JARs in 2.12.x.
Reflection, macros and quasiquotes
Please see this detailed changelog that lists all significant changes and provides advice on forward and backward compatibility.
See also this summary of the experimental side of the 2.11 development cycle. #3321 introduced Sprinter, a new AST pretty-printing library! Very useful for tools that deal with source code.
Back-end
The GenBCode back-end (experimental in 2.11). See @magarciaepfl’s extensive documentation.
A new experimental way of compiling closures, implemented by @JamesIry. With -Ydelambdafy:method anonymous functions are compiled faster, with a smaller bytecode footprint. This works by keeping the function body as a private (static, if no this reference is needed) method of the enclosing class, and at the last moment during compilation emitting a small anonymous class that extends FunctionN and delegates to it. This sets the scene for a smooth migration to Java 8-style lambdas (not yet implemented).
Branch elimination through constant analysis #2214
Compiler Performance
Incremental compilation has been improved significantly. To try it out, upgrade to sbt 0.13.2-M2 and add incOptions := incOptions.value.withNameHashing(true) to your build! Other build tools are also supported. More info at this sbt issue – that’s where most of the work happened. More features are planned, e.g. class-based tracking.
We’ve been optimizing the batch compiler’s performance as well, and will continue to work on this during the 2.11.x cycle.
Improve performance of reflection SI-6638
IDE * Numerous bug fixes and improvements!
REPL
The bytecode decompiler command, :javap, now works with Java 7 SI-4936 and has sprouted new options SI-6894 (Thanks, @som-snytt!)
Added command :kind to help to tell ground types from type constructors. #2340 (Thanks, George Leontiev and Eugene Yokota!)
The interpreter can now be embedded as a JSR-166 Scripting Engine SI-874. (Thanks, Raphael Jolly!)
Warnings * Warn about unused private / local terms and types, and unused imports, under -Xlint. This will even tell you when a local var could be a val.
Slimming down the compiler
The experimental .NET backend has been removed from the compiler.
Scala 2.10 shipped with new implementations of the Pattern Matcher and the Bytecode Emitter. We have removed the old implementations.
Search and destroy mission for ~5000 chunks of dead code. #1648
I beg to differ with this. Any languages gets easy to read & write once you master it. After having finished the Scala course and spending considerable time trying to get grips with the language, I was still totally clueless about a majority of the features.
Although I really liked how powerful Scala it is even if you grok 30% of its features but the learning curve required to master it is extremely steep. Prof Odersky has been quite vocal about the feature bloat and lets hope the future releases are more conservative in that sense.
Scala is the language that helps you write better code. In the kinds of projects that I've been working for the last 3 years, requiring parallelism, efficient usage of resources, asynchronicity, redundancy, scalability, throughput, reliability on the whole, I can honestly say that none of the other languages could do a better job.
On features, it actually doesn't have many, but the features that it does have are powerful enough that you can have bigger abstractions. For example, "async" is not a language feature such as in C#, but a library. Of course, there's much to learn, especially concepts that have been borrowed from Haskell or other FP languages with a Scala-ish twist, like persistent data-structures, type-classes, futures/promises, iteratees and in general, what's the deal with monads, monoids and applicative functors. In training beginners explaining these concepts was the most difficult part of the training, trumping all others considerations, starting from the basics like "don't use vars".
Scala is difficult because it's a functional programming language, beautifully blended with OOP, being in fact a better OOP language than most mainstream OOP languages. Learning FP and then learning OOP in a way not exposed by languages like Java and then learning what good design looks like, grokking a lot of FP design patterns in the process, that can be very overwhelming. For any developer that is not familiar with a good FP language already, or that thinks OOP is what Java gives you, the transition can be pretty painful. On the other hand - I'm of the opinion that if learning a new language is not painful, then it doesn't give you anything of value, so learning it is pretty useless.
With Scala I felt like the level of understanding/mastery required to truly feel at home was significantly higher than I've encountered before. Looking into some of the code in the wild gave me instant headaches. Developing in a language where you can be presented with code and draw a complete blank is not a reassuring experience.
It's still a beast id like to tame, but not when I have work to get done anytime soon.
How long did it take you to go from zero to being able to get stuff done, when you started to learn programming?
Complaining that Scala is unlike C# or Ruby doesn't make sense, since if you want C# or Ruby, might as well stick with C# or Ruby. And what came first anyway? Guess you started out with C#, since it's more popular in universities, right? Well, when you got into Ruby, where you able to understand all the meta-programming going on in like all the popular libraries?
Speaking of which, after working a lot with Ruby, I still have problems in grokking other people's code when meta-programming is involved, since it's almost always a fragile design that's stitched together with spit and glue and I can never wrap my head around all the things that could happen in the right context. This is very, very unlike my experience with Scala. Yes, it's difficult to learn because many new concepts are involved, but once passed that learning curve, everything becomes much clearer instead of going down a rabbit whole.
Languages never get simpler as they age, and Scala is certainly proof of that rule.
If anything, advanced features that make up for good academic papers have priority over fixing bugs and streamlining the libraries.
Paul Phillips, a Typesafe cofounder, recently left the company and went on a tour explaining why he thought Scala was headed in the wrong direction:
Paul Philips is an awesome developer, contributed a lot to Scala and he did quit because he thought that Scala was headed in the wrong direction. These are the facts. On the other hand the kind of problems he described are problems that happen in every mainstream language, either due to the pressure of keeping it stable and of backwards compatibility (you know, real world concerns) or because current languages aren't equipped to handle it or because of pragmatic reasons with which he doesn't agree with. And in fact, speaking of "academic papers", some of the problems he cares about can only be fixed for real in languages with dependent types (ever heard of one?).
As for "fixing bugs and streamlining the libraries", if you bothered reading the release notes on Scala 2.11-RC1 before commenting, you would know that this release is exactly about fixing bugs, modularizing the compiler, improved compilation times, streamlining the libraries, eliminating deprecated stuff and so on. By all accounts, it will be an awesome release even though it doesn't add features to the language. It won't solve all of Paul's concerns of course, but there are people that actually care and work on these problems.
But then, whenever that happens, people start complaining that Scala breaks backwards compatibility too often. Apparently you can't please everybody. And btw, the Scala core devs also have plans for breaking source compatibility by implementing a Go-like source-code migrator to get rid of deprecated syntax sometimes in the future.
Most importantly - at the end of that talk, Paul Philips still claims that Scala is his favorite language. But then again, you weren't really interested in what he actually had to say, did you?
> Any languages gets easy to read & write once you master it
Perl :(
I've been coding mostly in Scala for a couple of years now and am still learning new things. The more I learn the more I realise how powerful the features are.
Compilation speed is also drastically improved by using the type system. If you give your code well defined internal interfaces, there will be very little recompilation needed by SBT's incremental compiler. Your code will be cleaner too.
http://www.chrisstucchio.com/blog/2014/bondage_and_disciplin...
- def foo(x: X) = new G2
+ def foo(x: X) = new G3
Now all users of `foo` need to be recompiled even if all the downstream classes only want a G (for some G an ancestor of G2 and G3).