back

by vardump·12y ago·view on hn ↗
Lack of generics is not really significant. Other advantages in golang are worth much more than this minor deficit. Such as very fast compilation time, goroutines, channels, taggable structs (makes XML or JSON a breeze) and multiple return values -- one can get rid of bug inducing complicated control flow, that exceptions typically cause. Exceptions tend to be very hard to maintain and reason about and they tend to move the code dealing with the errors far away from where the exceptions are thrown. Probably a lot of people disagree about this, but humor me -- I write C++ as my dayjob. Oh, and I prefer golang's "defer" over RAII. It gets most of the job done in a way simpler fashion.

Even when generics are available, they're about a fraction of one percent of code. Other languages have been doing just fine without generics. Even Java has just syntactic sugar compile time type erasure hack instead of the real deal. Those List<String>s are just List<Object>s in bytecode. I don't remember any C-programmer complaining either.

What's very cool about golang in general, is that rather than including all the possible features you can think of (looking at you, C++!), it's more of how few features you can have while still having an expressive and powerful language.

I don't mean to talk down other languages or to praise golang, but I do want to point out one should look at the big picture and not let small details distract. Such as lack of generics.