5 ms·
To be honest, designing a good programming language is not just collecting random good features from other languages and gluing them together. Particularly, add
by pkolaczk 11y ago
To be honest, designing a good programming language is not just collecting random good features from other languages and gluing them together. Particularly, adding new features to an old and mature language like Java or C++ is very hard if not impossible to do right. We have a few examples of this in happened already in Java world: half-broken generics or support for lambdas with no proper map/filter etc. on basic collections (forcing to do a lot of conversions to/from streams). Sure, it is better than no generics or no lambdas at all, but it is Java that really looks like a hack now, not Scala.
There is also stuff that probably can't be taken out from Java without major backwards compatibility issues. E.g. Scala has no distinction for primitive/box types, which makes it much simpler and more elegant for basic imperative/OOP programming than Java.
As for frustration working with Scala - I didn't notice, despite working on a few projects for a few years now. I've known only one programmer in my whole career who complained about introducing Scala into one project because "Scala was too complex" and guess what... he was one of the poorest Java programmers on that team at that time. Java did not save him either. Reading his Java code was probably much more frustrating than waiting 5 minutes for a full Scala build would be. Poor programmers do exist and you should not blame the tool just because someone can't properly learn how to operate it.
- lomnakkus 11y ago> As for frustration working with Scala - I didn't notice, despite working on a few projects for a few years now. TBH, if you're using Scala as a slightly better Java/C#, then you're probably going to get a lot of mileage out of it. As someone who really would prefer Haskell, the problem I find is that Scala has all these tantalizing features that you really want to use but which turn out to be broken in subtle ways. Anyone who's used scalaz will know what I mean. The absurdity of "for { ... } yield" notation is one of the first things that springs to mind. (Given that "return" is NOT special or magical in any way in a Monad and can, in fact, meaningfully be repeated in the same function.). The other major thing is that you can arbitrarily (and subtly!) do side effects while in "monadic" notation. That nullifies most of the advantages of having a do/for-yield notation in the first place. There's also the stack overflow issues that are rampant if you actually try to use monads seriously in Scala, etc. etc. (This boils down to the JVM not having tail-call elimination.) Scala is basically a cocktease when it comes to FP features. It promises loads, but doesn't really deliver. These days, I'd actually probably prefer C#/Kotlin/Ceylon over Scala[1] because at least they don't lead you astray in this way. (Obviously, I'd prefer to rewrite everything in Haskell, but we have an actual existing/working system written in Scala to support, so...) TL;DR: These days we're using Scala as a "better Java" and if that's what you want, then you probably won't be disappointed. If you're looking for FP-as-it-should-be then you will be disappointed. [1] Assuming we're only talking about language, not the wider ecosystem.
- pkolaczk 11y agoI've heard this argument many times and it all boils down to "Scala is not Haskell", which is in fact a true statement. Scala is not Haskell and never meant to be a Haskell replacement, nor a pure FP non-strict language. Complaining effects or monads are broken in Scala is like complaining that nominal subtyping in Haskell is broken or that you can't just introduce state in Haskell whenever you want, like you can with Scala changing a val to a var. Different design choices, different strengths / weaknesses. Anyway, Scala is probably one of very few languages that combines OOP and FP and at the same time has type system sophisticated enough that it can express directly or indirectly the stuff that Haskell can - maybe more verbose and there are some rough edges like you say, but hello, here is the news: Scala is not Haskell and it had to pay some price for other useful stuff that Haskell doesn't offer. Also, Scala creators are generally aware of some shortcomings of the current Scala type system and are working hard on improving and simplifying things (DOT calculus). So if you know how to make effects or for yield notation better and fix these subtle problems - I think the community would appreciate your help.
- lomnakkus 11y ago> I've heard this argument many times and it all boils down to "Scala is not Haskell", which is in fact a true statement. Scala is not Haskell and never meant to be a Haskell replacement, nor a pure FP non-strict language. Yes, but my point is that Scala's unholy combination of OOP/FP has been marketed as some sort of panacea... which it definitely isn't. I think, it's actually worse in both aspects: Erlang (modulo static type checking) beats it in the OOP realm, and Haskell (and Idris, etc.) beat it in the functional. Try to use scalaz for anything serious, and I think you'll find out what I mean. Don't get me wrong, scalaz (and shapeles, etc.) are marvels of engineering, but they aren't sufficient in practice. Nor are they for any reasonable definition of the term 'usable'. Haskell/GHC is -- and in fact it's simple and easy. Btw, now we can also enjoy 'cats'! Let's retread the whole "mtl" and "transformers" disaster once again in Scala! Fun! (I was around for the Haskell mtl/transformers/fundeps thing and... it didn't work. Monad &c. need to be part of standard library. For sanity.) I just think programming languages is a realm where compromise doesn't work. Maybe I'm wrong, but... > Anyway, Scala is probably one of very few languages that combines OOP and FP Firstly, "Combine A+B does not necessarily improve anything"[1], but... Secondly, see, this is the problem... having a few things signify "this cannot be mutated" does not an FP language make. It's far more complicated than that -- it's about culture. The Scheme authors recognized this and named anything that was "dangerous" (side-effecting) with a bang at the end so that it would be offsensive and stand out to any code reviewer. This is what FP is all about... not just paying lip service (which I think Scala is doing currently) to immutability. EDIT: Look, I realize that I'm being an asshole with the beneift of hindsight, but still... I'm talking about what we should aspire to. Not just accept. [1] I think the supreme example of this is in the O'Caml object system. It's basically better than any single-dispatch system out there, but nobody[2] actually _uses_ it. Why? Because it's just simpler to do in function style. [2] Yeah, yeah, qualifiers, formal studies, etc.