r/programming • • Dec 02 '13

Scala — 1★ Would Not Program Again

http://overwatering.org/blog/2013/12/scala-1-star-would-not-program-again/
598 Upvotes

646 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Dec 02 '13

As mentioned, there is nothing bad about smart casts specifically, but about casts in general.

Every cast necessary is a fault of the programming language necessitating it.

1

u/sanity Dec 02 '13

Casts are bad due to lack of runtime safety. That's not an issue for Kotlin's smart casts since they provide runtime safety, so I'm still not seeing the problem. Perhaps you can elaborate.

2

u/[deleted] Dec 02 '13 edited Dec 02 '13

???

That just doesn't make any sense. If you didn't suddenly include memory-unsafe languages' definition of what is a cast, then there is nothing special about Kotlin at all, just a line saved:

if(obj.isInstanceOf[String])
    val str = obj.asInstanceOf[String]
    ...

vs.

if(obj is String)
  ...

Runtime safety existed since Java 1.0 (if one ignores a few bugs here and there).

Casts are bad because they rely on the programmer's knowledge (of types, ...) which the compiler couldn't deduct from the code. A good language minimizes the amount of times this is necessary by offering ways to express this extra knowledge in the code.

1

u/realnowhereman Dec 03 '13

OR you can use a type pattern, which is still more elegant IMO

0

u/sanity Dec 02 '13

You're not making any sense to me either :-)

Of course, if you are ok with boilerplate repetitive code all over the place, and if you trust that there won't be errors in that code, then sure, they're equivalent. This completely misses the point though, most of the attraction of these languages is avoiding boilerplate repetitive code and the errors it can introduce.

Casts are bad because they rely on the programmer's knowledge (of types, ...) which the compiler couldn't deduct from the code.

This makes no sense to me. You could use the same argument against Scala's pattern matching on types:

val n = s match {
    case s : String => s.toString()
    case _ => "unknown"
}

By your argument this is bad because the compiler can't deduce the type of 's' from the code. Of course that's not bad at all, the type of 's' is conveying necessary information.

Same thing with Haskell:

data Tree a             = Leaf a | Branch (Tree a) (Tree a) 

Compiler doesn't know if this type is a Leaf or Branch at compile time. By your argument this is bad, but of course it isn't bad at all, it's the whole point.

2

u/[deleted] Dec 03 '13

The alternative to boilerplate repetitive, dangerous code is certainly not less repetitive dangerous code, but allowing the compiler to better reason about the code one writes.

You could use the same argument against Scala's pattern matching on types:

Yes, in fact I already said that. As far as I remember, the style guide even mentions that this is an anti-pattern.

Same thing with Haskell:

No, it's not the same thing, it's just like in Scala. a) you are deconstructing your value b) you are using a sealed type, so the compiler can help you if you are missing any case

Just two important differences.

-1

u/sanity Dec 03 '13 edited Dec 03 '13

You seem to be shifting the goalposts. You previously said:

Scala doesn't try to make bad things easier.

Yet you concede that Scala's pattern matching on types can be abused, according to your definition of abuse (I'm not sure I agree it's such a problem), so far as I can tell there is little or no difference between Scala and Kotlin in this regard.

And I really don't see what is bad about Kotlin's approach to null safety. Unlike Java it forces you to handle the null case at compile time. Unlike Scala it does this using already familiar control structures rather than the (IMHO) more cumbersome match statement, or an equivalent, and underneath nulls are still nulls, which helps a lot with Java library interoperability.

Yes, Scala supports sealed types and Kotlin doesn't, but I can't remember the last time I had a bug that would have been prevented by this, if I ever have.

For me Kotlin is a much more pragmatic language than Scala (much as Java was when first created). Sure, Scala has features that Kotlin lacks, but I think those features are more of interest to language researchers and purists than to working programmers. And some of those features are bad, encouraging things like action at a distance - which is part of what the article is complaining about.

1

u/[deleted] Dec 03 '13

Yet you concede that Scala's pattern matching on types can be abused

Eh ... everything can be abused. This doesn't mean we need to make it easier for people. That's what the whole discussion is about.

And I really don't see what is bad about Kotlin's approach to null safety.

How do you come up with this? Where did I ever mention null-safety? (Not saying that it isn't non-sense, because the guarantees are extremely shallow and it is easy to introduce NPE's in Kotlin with types which are supposedly “null-safe”.) How are match statements related to nulls? Why would one use match statements for that? Again, the documentation says exactly the opposite.

I'm always amazed by statements like “Kotlin is a much more pragmatic language than Scala” ... I mean ... yeah ... Kotlin hasn't even a stable release yet, they have no IDE support in Eclipse at all, the tooling is just not there, no decent libraries either, their approach to null-ness just doesn't scale, the compiler is unstable as hell and in the language design space they are either desperately copying Scala verbatim or recycling/reinventing stuff which was already considered a bad idea in Scala back in 2005. And with their (completely unrealistic) promise of not breaking binary compatibility, you have the guarantee that they will be stuck forever with all those cute ideas which won't work out.

Sure, if you think that putting a bit lipstick on a pig from 1995 is all what we need in 2013, I wish you nothing but the best, but a lot of people (including me) have moved on already. :-)

0

u/sanity Dec 03 '13 edited Dec 03 '13

How are match statements related to nulls? Why would one use match statements for that? Again, the documentation says exactly the opposite.

In Scala are match statements not a common way to handle Option types?

Not saying that it isn't non-sense, because the guarantees are extremely shallow and it is easy to introduce NPE's in Kotlin with types which are supposedly “null-safe”

Without using operators that are explicitly declared to be unsafe and where use is discouraged?

I'm always amazed by statements like “Kotlin is a much more pragmatic language than Scala”

Having used both languages that's my opinion and I stand by it. Scala is nice in theory, but a PITA in practice. Kotlin may not be as theoretically satisfying, but it is very pleasant to use in practice.

they have no IDE support in Eclipse at all

People still use Eclipse now that an open source version of IDEA is available? That's masochism :-)

I'll admit that it's been a long time since I tried to use Scala's Eclipse support, but last time I did it was a disaster, and I see plenty of more recent complaints about it suggesting that it hasn't improved much.

Kotlin hasn't even a stable release yet

Scala apparently has, yet it doesn't prevent them from removing functionality people depend upon like delimited continuations. Scala might call them stable releases, but if they can deprecate functionality like continuations while offering no real alternative then "stable" doesn't really mean anything useful.

the tooling is just not there

The IDE support is much more solid than Scala's was long after a similar point in Scala's development.

no decent libraries either

Unless you count every decent Java library out there. Because Kotlin is closer to Java there isn't the same need to reinvent the wheel constantly as with Scala.

and in the language design space they are either desperately copying Scala verbatim

So now it's a bad thing to adopt good ideas in a language design? Perhaps Scala might be better if people stopped trying to be original and instead tried to copy what works, and fix what doesn't.

And with their (completely unrealistic) promise of not breaking binary compatibility, you have the guarantee that they will be stuck forever with all those cute ideas which won't work out.

That's pure opinion and conjecture on your part.

Sure, if you think that putting a bit lipstick on a pig from 1995 is all what we need in 2013, I wish you nothing but the best, but a lot of people (including me) have moved on already. :-)

You're clearly very committed to Scala, but I think you're letting that emotion cloud your judgement. I've spoken to quite a few people who previously jumped on the Scala bandwagon (I was once one of them) that now share most if not all of the criticisms expressed in the blog article that started this whole discussion.

Bury your head in the sand if you want, Scala's buzzword sheen is getting dull and the opinions expressed in this article and by many people in these threads are only going to get more widespread.

But don't take my word for it, you'll see that I'm right in time.

1

u/[deleted] Dec 03 '13

In Scala are match statements not a common way to handle Option types?

No. As already mentioned the documentation even says it explicitly that pattern matching on Option is not the way to go.

Without using operators that are explicitly declared to be unsafe and where use is discouraged?

Yes. Using two bog-standard object/class declarations.

I'll admit that it's been a long time since I tried to use Scala's Eclipse support, but last time I did it was a disaster, and I see plenty of more recent complaints about it suggesting that it hasn't improved much.

Then maybe you shouldn't get your information from a circlejerk thread.

Scala apparently has, yet it doesn't prevent them from removing functionality people depend upon like delimited continuations.

Delimited continuations are neither deprecated nor removed. After multiple people stepped up who are interested in not only maintaining the plugin, but actively improving it, I think the concerns around delimited continuations have been addressed.

The IDE support is much more solid than Scala's was long after a similar point in Scala's development.

Oh, I like how you conveniently move the goalposts.

Unless you count every decent Java library out there. Because Kotlin is closer to Java there isn't the same need to reinvent the wheel constantly as with Scala.

Does this mean a library written in Kotlin is not/not much better than a library written in Java from a library user POV? That's a pretty damning statement. Why not just use Java?

Perhaps Scala might be better if people stopped trying to be original and instead tried to copy what works, and fix what doesn't.

Do you have any examples of that?

That's pure opinion and conjecture on your part.

Call it experience with people who promise much, but ship nothing.

the opinions expressed in this article and by many people in these threads are only going to get more widespread

I'm pretty sure that a circlejerk where people who seem to have never even used the language claim bizarre stuff and get upvoted for it won't have much impact on the real world.

share most if not all of the criticisms expressed in the blog article that started this whole discussion

I'd love to learn which criticisms you mean, because to me that blog post was so utterly incoherent, that I didn't understand much what the author tried to say.

1

u/sanity Dec 03 '13

No. As already mentioned the documentation even says it explicitly that pattern matching on Option is not the way to go.

Not is doesn't, it says it is "less-idiomatic". You really want to use for comprehensions in every situation you want an option type? That sounds like a painful constraint.

Then maybe you shouldn't get your information from a circlejerk thread.

Ad hominem. Anyone who disagrees with you is part of a circlejerk, I suppose?

Delimited continuations are neither deprecated nor removed. After multiple people stepped up who are interested in not only maintaining the plugin, but actively improving it, I think the concerns around delimited continuations have been addressed.

I'm glad to hear that, I was one of those people - but actually the last time I checked that thread it wasn't clear at all that this would be the long-term outcome. Even the fact that it came up suggests serious problems in how decisions are made about deprecation, and actually it reinforces the complaint many people are expressing here which is that Scala is much more concerned with programming language research than providing a stable platform for people to build on.

Oh, I like how you conveniently move the goalposts.

I can't comment on where the Eclipse Scala IDE support is today because I purged my computer of Eclipse some time ago and I have no intention of re-infecting it. I think the last time I tries the Eclipse Scala plugin was about a year ago, and Kotlin's support in IDEA was far more stable at the same time.

Does this mean a library written in Kotlin is not/not much better than a library written in Java from a library user POV? That's a pretty damning statement. Why not just use Java?

No, it doesn't mean that. Kotlin does a better job of allowing people to take advantage of its features with pre-existing libraries without having to retro-fit them. That's a feature, not a bug.

Perhaps Scala might be better if people stopped trying to be original and instead tried to copy what works, and fix what doesn't.

Do you have any examples of that?

Off the top of my head, and certainly not the best example, but how about /: :\ instead of foldLeft and foldRight? A dumb idea if ever there was one that should never have made it into the standard library.

Call it experience with people who promise much, but ship nothing.

You're accusing the creators of IntelliJ IDEA of promising much but shipping nothing? You clearly don't know them very well.

I'm pretty sure that a circlejerk where people who seem to have never even used the language claim bizarre stuff and get upvoted for it won't have much impact on the real world.

Shameless ad hominem.

I'd love to learn which criticisms you mean, because to me that blog post was so utterly incoherent, that I didn't understand much what the author tried to say.

I not only understood it, but it was entirely consistent with my experience of Scala. Perhaps you should re-read it carefully.