15 ms·
I am a Scala programmer & think it's a great language. Here are some arguments for why not Scala: * Li's libs (os-lib, upickle, utest) have clean public inter
by MrPowers 6y ago
I am a Scala programmer & think it's a great language. Here are some arguments for why not Scala:
* Li's libs (os-lib, upickle, utest) have clean public interfaces, but most Scala ecosystem libs are hard to use, see the JSON alternatives for examples: https://www.lihaoyi.com/post/uJsonfastflexibleandintuitiveJSONforScala.html#scala-alternatives https://www.lihaoyi.com/post/uJsonfastflexibleandintuitiveJS...
* The Mill build tool looks a lot better than SBT, but seems like everyone is still using SBT
* Scala minor version are binary incompatible, so maintaining Scala projects is a big pain. Upgrading Spark from Scala 2.11 to Scala 2.12 was a massive undertaking for example.
* Scala has tons of language features and lets people do crazy things in the code. Hard to win technical arguments with Scala geniuses that like using complicated language features.
* Scalatest is stil used by most projects and is annoying to use, as described here: https://github.com/lihaoyi/utest#why-utest https://github.com/lihaoyi/utest#why-utest. The overuse of DSLs in Scala is really annoying. Too many DSLs is another example of something I consider to be an antipattern, but there is no Scala community consensus on the responsible use of DSLs.
I'm optimistic about Scala. There are some folks that love the language and are continuously improving the ecosystem. Scala 3 will have to sell a better story about ditching legacy tooling and giving users a better default stack if it wants to compete with modern Go/Rust/Python.
- dominotw 6y ago> Hard to win technical arguments with Scala geniuses that like using complicated language features. I was on a team building good old crud apps using monads, monoids, categories, combinators, effects cats, seamless and bunch of other nonsense that i've now purged from my brain. You could've easily mistaken our team for a programming language research group at a university. This is literally the number one reason i would never choose scala. There is no upper bound to amount of stupidity one can indulge in. Our code was so convoluted that even intellij had trouble understanding what the hell was going on and would spit out compilation errors when there were none. I now work with clojure team and i feel a sense of relief and weight taken off of my head from all the useless stuff i had to learn and use.
- Cthulhu_ 6y agoThis is my biggest gripe with Scala as well. I'm sure it's a great language, but I've often seen it used to add complexity where none is necessary. It's abused to give developers a sense of accomplishment and intellectual superiority. In fact, in one project my former employer was involved in, one main reason they picked Scala was to, on the one hand, weed out the chaff from their existing team of .net developers (in a "shape up or ship out" kind of fashion), and on the other to weed out the 95% of mediocre Java developers.
- dominotw 6y ago> weed out the chaff from their existing team of .net developers This is scala equivalent of HN/pg lisp folklore.
- dboreham 6y ago> sense of accomplishment and intellectual superiority This, I feel, is underneath a very large proportion of everything in our industry.
- dmux 6y ago>...I've often seen it used to add complexity where none is necessary. This reminded me of a great blurb about Niklaus Wirth's approach to languages: >Wirth’s philosophy of programming languages is that a complex language is not required to solve a complex problem. On the contrary, he believes that l languages containing complex features whose purposes are to solve complex problems actually hinder the problem solving effort. The idea is that it is difficult enough for a programmer to solve a complex problem without having to also cope with the complexity of the language. Having a simple programming language as a tool reduces the total complexity of the problem to be solved. [0] [0] Pg.2 http://www.cslab.pepperdine.edu/warford/ComputingFundamentals/PboxCh01.pdf http://www.cslab.pepperdine.edu/warford/ComputingFundamental...
- augustk 6y agoNiklaus Wirth designed and implemented the languages Pascal, Modula-2 and Oberon of which the last one is the smallest. https://miasap.se/obnc/oberon-report.html https://miasap.se/obnc/oberon-report.html
- valenterry 6y agoLet's clarify some points for folks not so familiar with Scala. > * Scala minor version are binary incompatible, so maintaining Scala projects is a big pain. Upgrading Spark from Scala 2.11 to Scala 2.12 was a massive undertaking for example. Scala just chose a strange naming scheme. Other languages would have just increased their major version instead. The scala minor version is increased every few years and not every month or so. > * Scala has tons of language features and lets people do crazy things in the code. Actually, that's not true. Or rather: compared to what language? Scala has surprisingly few language features, but the ones it has are very flexible and powerful. Take Kotlin for example. It has method extensions as a dedicated feature. Scala just has implicits which can be used for method extension. > * Scalatest is stil used by most projects and is annoying to use, as described here: https://github.com/lihaoyi/utest#why-utest https://github.com/lihaoyi/utest#why-utest. The overuse of DSLs in Scala is really annoying. I agree with the overuse of DSLs. Luckily that got much better, but older libraries like scalatest still suffer from that. > * Li's libs (os-lib, upickle, utest) have clean public interfaces, but most Scala ecosystem libs are hard to use, see the JSON alternatives for examples I think that just comes from using the library in a non-idiomatic way. In most applications, you will need to use the whole json anyways, and then you use (or can use) circe like that: { "id": "c730433b-082c-4984-9d66-855c243266f0", "name": "Foo", "counts": [1, 2, 3], "values": { "bar": true, "baz": 100.001, "qux": ["a", "b"] } } case class Data( id: String, name: String, count: List[Int], values: List[DataValue] ) case class DataValue( bar: Boolean, baz: Float, qux: List[String] ) import circe.generic.auto._ import io.circe.parser._ val data = decode[Data]("...").get data.copy(name = data.name.reverse).asJson Yeah, that is more code, but as I said, in the vast majority for projects, you need all or most of the fields anyways, so all the structure definition is a one-time thing. The advantage is that the last line is plain Scala code. You don't even need to understand the json-library to do transformations and re-encode into json.
- _a1_ 6y ago> Scala just has implicits which can be used for method extension. I don't think it's fair to say it like this. Scala's implicits can mean different things, depending on where they're used. Scala 3 even divides 'implicit' to multiple keywords. (kind of 'static' in C++ I guess, only more complicated)
- bzzzt 6y agoOverheard on a Java conference: "I love Scala, clients pay me big bucks to rewrite it into sane Java code".
- cutler 6y agoJava - the terraced housing of programming. Still, point taken.
- lihaoyi 6y ago> Hard to win technical arguments with Scala geniuses that like using complicated language features. This is an interesting point. Perhaps part of the reason my current employer has been successful with Scala has been that we never were integrated into that part of the community. We hire non-Scala programmers and they write Scala without any training, and it generally turns out OK and ends up converging in a pretty boring style without any fanciness
- MrPowers 6y agoYep, the Spark codebase is a great example of what a big Scala codebase should look like. Nothing crazy, not too many traits, mainly just "regular functions". Imagine another codebase uses a feature like self-types extensively: https://docs.scala-lang.org/tour/self-types.html https://docs.scala-lang.org/tour/self-types.html A small team has no good way to resolve the argument if self types should be used all over the place or avoided entirely.
- marcinzm 6y ago> Yep, the Spark codebase is a great example of what a big Scala codebase should look like. A lot of the hardcore Scala community hates Spark which sort of summarizes the situation.
- hocuspocus 6y agoThis is a false dichotomy. You'll run into all sorts of pain and frustration as soon as Spark touches your codebase, no matter what kind of Scala you're writing.
- marcinzm 6y agoI've almost every big data processing system out there and Spark causes no more pain than any other. Less than most. It's also a data processing system not a library so if you're integrating it into existing code (rather than writing code for it and running code on top of it) I'd argue you're doing it wrong.
- msluyter 6y agoAfter a number of years with Python, I started a position working in Scala about 6 months ago. I really wanted to learn something new, and become acquainted with functional programming concepts. I agree with most of the above. A couple of additional thoughts: * sbt -- I still have a lot of coming up to speed to do here, but the manual is like 500 pages and it's somewhat overwhelming. There are tons of little oddities, like why can't I run `sbt --version` and instead have to do `sbt sbtVersion`? * The functional side is fascinating -- I'm still studying the cats library. I can almost describe a Monad! It's a pretty big mountain, though, and there are times where I have doubts whether the benefits will be worth it. Would love to hear some re-assurance! ;) * The ecosystem for microservices seems pretty closely tied to akka & lagom. These are quite complex in their own right and we've been having trouble with the latter in particular. Curious to learn about alternatives. ZIO? * Re: DSLs. Also not a huge fan of DSLs. One refreshing thing about python is that often configuration can just be in Python itself (as in Django, for example). See also: [1] https://erikbern.com/2018/08/30/i-dont-want-to-learn-your-garbage-query-language.html https://erikbern.com/2018/08/30/i-dont-want-to-learn-your-ga... [2] https://github.com/cf020031308/cf020031308.github.io/blob/master/blog/i-dont-want-to-teach-my-garbage-dsl-either.md https://github.com/cf020031308/cf020031308.github.io/blob/ma... [3] https://twitter.com/antonycourtney/status/589238574429515777 https://twitter.com/antonycourtney/status/589238574429515777
- randmeerkat 6y ago> It's a pretty big mountain, though, and there are times where I have doubts whether the benefits will be worth it. Would love to hear some re-assurance! ;) It’s not worth it, the entire language is a mountain of documentation and hard to understand concepts that just gets in the way of actually delivering product features for the business. It will help you to think differently about programming problems though.
- kaba0 6y agoI learnt Scala before diving deeper into FP, but I think properly learning/understanding Monads and some other FP concepts greatly help every sort of programming I do (even though it is mostly OOP nowadays). You come to notice it everywhere and even if you can’t abstract over them (there is no one `bind` or `join` function, so it may be called different with each Monad instance), but after understanding them you will gain a better reasoning power over them.
- pdpi 6y ago> Scala has tons of language features and lets people do crazy things in the code. In many ways, it's even worse than that. Scala has exactly two features (implicits and punctuation-free method calls) that allow you to build massively complicated libraries that pretend to be language features, and which work worse than equivalent features in languages that support them explicitly. A good example of this is typeclasses which are core features of haskell and rust, but are implemented by explicitly passing implicits (hah) in Scala.
- yw3410 6y agoScala 3 has type-classes as a core feature.
- pdpi 6y agoRight. We don't have a full production 3.0 release yet, so I tend to think of "Scala" as Scala 2 unless it's specifically qualified as Scala 3. Scala 3 seems to be a really good step in the right direction for me. There's a clear desire for many of the features that are currently achieved through burdensome hacks on top of implicits, and actually reifying several of them into core language features is a counterintuitive way to make things simpler rather than more complicated.
- cutler 6y agoAs far as I'm aware implicits are alive and well in Scala 3 and will, I predict, be Scala's ultimate downfall.
- lmm 6y agoNo it doesn't, it has syntax to make them look more like a language feature but they're actually still just implicits.
- rapnie 6y ago> Scala has tons of language features and lets people do crazy things in the code. Hard to win technical arguments with Scala geniuses that like using complicated language features. I also like(d) a lot about Scala, but this is what ultimately led me to other languages. There's too many language features cranked together. This makes a) for a steep learning curve and b) exposes you to expert's code that is so dense and 'smart' that its a PITA to decipher what it does. b) you'll encounter especially when incorporating libraries that are not fully stable, and you have to track down bugs in them (if only to know if your code is at fault, or the library's code). I had this with Akka when it was just released. One line of code and 2hrs of debugging to determine what it did, and if it was faulty or not.
- wirrbel 6y agoI can agree with all your points (wrote a fair bit of Scala all though I wouldn't identify as a scala programmer). Scala is a weird case, I would normally be the perfect fanboy for it, I like functional programming, did my fair share of SML, Haskell, Clojure. Also I am not at all dogmatic and can even find joy in writing Java. However, Scala and I never got along well. It is - I think - too magic. I'd even prefer pure Java over it tbh. And then, the community is fairly toxic, which also made me not want to stick around.
- oldgradstudent 6y ago> The overuse of DSLs in Scala is really annoying. Unless, of course, that specific DSL is the sole reason for choosing Scala, like with Chisel[1]. [1] https://www.chisel-lang.org/ https://www.chisel-lang.org/
- MichaelMoser123 6y ago> The overuse of DSLs in Scala is really annoying. Too many DSLs is another example of something I consider to be an antipattern, but there is no Scala community consensus on the responsible use of DSLs. Domain specific languages are heavy users of the implicit keyword and implicit conversion; maybe that makes the code more concise, but it doesn't quite help with reading / understanding the code. For me that's the greatest problem with scala - figuring out what this code in front of me does.
- thinkharderdev 6y agoThe way I tend to think about it is that there are different axes of "complexity" in a language/ecosystem. Looking only at the language itself then yes Scala is quite complicated with a lot of language features (implicit, higher-minded types, macros, ...) that are uncommon in other popular languages. But another axis to consider is "how many abstractions do I need to understand in order to grok a large codebase?" And that I think is where Scala shines. There are different ecosystems but if you look at something likes cats/cats-effect then there are a core set of type classes on which everything else is built and if you understand those core abstractions then understanding any codebase which uses them is very easy. And those abstractions are extremely flexible to the point where they can be applied to an astonishing variety of problems. Contrast that with something like Java which, while quite simple syntactically, has a huge and varied super-structure of incongruent abstractions on top of it. Every time I dive into a largish codebase of "enterprise Java" it feels like the engineers has a running bet on who could use the most GoF patterns in any given module.
- MichaelMoser123 6y agogood point! on the other hand java got some functional features since java8 (lambda/streams/option chaining) that allow to have less bloated code; i think nowadays it is (at least) possible to have a less design pattern heavy code style in java.
- thinkharderdev 6y agoTrue. Java has improved substantially since java8 (including something kinda sorta like case classes with record types in jdk15) but I still think Scala is miles better. I don't think it is generally appreciated how essential higher-minded types and typeclasses are to making functional programming tractable and safe. Perhaps because it is something that is generally hidden away in libraries and developers working on actual application code (i.e. 99% of scala devs) never use them.
- cutler 6y agoKotlin is Scala's biggest competitor not Go/Rust/Python.
- still_grokking 6y ago> * Scala minor version are binary incompatible Isn't it "major" versions? AFAIK Scala has a version scheme of "epoch.major.minor"