logoalt Hacker News

munificentlast Tuesday at 10:49 PM5 repliesview on HN

I think Go should have shipped with generics from day one as well.

But you breezily claiming they made the same blunder as Java omits the fact that they didn't make the same blunder as Rust and Swift and end up with nightmarish compile times because of their type system.

Almost every language feature has difficult trade-offs. They considered iteration time a priority one feature and designed the language as such. It's very easy for someone looking at a language on paper to undervalue that feature but when you sit down and talk to users or watch them work, you realize that a fast feedback loop makes them more productive than almost any brilliant type system feature you can imagine.


Replies

hackingonemptylast Wednesday at 12:35 AM

This is a very good point, fast compilation times are a huge benefit. The slow compiler is a downside of languages like Rust, Scala, and Haskell. Especially if you have many millions of lines of code to compile like Google.

However, OCaml has a very fast compiler, comparable in speed to Go. So a more expressive type system is not necessarily leading to long compilation times.

Furthermore, Scala and Haskell incremental type checking is faster than full compilation and fast enough for interactive use. I would love to see some evidence that Golang devs are actually more productive than Scala or Haskell devs. So many variables probably influence dev productivity and controlling for them while doing a sufficiently powered experiment is very expensive.

show 1 reply
pjmlptoday at 7:18 AM

People keep mistaking languages with implementations.

OCaml and Haskell don't suffer from similar pain points, because interpreters, and JIT like tooling is also available.

One can happily develop with one toolchain, and press the red button for an optimised compiled build, when it actually matters.

Also both Swift and Rust have made the mistake to make used of the compiler backend that everyone avoids when they care about build performance, LLVM.

umanwizardlast Tuesday at 11:11 PM

What makes you think Rust’s compile times are related to its type system?

show 1 reply
littlestymaarlast Wednesday at 4:48 AM

This has been a lazy excuse/talking point from the Go team for a while, but in realitiy Generics aren't the reason why Rust and Swift compile slowly, as can be easily shown by running cargo check on a project using a hefty dose of generics but without procedural macros.

Yoriclast Tuesday at 11:22 PM

Last time I checked, Rust's slow compile times were due to LLVM. In fact, if you want to make Rust faster to compile, you can compile it to wasm using cranelift.

show 1 reply