4 ms·
It's unfamiliarity with the idiom that makes me uncomfortable, to be perfectly frank. I'll get used to it. I won't get used to how alien and ultimately weak Sc
by jfb 12y ago
It's unfamiliarity with the idiom that makes me uncomfortable, to be perfectly frank. I'll get used to it.
I won't get used to how alien and ultimately weak Scala's support for algebraic data types is, and that's not changing. This comes down to the affordances that Odersky and the Scala team have decided to favor, which is OO flavored in a way that I don't like. I vastly prefer the ML style:
data Foo = Bar s | Baz
to the sealed class/case nightmare of Scala. Again, this is not a technical nit -- this is an idiomatic and personal one.
- bad_user 12y agoYeah, but the cool thing about Scala is that you get to pick the kind of polymorphism you want, depending on whether the list of Nouns will evolve versus the list of Verbs. Like, those case classes are also classes that can have polymorphic methods on them. So for example, you can do this: https://gist.github.com/alexandru/2604948978c497adc8e2 https://gist.github.com/alexandru/2604948978c497adc8e2 - instead of doing this: https://gist.github.com/alexandru/41acda9bdd694bec38b2 https://gist.github.com/alexandru/41acda9bdd694bec38b2 Which variant is better, it depends, but both versions have tradeoffs, depending on direction. Also, Scala's OOP blend with FP is best in breed. In Ocaml for example is like having 2 type-systems in the same language, whereas in Scala it's more like a turtles all the way down kind of thing which I like.
- jfb 12y agoAlso, Scala's OOP blend with FP is best in breed. In Ocaml for example is like having 2 type-systems in the same language, whereas in Scala it's more like a turtles all the way down kind of thing which I like. This is a perfectly reasonable stance to take; I think my Objective-C background would have me argue that it makes more sense to keep two distinct paradigms syntactically distinct, but that's a matter of taste. I haven't done anything serious with OCaml -- perhaps that's a direction I'll explore after my Haskell toy project is finished. Thanks for the replies, you've shed much light. And the OP is great, too; I'll definitely be keeping it close at hand.
- bkirwi 12y agoTBH, I think that is a legitimate technical nit. Case classes end up being very useful, but they're not as principled as the ADTs that they're generally used to replace, and that shows up in a bunch of weird corner cases. It's one of the prices you pay for trying to cram this stuff into the JVM / OOP universe. Speaking to your sibling comment on Haskell and Kotlin: I also happen to think that Haskell is by far the better-designed language. I think Kotlin does a nice job of cleaning up some of the warts of Java, but I don't really want a better Java -- I just want a better language. Scala is definitely less elegant than Haskell (Haskell/Scalaz-style FP is particularly gross) but there's a large class of problems for which I really do think it's the best language / ecosystem that happens to actually exist.
- jfb 12y agoI complain, but at the end of the day, I really do prefer working in the JVM with a language that can e.g. curry functions and implement at least partial type inference, given the constraints that we work under. I think it was a good choice; but I'm not likely to grab for Scala for fun.