3 ms·
Blogspam, original is here: http://overwatering.org/blog/2013/12/scala-1-star-would-not-program-again/ http://overwatering.org/blog/2013/12/scala-1-star-would-
by yummyfajitas 13y ago
Blogspam, original is here:
http://overwatering.org/blog/2013/12/scala-1-star-would-not-program-again/ http://overwatering.org/blog/2013/12/scala-1-star-would-not-...
Some thoughts: I've worked on several large scala projects, and I've found that long incremental compile times are often a sign of bad encapsulation. If you change the type signature of a public method then any file using that class needs to be recompiled.
I've found that explicit type annotations on method return types help a lot here:
def getBandit(ref: BanditRef)= {
...
ConcreteSimpleBandit(...)
}
This has type `BanditRef => ConcreteSimpleBandit`. If I change the implementation and return a ConcreteNonSimpleBandit, the inferred type signature changes to `BanditRef => ConcreteNonSimpleBandit`. If I use an if-statement and return one or the other, the return type will be the nearest superclass of both (say a ConcreteBandit).
However, if I explicitly annotate it to return a BanditLike
def getBandit(ref: BanditRef): BanditLike = {
...
ConcreteSimpleBandit(...)
}
then only the class in question needs to be recompiled.
The author is spot on about the use of infix methods. These are nearly always evil. What would be great if Scala gave you a way to explicitly declare certain functions as infix, and everything else uses the java-style calling convention. For a monoid, a |+| b |+| c makes perfect sense. However, consider:
optionalResult map (x => x*x) filter (_ % 2 == 1) getOrElse -1
Yeah, you need to do work to figure out what's going on. Compare to:
optionalResult.map(x => x*x).filter(_ % 2 == 1).getOrElse(-1)
But I suppose the former will save some bits ('.' and '(' take more bytes than ' ', right?).
- ryanobjc 13y agoThis comment reminded me of a book called "Large Scale C++ Software Design" which is essentially about techniques to speed up your build time. My short handed criticism about Scala is this: It's the C++ of the JVM. Specifically it has many features of C++ we thought we left behind: - slow compile times - complex language features and syntax The language features have a benefit, and a cost. I just personally believe the cost outweighs the benefits for me.
- bad_user 13y agoHaving worked with both Scala and C++, I actually think that people saying this don't know what they are talking about. I encourage you to take another look, as we often jump to criticisms with only a superficial understanding, often based on comments made on forums by other people. In particular, the idea of writing the code in a certain way to avoid recompilation is rather silly and I never, ever did it in the last 2 years since I worked with Scala. On syntax and complex language features - having trained rookies unfamiliar with Scala myself, I can tell you - it's neither the syntax or the language features that are problematic, but rather the concepts involved. The Scala ecosystem is chock-full of paradigms coming from static FP languages such as Haskell. Scala's features are actually very elegant and orthogonal. It does have ugly corners that are a result of its interoperability with its host, the JVM, but that's a tradeoff I like, because people that don't like the JVM, haven't seen what it can do. On compilation speed, it's not much of a problem though I understand why people don't like it. But the type system is very static - and in comparison with Java in which the type system does nothing else but to stay in your way - in Scala it actually helps you to write code that is sometimes provably correct or to design safe and user-friendly APIs. For me it's not a problem if my code takes an extra couple of seconds to compile, because the compiler does help me in the case of Scala. In terms of recent developments, both SBT and Maven are doing incremental compilation. Plus, SBT makes it really, really easy to break your project into multiple sub-projects that depend on each other, to keep them small, something which helps with compilation speed though personally I do it for keeping the code base cleaner.
- yapcguy 13y agoCorrectness. Hmm. See other comments below where co-founder of Typesafe (who has quit) gave a talk explaining why Scala is doing everything wrong. In his video he has a slide with the words "No wonder nothing works" and on the slide: scala> val x1: Float = Long.MaxValue x1: Float = 9.223372E18 scala> val x2: Float = Long.MaxValue - Int.MaxValue x2: Float = 9.223372E18 scala> println(x1 == x2) true This is the guy who has worked on the Scala compiler. He says it will never be fast and there are things which are fundamentally broken (like above, and there are many more). I think any start-up using Scala is making a big mistake.
- laureny 13y ago> My short handed criticism about Scala is this: It's the C++ of the JVM. "Scala is to Java what C++ is to C".
- ryanobjc 13y agoThis talk from Paul Phillips is really interesting: http://parleys.com/play/528cbfc3e4b084eb60ac78f2/about http://parleys.com/play/528cbfc3e4b084eb60ac78f2/about With slides: http://www.slideshare.net/extempore/keynote-pnw-scala-2013 http://www.slideshare.net/extempore/keynote-pnw-scala-2013 The main take-away imo is the line "every increase in expressiveness brings an increased burden on all who care to understand the message" That line basically why I am not as fond of Scala as I originally was. My defense of the inevitable "well hire smarter developers then!" is twofold (a) You're saying Scala is not a mass market audience language and (b) you aren't as smart as you at 4am, after you were just woken up because your code is broken in production.
- steveklabnik 13y agoAnd it was discussed a little over a month ago, 350 comments: https://news.ycombinator.com/item?id=6829725 https://news.ycombinator.com/item?id=6829725
- lmm 13y agoI find the version without the .s much more readable as long as all the methods take one argument each. Haskell does it for everything, so this is certainly a viable syntax choice, though IMO it isn't nice when you have multi-argument methods.