4 ms·
There are two really interesting ideas in Zig that I'd like to find in Go: - The %% operator and the %return expression used to simplify error handling. - The
by ngrilly 9y ago
There are two really interesting ideas in Zig that I'd like to find in Go:
- The %% operator and the %return expression used to simplify error handling.
- The concept of compile-time parameters used to implement generic functions and generic data structures.
- polskibus 9y agoI don't mean to troll here. Aren't generics officialy excluded forever from Go lang roadmap? I'm not following Go much, but that's what I recall from months ago.
- orph4nus 9y agoI think they are still open to it, in a very sceptical way. Basically they are asking [1] the public/users for papers/documents/articles/blogs, describing the use cases of generics in Golang. How would they use it? Why is it required (as in can you not do it easily/better without generics)? Stuff like that. They basically aren't convinced that generics is something they need/want in Go, but if the users can convince them, they will still go for it in the future of Go. [1]: https://blog.golang.org/toward-go https://blog.golang.org/toward-go "I'm focusing today on possible major changes, such as additional support for error handling, or introducing immutable or read-only values, or adding some form of generics, or other important topics not yet suggested. We can do only a few of those major changes. We will have to choose carefully."
- GenericsMotors 9y agoI find it interesting that they're asking the community what the use cases for generics are, when internally Go does support generics for its built-in collection types...hmmm I wonder why?! Maybe because it provides compile-time type safety and reduces the amount of boilerplate that would otherwise be required. Yet they can't see the usefulness outside of this single case? Seems disingenuous to me.
- pjmlp 9y agoBasically it allows for any Gofer on HN and similar forums to defend the idea "they are working on it" without any actual visible action.
- ngrilly 9y agoRuss Cox clearly said the subject of generics is still on the table: https://research.swtch.com/go2017#generics https://research.swtch.com/go2017#generics
- bitwize 9y agoI'd like to see Go adopt Ada-style generics. They are a bit more cumbersome to use than templates in C++, but they allow for reuse of code across instantiations of the same generic that have the same actuals, thus shortening compilation times.
- iainmerrick 9y agoI particularly like the parallelism between %% for errors and ?? for nullables. Very elegant! I'm surprised I haven't seen that done before. It's very much in the Go style of "do the minimum needed to solve specific problems" but at first glance Zig looks much more cohesive than Go.