Go 1.22 Released!
Vložit
- čas přidán 8. 02. 2024
- Recorded live on twitch, GET IN
/ theprimeagen
Become a backend engineer. Its my favorite site
boot.dev/?promo=PRIMEYT
This is also the best way to support me is to support yourself becoming a better backend engineer.
Article link: tip.golang.org/doc/go1.22
MY MAIN YT CHANNEL: Has well edited engineering videos
/ theprimeagen
Discord
/ discord
Have something for me to read or react to?: / theprimeagenreact
Kinesis Advantage 360: bit.ly/Prime-Kinesis
Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
turso.tech/deeznuts - Věda a technologie
Prime : "Go is one of the most productive languages I've ever used"
Also Prime, 30 seconds later : "I don't know the syntax of a for loop in Go"
*_- PROGRAMMING 100 -_*
I guess because you'd almost always use range for loops in Go.
The duality of Go programmers. Highly concurrent code? Sure. Message passing? No problem. You want me to write a for loop? One sec, looking that up in the docs.
Hahahaha
Just think of C for loops and some range for each! Lol
Weirdly, I think this is one of the great things about the language.
It's so simple that you don't even need to memorize the details to jump back in and get up to speed in a few hours.
They put "for" in quotes because that's the grammatically correct way to do it. The sentence makes no sense without those quotes.
Ikr it's like what stackoverflow does for highlighting words, that was obvious
The sentence would make sense if the for-loop was hyphenated
@@k225 also that, yes :)
The way I like to do it is to switching to a mono font / putting the text in a pre tag or code block.
I just tell people "english is not my first language" and let the readers decipher which for was used to imply a for loop in a for example section for for loops.
I didn't even want to like Go, but it just happen after getting familiar with it. I was simply experimenting around with it for the sake of learning, and I figured it would be beneficial to at least be familiar with it since its popularity was growing, and it ended up being one of the first languages I reach for when starting some new project where it makes sense.
Same here!
The "for" loop changes apply to all loops, not just "for range"
The little aside on mocks at 9:40 is great. Its one of those things that can really click in your brain sometime in the transition from jr to mid level and just feels so powerful because suddenly all your code *feels* testable when its likely not. I think Prime is on point about separating the i/o from the processing wherever possible to make mocking unnecessary or minimize where it is required as he also correctly states that sometimes its not possible to entirely separate them or it may be possible but doing so is extremely difficult without significantly complicating the design. Aim for those idealistic principles but be willing to toss them when its clear they are not benefitting you.
+1.
The only use case for mocks for me is when you want to test whether your class correctly calls callbacks passed from other parts of your app.
Then you just don't care and mock is fine.
I hate mocks so much. It seems good on the surface but quickly becomes a huge mess. Two huge issues: 1. you tie the implementation very closely to the tests, so changing implementations breaks a lot of tests, 2. any time your code is changing state you cannot inject more mocks between function calls from the test, and a stateful fake will save you a lot of duplicate test code
the name... *some long ass monologue* AGEN never gets old
well, recently i've read something like that in our codebase:
for(int i=0; i
Potentially they did something to i inside the for loop? Either way, if so, that should have been a while loop
paid by the line
@@y00t00b3r since the "if" would be the same amount of lines
the line is just a bit shorter
Well I was just checking the go changelogs and was thinking - "I remember Prime was recently working with go, I hope he will make the video on it as we go some new shiny toys". I was dead on point. Let's Go 🏎🏎!!
coverage is great for indicating whether a new block of code has even been tested
But it doesn’t care if said test is meaningless
Lets GO from now
My take on testing and coverage: test the validity/correctness of features/subfeatures rather than look at some arbitrary numbers. In cases like handling secrets such that they don't leak etc, you could argue for 100% coverage for these certain code blocks though.
his hair is transparent due to green shades XD
"I'd rather type a little bit more than have slow compile times" rust in shambles; you type more and get slow compile times🤣
13:05 test bros will see a test to evaluate if adding two numbers actually adds them, and act like that's normal and expected in the development cycle
kinda agree with having coverage. since it's unit testing (which obviously the easiest part of auto testing) it's better to cover not just 40% which probably u mostly concentrated on during the implementation but also on some edge cases which may behave unexpectedly. And the big + is that testing requires some code optimization and refactoring to make the code testable
Coverage is great as a quick reminder if you forgot to add tests or something. It should not be a requirement.
Best part of this video was I learned what sqlc is. Gonna make my life so much easier !!
I am loving the Rust range syntax, it has a simple way to make the range inclusive by adding “=“ before the end number. Go and Rust are the two languages that I feel everyone should try to use and will make production ready code - where Go doesn’t need external dependencies and Rust will give you some built in safety, but you need to understand memory management.
I like what I see in Zig, but I feel that it is still too early and the language needs to mature more before it is fully production ready.
Let’s GO!
Both Rust and Go are IMHO shaping the future of development in very positive ways. I'm currently considering rewriting a lot of my Node-based projects using one or the other depending on which is more suitable to the task. When deciding which to use, the impact of garbage collection on the running process will be the driving concern. Roughly 90% of my projects would not be negatively impacted by garbage collection so these would definitely be a candidate for using Go whereas the remaining 10% would benefit from Rust. Yeah, I'm really excited about this even though it is going to be a lot of work. Oh the sacrifices I have to make as a software engineer LOL. Thank you, Prime, for your very interesting take on this Go release. Much appreciated.
hummm and what about Hare, Zig ...
Literally never heard of Hare so I think it’s safe to say they’re not
Rewrite is usually considered a bad idea unless the scale justifies the cost savings it brings
Thanks for the upload.
It would be interested how effective mutation tests are in go. Next topic I will look into :)
@ThePrimeTimeagen You always seem to consider Java slow, but if I'm not mistaken optimizations such as that PGO you mention in this video can be done at runtime on the JVM. And hot paths can change under some circumstances, right?
Let's Goooooooo
A data structures module would be nice
Most tests should not be unit tests. Integration and end to end tests are way more helpful. I find checking before writing a test if it will make release faster and with more confidence. If it does, it is a good test, if it doesn't it is technical debt.
exactly. too many useless unit tests just make the codebase more brittle. need to refactor some code? congratulations, now you need to rewrite 27 unit tests. Result: desire to avoid refactoring.
100% code coverage is choosing "green checkmark culture" over actual thinking.
Yeah testing trophy over testing pyramid any day of the week for most web apps.
slog is pretty neat
On test coverage and 'how to write tests' you're inline with CD guy :D
The test coverage thing is really easy. Test 100% of desired behaviours, not 100% of lines of code.
Yes, but counting line coverage is easy for a test coverage tool to reason about. I wouldn't know how to automatically check for behavior coverage.
The "for" loop thing used to be an interview question that was supposed to "get you". Thanks god its now gone.
Prime slowly morphing into theo with that hair. Did he lose a bet?
yes he did, im not sure what bet, but he said in previous video
@@ninocraft1 2000 subs in a single stream.
Yes, but he needs to keep the blue hair. Looks good.
@@user72974no
“Go full Ada”. Yeah, Swift has that ❤
for number in 1...10 {
print(number)
}
The day Swift gets big in the backend will be the day of celebration for the dev community
Mock's are fine if you are building a large project, it speeds up test completion time instead of awaiting real requests. I hate personally when a project's test takes forever to run because of the amount of requests it makes. Mocks make sense for unit and integration tests but not E2Es and are easy to write especially with copilot or ChatGPT.
the alternative to mocks is not real requests, its to use Stateful Fakes
I loooooooove the changes to the router!
18:02 this would affect SIMD instructions, but who even does that in go?
hell yeah
Jai has 0..10 and I love it
(though I do like the Rust variant of it, where 0..5 is 0,1,2,3,4 and 0..=5 is 0,1,2,3,4,5)
Nim has 0..5 for inclusive range and 0..
At the risk of bikeshedding, Odin has ..< and ..= and I think they are the most intuitive range operators I've seen
Beast!
lets go... !!! the more i see go, the less i like rust. there is a quality of readable and working today VS maybe working tomorrow.
GooOOoooOOoo
Me working on a Go codebase that hand roles some assembly pointer stuff 😱
I'm sorry for your loss
I've called data mocks "stubs" in the past. Its better but only one step better. Its best to just do integration/functional testing as mentioned.
Honestly, Go is looking more and more appealing to me every day. How well does it handle ODBC db stuff? A lot of the work I do is db oriented, but with a db that I can only access via an ODBC driver (or jdbc, but meh).
I LOVE ITERATORS
That's cool
Been learning go myself and for a time been asking myself why learn typescript if you know javascript just for the adding types if the could just add types to javascript.
There is an hour long video about coverage testing in this Go 1.22 release video lol
came for go stayed for blue hair.
Please do a frontend masters test course
I’m very excited about range-over-function iterators. Go is the most productive language I’ve ever used, and it’s getting *that* much nicer
Serious question, why should I choose GO over languages like C# or Kotlin? Is the syntax that simpler compared to these? Dosent Go also have a runtime and GC, is GO really faster than optimized C# ?
Go is simpler and compiles to native with better support (although they're working on it in C#, it'll never have full native AoT support). This matters especially for places where binary size is important or you need a fast startup time (serverless).
With that being said, no go isn't faster than other languages like C or C++ might be. Its strengths are ease of use, native binaries and fast builds.
@@arnontzori
"(although they're working on it in C#, it'll never have full native AoT support)"
> Doubt
@@diadetediotedio6918 doubt what? That they're working on it or that it'll never have full native support?
Because both are statements Microsoft made lol
.net 8 already has good NativeAoT support just in case you were wondering
@@diadetediotedio6918 what part are you doubting?
because "goroutines" and "channels"
Vendor reminds me of php composer . So runtime plugins should be easier to use
you can have unix domain socket on windows but ok...
Prime, you're a Windows user. You may not main it but everyday you stream on a Windows computer, you use it more than most Windows users 😂
Im waiting go arena, i hope they realese it 😊
👀👀👀
No comment on rust release?
"I think I've become a GO lover" oh so that's why the Go-colored hair.
Agree 100% RE: test coverage... Quality > Quantity... coverage = quantity... #math
40mins again… surely Prime will be up for Podcast awards soon right?
Coverage is more important in mathematical /scientific libraries, data utilities and such. I expect 100% test coverage for such libraries.
rangefunc smells like PHP Generators 🙈
I dont know what happened. I saw a video with the title "Why Go Sucks ...." uploaded few hours back which was taken down later . I hope i am not alone 😂 who saw it
maybe that was the live stream?
A 100% test coverage is desirable, it just our tools are dumb. We should have language specific coverage libraries which know what do not needs tests. Like empty private constructor in java, and so on. So it is not that aiming for 100% is bad, we just have a bad definition of 100%.
Vendor your own npm leftpad
yo, did you know you also have a main channel?
Dude, php has built in development server in it's binary :P
Golang color hair :D
Coverage: 100% Great tests > 40% Great tests > 20% Great Tests > 100% Poor tests. 100% Poor tests just waste everyone's time.
wastes*
waste*
Can someone decipher this?
@@onrir good tests are better than bad tests, and a good coverage of good tests is great, but a good coverage of bad tests is bad
@@JeremyAndersonBoise thank you... English is hard.
Still missing Options and Enums
Praying for enums in Go!
Do you want Enums or do you want pattern matching?
@@TheAcademik At least I would love to have enums as a set of options. At most, I would love to have an ADT, i.e. sum-type, but not sure if that is possible for Go.
Yet another useless feature to bloat the language.
@@youtubeenjoyer1743 Why just not switch to Brainfuck then? Very simple language, with a tiny footprint.
@@youtubeenjoyer1743do you live under a rock
0..10 we have that in Ruby :)
no mocks? how do you test with external resources like databases? do I need to spin up a database instance for every test? mocks are very useful if used correctly
12:20 thats "functional core, imperative shell" pattern. Test the core, it doesn't require any mocks, just call functions with input and test is done. And you dont test the shell, its a waste of time
I'll admit Go is a fine language - it just has a very inelegant syntax.
Test coverage is the worst ever. I have seen tests, that dont test anything valuable, just to reach the 100% mark. My rule of thumb is, write tests to everything that can get you fired and even this doesnt mean it has to be 100% coverage.
Oh looks like go is getting a lot of odin features, nice!
Regarding test coverage - you CAN'T do 100% test coverage all the time. For servers, you will have fail paths that only get executed when an external service is down. Even if you've localized the external service comms to one module, THAT module will be missing a bunch of path execution because of external dependencies.
Personally, I find the golang cover tool to be most useful when I am working on some unit tests and I use the colourized HTML view to highlight which blocks are executed and which are not, then I choose which to write tests for and write them then. I also write tests when a complex computation or interaction is required, and also if a bug is reported I write a test for that.
8:04 anything dogmatic in programming (and life in general?) is bad
I'm a Java developer. Go is very sexy for me lol
I'm a Go developer. Rust is very sexy for me lol
@@maximus1172 I'm a Go developer, ex Rust amateur. Go is very sexy for me lol
U tellin me
Dammit, I have been convinced
He a baddie for sure
ewww, remember kids, never use Go for back-end when C# exists
bro did you use RGBA to color your hair 😂
Test coverage is like money. It's not that meaningful as long as you have some
Wow, range loops! Go almost arrived at the 21st century with this release.
It's had range loops forever tho?
Who ever said 100% coverage by itself was the sole criteria?
Here is the thing: If you have code in your project that has never been run then:
1) You have no idea if that code behaves correctly if it ever gets run.
2) Or, it actually never gets run run and should not be there anyway.
Ergo you need 100% coverage.
However, that has to mean coverage by meaningful tests.
In the avionics work I have been involved in that was mandatory. And yes including checking when and which way every "if" statement jumps. If anything could not be tested for some odd reason there had to be very good reason for it, it hand to be reviewed by three engineers and signed off.
Of course if one can only afford or is only prepared to do a half baked job then some trade off between percentage of coverage and meaningful testing has to be made.
Is Go like C# without a heavy runtime and compiling to native?
not really no
C# allows compilation to native now, but with limited reflection support. Granted, it builds the runtime (or a minimal subset required to run the app, if I understand correctly) into the executable. That said, it’s still not going to be as minimal or as performant as Go, which is ground up designed for quick and native builds, imo.
Still, C# is a damn good language
@@leetaeryeo5269 Yep. Am coding C# on .Net 8. I see the pulling in patterns similar to the borrow checker and chasing native speed with AOT.
It's not very similar to C# at all.
You don't even have proper dependency injection in Golang
Sorry but := is a deal breaker for me 😅
Don’t care, we’re using Odin over here 😎
TypeScript, Go, Rust... ❤ Polyglot programming.😊
You asked for another language that has HTTP handling as part of the standard library. Well, there is PL/SQL (ptui).
The guy who proposed workspaces: czcams.com/video/wQglU5aB5NQ/video.html
Fucking Babel 😆
You are officially my technical father figure.
Daddy...
Hot take: Mock is not useless. Most of the time people just struggle to draw domain boundaries and then when their tests suck they blame it on the mocks.
The boringly practical way of go is the sexiest way to program to me. I don't even know why that's controversial. Also wtf does 100% end-to-end testing coverage even mean...
Its controversial because some people like complicated things
Practical way? Look up the code of kubernetes, a complexity and verbosity mess. People who love Go must be some hobby programmers who never worked on a big project with a team lol. Writing Go may be easy, but without some nice syntactic sugar its a night mare to read Go code of a bigger project. The simplicity of Go is a lie, because with simplicity in the language the code gets verbose and complex really fast. Both things are not good for reading code.
@@ITSecNEO I can mainly feel these pain points in error handling and type conversions, but those are issues that could realistically be addressed individually.
I'm pretty sure they will add both struct unpacking and the chain result operator into the language one day ™.
The rest of what you're describing honestly just sounds like technical debt.
It seems to me that guys at google would write a language with big projects in mind, but I've also never worked with a codebase the size of k8s(that's a little bit of an extreme entry level requirement), so what do I know...
@@nexovec Yes maybe they will add new stuff, but the 1.22 release is already a joke for me. Error Handling is one of the most requested features for years but they give a f. So how long should we all wait until Go gets really usable? I like Go because its a lot like coding C, just better. But at the same time I feel the language is not good enough to compete nowadays. Why should we wait for a language to be complete If we already have better alternatives? I hope you can understand my frustration and my point.
Working in a big codebase of Go is Not a great experience, I promise. If I remember correctly, kubernetes needed to implement a type system on top of Go because Go's Type system is not good enough by default.
go was supposed to be a very simple language but now it looks to me like they are adding more and more syntax sugar and new features like any othert language. in few years go will be like java. xD
The problem is they add features which are completely bad designed. At the same time they dont have some basic useful features every language should have.
Make Go more like Ruby, not Python! ;)
you need tests to make sure your code is correct? sounds like skill issue to me /s
20:05 Windows? More like Losedows KEKW