Golang Generics is Officially HERE!! (Full Tutorial)
Вставка
- Опубліковано 15 лип 2024
- Golang Generics is Officially HERE!! (Full Tutorial)
Golang Generics is finally out. It will make it easier for new and experienced programmers alike to use generics in Go. This video gives a rundown on the 3 main features of Go generics.
-Type parameter
-Type inference
-Type set
Enjoy watching!
--
Golang Dojo is all about becoming Golang Ninjas together. You can expect all kinds of Golang tutorials, news, tips & tricks, and my daily struggles as a Golang developer. Make sure to subscribe if you look forward to such content!
Get Your Golang Cheat Sheet! - golangdojo.com/cheatsheet
Git repos & notes - golangdojo.com/resources
Golang Basics - • Golang Basics - Instal...
Golang Informative - • How much do Golang dev...
--
Timestamps
0:00 - Intro
1:01 - The Go Generics
1:32 - The 3 Main Features
3:14 - Type Parameter
6:01 - Type Inference
8:56 - Type Set
12:43 - Outro
--
#golang #goprogramming #golangdojo - Наука та технологія
📝Get your *FREE Golang Cheat Sheet* -
golangdojo.com/cheatsheet
The cheat sheet doesn't seem to include generics. Am I missing something?
This channel is exactly what I’ve been looking for; thank you
After this video I am officially moving from Typescript to Go.
Genetics are the necessity nowadays. Even the PHP crowd is waiting for them for a long time.
Excellent!
This really helped me to understand how generics work in general - I always thought it to be some kind of a "higher level" thing, but it really is just a placeholder in a way, allowing generalizing functions, but also constrain the types the function works with.
very crisp and clear explanation of generics concept. thanks!
Very well explained. You're not only a golang Ninja ... but also a teaching Ninja. Thank you very muvh.
I'm learning go and all these new things are really exciting for me
Let's go!!!, I will watch this one on my Java/JavaScript job 😂
Great content! Thanks for the channel!
Thanks for your sharing!
It was crystal clear. Thanks!
A very good instruction in go generics. Well done buddy.. 🥇
Excellent video. Succinct and well organized. Thanks for this.
Thanks for this. Really good content
Finally!!!! 🔥🔥
thanks for this video, it is quite clear 👍
Good explanation. Thank you for sharing your knowledge.
Amazing video!
Great video!
amazing explanation, ty
Cool vid, thanks for the help
Golang is improving so fast. That is great.
I'd love to see a generic binary tree written in GoLang.
thank you bro
finally!!! :)
thanks!
Im learning Go and by coincidence started looking at generics today. Downloaded v1.18 and did some trials. Works well but my vscode ide has not caught up and shows some potential errors which are not real for the new compiler. Anyway, nice tutorial, thanks for your video 🙏
I think, you need to update gopls for your vscode. Ctrl+shift+p then choose Go: Install & Update tool, then choose all. I am not sure to fix your errors, but please try.... have a nice day!
@@quocnho thank you. That worked for me
something I've recently done was needing to create a certificate generation function that could accept both RSA keys and EC keys, I did it slightly differently where it could accept any type and if it didn't mach a supported type it would error out. Now I should be able to go back and make it more strongly typed thanks to Generics
Does allowing multiple types as an input have an effect on performance?
Great tutorial overall! Why did your min(sf, 0.2) return 0.3 (incorrect) when the generic type was defined as ~float64? This problem did not exist when the generic type was defined using "type set". Is this another example of the compiler not being compatible with the latest language additions?
Thanks as usual! My only concern though is keeping golang minimally sufficient and succinct. That's what makes it awesome. When I see your examples, my first reaction is okay, soon someone will ask for overloading the operator
Let's hope it doesn't get to that
There is always a balance but generics were needed. I program a small app and option 1: Making X functions which do all the same
2: generics.
So thank god we got generics.
we want more videos basic golang I'm from India waiting
Which environment are you using to dev? And which plugin allow look the var like it appear?
The inclusion of generics has made me more interested in the language because support for polymorphism is a pretty key tool in alot of codebases I work on. Why it took so long to implement Generics in GoLang is a mystery to me.
You've just changed my mind about Generics in Go!
reinstall gopls with 1.18 to see the error on IDEs, which use it.
Goland is cool!@
Is 1.18 production ready? I am using 1.17 on my working project but it on early stage, I want to switch version to 1.18 but I'm scare of reliability. Thank you
I wonder, is the future of all newer languages upgrading to the robustness of older languages? And we enjoy this "new" features 😅
Insta sub - just for funny versions of go mascot.
Great video! Also, if you don't mind me asking, what is your IDE theme?
I'm also curious.
Dude... I sorta understand it as budding noobie-Golang-coder. But I have to re-watch it again when my knowledge and experience had matured. So Generics is how it handles, sorts any data types. Hmm... 🤔
Are you going to update the cheat sheet with Generics?
How to add different generics to param 1 and 2
really helpfull video! 只是,怪腔给怪调开门--怪到家了!
Hey, great explanation on generics, thank you! Are you planning another Video with generics in combination with Interfaces? Just asking for a friend… 😉😉
he literally explained it on the video
What about the "comparable" type ?
I have to say, I doubt generics will make much of a difference in GoLang's popularity. GoLang is popular for a number of good reasons:
1. Unicode(utf-8) out of the box.
2. Simple to build.
3. Interfaces. i.e. a simple object model.
4. Concurrency.
5. Memory safety.
6. Higher order functions.
7. Code that's not cluttered with boiler plate. Very clean and standard source code bc of enforced standard formatting.
Generics might attract a few curious Java and C# programmers but I doubt they'll hang around long.
I almost forgot... Sane IO and slices.
Kotlin Rust Swift and many other modern languages have all those things you mentioned AND great generic systems. Is there anything else about Go?
@@michaelnajera7958 Rust code is pretty much unreadble if you didnt invest a lot of time into lang. Swift/Kotlin has diffirent usecases atm. So I dont get your point
“Rust code is pretty much unreadable”
That’s just you’re opinion.
“Kotlin/Swift have different use cases”
Kotlin and Swift are general purpose languages just like Go or Python.
You still haven’t answered my question. What more does the Go language give you that those other modern languages don’t?
Well kinda. You can't use them on struct methods which rules out about 60% of the use cases where I want to use generics.
Goland vs VSC ?
What IDE are you using?
He's using GoLand (by JetBrains) with High Contrast theme
is this dubbed in english?
(edit)Actually after a week to work through some, not so cute examples I have found a very workable generic pattern that works for even complicated generic types.
Has anyone tried generics in Golang? I mean besides the cute examples! I can see this being the straw that broke the camel's back for some people trying GoLang. Talk about a half-assed approach to generics. Why would they produce such a terrible feature and then release it?
I used generics in Java, C#, C++, OCaml, and several other languages and I've never come across such an odd implementation of generics... I think they should have stuck without generics.
I'm beginner in Go, and I didn't know what generics is, but I heard everyone was looking forward to their releasing. Now I see and it looks like Go is losing it's tight types constraints and becomes TypeScript with their dope ANY, and everyone is happy about.... but it's awful, isn't it?
So are you ripping off "Let's Get Rusty" style or is he ripping off yours?
Generic types or Generics 🙄
No front but I really can't understand why Go broke generics convention and used [ ] instead of . I don't care if is used in some other way but this looks unnatural and irritating for everyone coming from any other language. Many features differ between languages but for all languages I know generics are everywhere syntactically similar if not equal.
yes, I agree with you completely. Just stupid arrogance on the part of Google and their engineers. Other than the concurrency parts, which are incredibly elegant, the rest of the Go language is quite ugly.
Not to mention the error handling, like, is there something wrong with try-catch?
@@thangnt2945 I don't know GO error handling and how good or bad it is. But this is a but different. Many languages differ in error handling. For example rust returns an combined type with result and error, or c stores error states globally. The point is that nearly every other language that supports generics and could have been a inspiration for GO generics uses . Using something different is just irritating and unnecessary complicated.
Because it would have required a breaking change:
a, b := c < 10, d > 20
These assignments have always been a totally valid Go code and, if you look carefully, you can see that they contain the conventially generics syntax (< , >) that would have broken the language lexer, if they had pursued the decision to go with it. That’s why they decided to go with the [] implementation.
@@nicogorr8440 is not a valid generic bound. Both could have used the < xxx > syntax. Besides there is a core context difference between:
VARIABLE ASSIGNMENT CONDITIONS
and
TYPE_DEFINITION CONSTRAINT BODY
You definitely don't quite fully understand how lexers work and what's a potential conflict and what isn't.
tried to listen for three minutes, content is great, but the accent is terrible
go is inferior to rust