Go 1.22 is bringing about a new future for the language.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
go 1.22 has finally dropped and with it we have a bunch of new and exciting changes this release marks a huge milestone for go Bringing about a new future for the language the first category of improvements that this release brings is for looping in go with the major one being a fundamental change to the way that Loop variables are scoped I have another video that goes into this change in Greater detail but to summarize it changes the loop variable to be per iteration scoped rather than scoped to the entire Loop by doing so it fixes one of the most common mistakes you can make in go as well as this change 1.22 also brings the ability to range over an integer we can do this using the following code which will iterate from 0 to 9 the last change to Loops that this release brings is a new experimental feature for ranging over function iterators this feature is similar to generator functions in other languages allowing us to use the yield keyword to turn a function into an iterator the second category of improvements that the the 1.22 release brings is improvements to both CPU and memory performance the runtime now keeps type-based garbage collection metadata nearer to each Heap object which improves the CPU performance of go applications by 1 to 3% additionally this change also reduces the memory overhead of the majority of go programs by approximately 1% by duplicating redundant metadata the nice part about this Improvement is that it's mostly provided for free without any intervention on your end there is a consequence of this change that's going to affect programs that use assembly instructions that expect memory addresses to be in a certain alignment however the developers expect this to be a rare recurrence as well as improving the runtime performance the compiler now can use profile guided optimization or PJ in order to see an improvement between 2 and 14% pggo however doesn't come for free and requires you to profile your application whilst it's running in production if that's something you want to know more about then let me know in the comments down below and I'll do a video on it go 1.22 brings about a number of changes to the standard library that will Define the future of the language the most significant of these changes is the first ever V2 package inside of the standard Library this is the math Rand slv2 package which brings about a number of important changes these changes include faster algorithms improved interfaces idiomatic naming of methods and functions and a new generic function called n which will take any integer type to create a random from because this method is generic it allows us to easily create random numbers for types that we weren't able to do so before such as generating a random time do duration as well as our first ever versioned package we also have a brand new package called go/ verion this package is used to both validate and compare Go version strings as well as these changes there's been a number of minor ones added to various different packages throughout the standard library of this list the one package I think most interesting is the slices package which now provides a new function to concatenate multiple slices together the the biggest change however is for functions that shrink the size of a slice such as the delete method these functions will now zero the elements between the new length and the old length whereas in previous versions of go these elements would still remain in memory and be accessible in the existing slice for all other minor changes I recommend checking out the documentation to see if there's anything that interests you the last and perhaps biggest change that go 1.22 brings is the enhanced routing features of the net / HTTP package I covered the proposal for this in another video about 9 months ago and with 1.22 it's finally here this change enhances the HTTP serve MX type allowing us to easily specify routes with both HTTP methods and path parameters because of this change it now makes the standard Library viable when it comes to complex HTTP routing this means you'll no longer need to use a third party dependency such as gorilla mqi or Fiber I for one am pretty happy for this change having the language be more resilient to third party dependency is always a good thing now whenever I need a simple HTTP server the standard library is more than enough I'm interested to know your thoughts however are you happy with the changes that 1.22 brings or perhaps there were some other features you'd have liked to seen either way let me know in the comments down below I want to give a big thank you to my newest Channel member the 54mm thank you for supporting the channel and allowing me to bring my content to hundreds of thousands of people around the world a big thank you to everyone else for watching and I'll see you on the next one
Info
Channel: Dreams of Code
Views: 142,327
Rating: undefined out of 5
Keywords: golang, 1.22, update, go, programming, slices
Id: HXdBwGRjv_4
Channel Id: undefined
Length: 4min 31sec (271 seconds)
Published: Fri Feb 09 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.