4 ms·
Generics are useful for some purposes. But mostly they can be avoided in favor of simpler language constructs. Most Go developers understand the importance of u
by bugfix-66 4y ago
Generics are useful for some purposes. But mostly they can be avoided in favor of simpler language constructs. Most Go developers understand the importance of using simple code constructs.
There are many experienced developers who (through long experience fighting C++) have come to understand that using a simple language (like Go or C) allows you focus on the algorithms and complexity of the problem you're trying to solve. This is part of the Go culture.
A junior developer might not understand this yet. He's still having fun finding obscure and convoluted contortions of the language that allow him to save little or no effort... not yet realizing that nobody gives a shit and he's wasting his time and the time of his coworkers.
- Tozen 4y ago> developer might not understand this yet... having fun finding obscure and convoluted contortions of the language... not yet realizing that nobody gives a shit and he's wasting his time... There's a major issue of programmers trying to impress each other, by creating complex convoluted monstrosities, and not realizing what is actually important. It takes them awhile to find out that what they have produced was not impressive, and the people that know better, are also not impressed.
- hakunin 4y agoSometimes this advice is taken the wrong way, and people begin assuming that applying any thought to code design is "being obscure and clever" and "finding contortions". Some of the cleanest, most boring code I've written came out of days of contorting and experimenting to arrive at something that looks entirely boring and obvious. On the other hand, when code is quickly and simply added on, it grows into thousands of lines of messy entangled functions and types that are impossible to follow. We gotta make sure that people don't get the wrong idea with this advice. Simplicity can sometimes take more work and cleverness to achieve than complexity.
- kaba0 4y agoIt’s not simple vs complex, it’s being able to express something often quite important about the types or not. E.g. a simple map is not implementable in a sane manner in a static language without generics, because you likely want to know the type of the object you get from there at compile time. There is a reason C has no sane data structures at all, everyone has their own creation which either brings in a big deal of overhead, or employs copy-pasting mostly the same code (which is pretty much what generics do behind the scenes, at least in an overly simplistic manner).
- deleted 4y ago[deleted]