Hacker News new | ask | show | jobs
by skybrian 2957 days ago
Why do you think Go's type has "less benefit" than Java's type system?
2 comments

That's my personal, anecdotal feeling as well. Go feels a bit more like I'm yelling at the compiler "you know what I mean, why can't you just do it?!" whereas with Rust it's more "ah, I see, you have a point".
Java has generics for one.

Failed generics with type-erasure sure, but definitely better than Go which has nada.

Type erasure on it's own isn't necessarily a bad thing, Haskell implements type erasure also.
I guess this was your point, but the problem is how Java does does type erasure. With Haskell type erasure is an implementation detail, but with Java it leaks into the compile-time type checker. For instance, you can't have both these overloads:

    public void foo(List<String> list)
    public void foo(List<Integer> list)
This just wouldn't compile.
The problem there is that the equivalent Haskell would dispatch statically, whereas this is dynamic dispatch in java
Not today, but in the future it might, depending on how the work on value types will turn out.
The difference is that Haskell has very little RTTI, so you can't really see the missing types at runtime. For Java it's much more noticeable, because runtime type manipulations are way more common.