![]() |
VOOZH | about |
We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.
Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.
Follow TNS on your favorite social media networks.
Become a TNS follower on LinkedIn.
Check out the latest featured and trending stories while you wait for your first TNS newsletter.
Rejoice, long at last, all you Gophers, for the question of whether or not the Go programming language will adopt generics has finally, after many years of debate, been answered this week with the acceptance of a proposal made last month.
In this most recent proposal, Golang team member Ian Lance Taylor writes that generics have been “one of the most commonly requested language features” since the language was first released in 2009, but even then, it’s adoption doesn’t come without concerns. Taylor explains the idea of generics in the intro of his proposal:
“Generics can give us powerful building blocks that let us share code and build programs more easily. Generic programming means writing functions and data structures where some types are left to be specified later. For example, you can write a function that operates on a slice of some arbitrary data type, where the actual data type is only specified when the function is called. Or, you can define a data structure that stores values of any type, where the actual type to be stored is specified when you create an instance of the data structure.”
It is precisely this value proposition — being able to write reusable code — that excites some developers and has been behind the push all along.
Adding generics to Golang fixes one of the major things that annoys me about the language! I’ve written a bunch of Go code, and the amount of duplicate / boilerplate code this will eliminate will make it more enjoyable to use.
— Rob (@robdaemon) February 10, 2021
While we don’t need to relitigate the various arguments against adopting generics, now that a proposal has finally made it through the proposal process, a new concern has found its voice among several users: that when presented with a hammer, everything looks like a nail.
This aptly summarizes how I feel about Go generics, as we prepare to be reamed by oodles of “just because you can doesn’t mean you should” generic code.
In baking a code pie, generics should be the salt, not the sugar, but I have concerns about those getting mixed up.🧂💥😵 https://t.co/cQv3YQeqAM
— ian molee (@ianfoo) February 11, 2021
This wouldn’t be the first time, however, that a new language feature was confronted with this fear. When channels were introduced to the language, they too became the feature that, for a time, turned everything into a nail. As time went on, this concern faded, and the hope now is that the same will come to pass with the adoption of generics.
Yeah I brought this concern up with the Go maintainers during the review period and their response (which I agree with) was: you can write really bad code with channels, but the community has done a good job figuring that out. Generics hopefully will be the same.
— Mitchell Hashimoto (@mitchellh) February 11, 2021
Only time will tell, and for now, there is still some time left before all you Gophers will be able to get your paws on the long-awaited feature. At least according to the original proposal, the goal “will be to have a complete, though perhaps not fully optimized, implementation for people to try by the end of the year, perhaps as part of the Go 1.18 betas.”
Now, before moving on to the rest of the world of what’s happening in programming this past week, here’s a video looking at the potential paradigm shifts coming to programming, what with the advent of cloud native everything, in the years ahead.
Before kubernetes: I had lots of fires.
After kubernetes: I had horizontally autoscaling fires— fraq (@0xfraq) February 9, 2021
British Python devs be like “that’s a constructor, __init__?”.
— Jesslyn 🇮🇩 (@jtannady) February 10, 2021
I’m glad Go is finally getting generics because my insurance wouldn’t cover brand-name Go. https://t.co/0NKnI9naJF
— Aaron Patterson (@tenderlove) February 10, 2021