Hacker News new | past | comments | ask | show | jobs | submit login

Generics are architecture astronomy?

This is parroting anti-intellectual nonsense.




Generics as done in C++ templates lend themselves to that.

Inheritance as done in most OO systems does likewise.

You will note that the core Go team has a desire to add generics. However they also feel that it is a potential Pandora's box.


Interestingly though, some of the worst excesses of overdesigned architectures in Java happened before Java even had generics, and heavy use of interfaces was a standout feature.

So Go has absolutely everything a true architecture astronaut needs. In my view, the big difference is cultural and has nothing to do with language features.

Also, the lack of generics often forces you to use reflection to avoid code duplication, which makes for very complex, error prone code.

As an example consider the sort package in Go's standard library. Here's what they had to write in order to generically swap two elements in a []interface{}:

https://golang.org/src/internal/reflectlite/swapper.go


I suspect a problem with Java is it's culture and ecosystem evolved in the early 90's when memory, disk, and processor speeds were doubling every few months.

Go in the late 2000s after Amdahl's law had been bitch slapping everyone for 10 years. Network bandwidth increased but laterncy didn't. Processor transistor counts increased but clock speeds didn't. Memory increased but memory bandwidth didn't keep up.


C++ templates are not the gold standard of generics. In fact, they are a glorified text substitution system, totally broken and flawed.

Generics are still absolutely necessary for ANY serious programming language. They are required by the DRY principle. Algorithms must not need be repeatedly implemented for every new data structure. To say that generics are astronaut is simply unprofessional.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: