Also regarding "why the JVM in general," it's worth remembering that the JVM has excellent garbage collection, and the just-in-time compiler (JIT) can make repetitive code run almost as fast as native C++ code. Then there's the concurrency aspect, which is broken in both Python and Ruby (GIL). There are other JVM languages of course, but Scala is both more intuitive and more flexible than, say, Clojure. When one writes big applications or uses new APIs, having a statically typed language not only allows you to have the IDE help you, it also catches many bugs before runtime. Given type inference, it's less painful to have type safety than in Java, but in Clojure, Python and Ruby you don't have type safety at all (well you do in Cython, but that's a different story). Of course the JVM has warts, such as no unsigned numeric types, boxed numeric types for generics, painful interaction with native code if you need to reuse existing native libraries (JNI, JNA). Nothing is perfect I guess. However, Java's scalability, efficiency, concurrency and portability did show that the JVM is a great compromise - and it's not surprising that other languages that were traditionally not on the JVM now are (Jython, JRuby, etc.).
Marek On Thu, May 29, 2014 at 5:10 PM, Marek Kolodziej <mkolod....@gmail.com> wrote: > I would disagree that Scala is controversial. It's less controversial than > Java was when it came out in 1995. Scala's been around since 2004, and over > the past couple of years, it saw major adoption at LinkedIn, Twitter, > FourSquare, Netflix, Tumblr, The Guardian, Airbnb, Meetup.com, Coursera, > UBS, Ask.com, AT&T, Bloomberg, eBay, The Weather Channel, etc. It's not > merely academic. > > It's pretty obvious that Java has many major shortcomings, especially in > the functional programming realm. Java 8 added lambdas, but it didn't add > currying, partial application, tail call optimization, and so on. Java's > "BoilerPlate boilerPlate = new BoilerPlateImpl()" is poorly suited for data > science and other cases that require expressivity. Scala's type system is > both stronger than Java's (e.g. Scala's arrays are invariant while Java's > are covariant, which was an error in language design) and more flexible > (covariance and bounds, not just bounds like in Java). Scala's type > inference cuts out the boilerplate. Implicit conversions make > domain-specific languages possible. Pattern matching allows decomposition > that's much more expressive than Java's "instanceof," switch/case and > if/else. ClassTags also allow you to combat type erasure - how can you > check if something is List<Integer> vs. List<String> at runtime if the > types are erased (a major sin that Java committed yet C# didn't). The list > goes on and on. > > Since Scala compiles to Java bytecode, you have all the Java libraries > available at your disposal, but there's no question that the language is > better, more type safe, more expressive, more concise, etc. The functional > programming features are so much better than what Java 8 *stole* from Scala > (look how they even copied the method names such as compose/andThen from > Scala) that it's hard to even begin to compare. You can still use your old > Java tools like Maven and JUnit/TestNG, though Java tools such as SBT and > ScalaTest are much more feature rich. > > I'm not saying that Scala is perfect, but it's very good, and I would > advise others to form their opinions based on experiencing it for > themselves, rather than reading what random people say on Hacker News. :) > > Marek > > > > > On Thu, May 29, 2014 at 1:55 PM, Nick Chammas <nicholas.cham...@gmail.com> > wrote: > >> I recently discovered Hacker News and started reading through older >> posts about Scala >> <https://hn.algolia.com/?q=scala#!/story/forever/0/scala>. It looks like >> the language is fairly controversial on there, and it got me thinking. >> >> Scala appears to be the preferred language to work with in Spark, and >> Spark itself is written in Scala, right? >> >> I know that often times a successful project evolves gradually out of >> something small, and that the choice of programming language may not always >> have been made consciously at the outset. >> >> But pretending that it was, why is Scala the preferred language of Spark? >> >> Nick >> >> >> ------------------------------ >> View this message in context: Why Scala? >> <http://apache-spark-user-list.1001560.n3.nabble.com/Why-Scala-tp6536.html> >> Sent from the Apache Spark User List mailing list archive >> <http://apache-spark-user-list.1001560.n3.nabble.com/> at Nabble.com. >> > >