r/ProgrammerHumor • u/NeverMakesMistkes • Jun 24 '18
JavaScript is getting real tired of your jokes
Enable HLS to view with audio, or disable this notification
12k
Upvotes
r/ProgrammerHumor • u/NeverMakesMistkes • Jun 24 '18
Enable HLS to view with audio, or disable this notification
View all comments
Show parent comment
8
u/b4ux1t3 Jun 25 '18
I can try. I'm going off of a blog post I read a couple years ago, so things might have changed (or the post might have been wrong).
The gist is that while, yes, you can figure out at compile time what the generic is, you still have to take into account how large a piece of data is when you build that binary. If you can make some assumptions about the size of the data structure, you'll likely see higher efficiency in the compiled binary.
This is why interfaces make sense, at least in Go's case. It doesn't matter how big your data structure is, you'll always know what its interface footprint is, so you can make those assumptions at compile time and see those speed gains.
In the end, it all really boils down to how Go was implemented. If they had gone a different route, maybe they would have made it easier for them to build generics into the language. As I understand it, though, the way they built Go makes this kind of problematic.
In my (completely humble) opinion, if it were easy to put generics in Go, someone would have forked it by now and implemented generics. All that said, I just write in Go. I'm by no means an expert. Everything I've parroted from that blog post "makes sense" from my point of view, but then some people think it makes sense that the Earth is flat.
I'll see if I can't dig the post up. I don't even remember who wrote it.