I liked certain aspects of Go, but lack of generics was a deal-breaker for me. You approached it a way better than I (and many others) did. Instead of arguing on forums you started writing code.
Isn't interface{} a generic?
Show HN: Fo: An experimental language which adds generics on top of Go
41–50 of 125 posts
Re: Show HN: Fo: An experimental language which adds generics on top of Go
#42Interesting, now all you need to do is add exceptions :)
Golang already has an exceptions-equivalent construct in the shape of panic() and recover(): https://blog.golang.org/defer-panic-and-recover You’re free to write exception-full code using those constructs, although the community tends to use error return values for the most part.
Re: Show HN: Fo: An experimental language which adds generics on top of Go
#43Interesting, now all you need to do is add exceptions :)
Perhaps. But if Go itself adds exceptions they're going to have to catch a MassDeveloperExodusException. The standard reason I see for people wanting exceptions in Go is because they're sick of writing the following: ```go thing, err := things.New() if err != nil { log.Fatalln(err.Error()) // Or `return err` } ``` But I would argue that it means they're not writing idiomatic go. A good reference for the value of erro…
Re: Show HN: Fo: An experimental language which adds generics on top of Go
#44Author here. I've been working on Fo part time for 4 months. Feel free to ask me anything.
package stack[t]
type Type []t
func New() Type { return Type{} }
...
Then it can be used so: import s “stack”[int]
var s1 = s.New()Re: Show HN: Fo: An experimental language which adds generics on top of Go
#45Earlier quoted context omitted.
Perhaps. But if Go itself adds exceptions they're going to have to catch a MassDeveloperExodusException. The standard reason I see for people wanting exceptions in Go is because they're sick of writing the following: ```go thing, err := things.New() if err != nil { log.Fatalln(err.Error()) // Or `return err` } ``` But I would argue that it means they're not writing idiomatic go. A good reference for the value of erro…
Eh, rust’s result type has shown that you can do the same thing in way that is more type safe and more ergonomic.
Re: Show HN: Fo: An experimental language which adds generics on top of Go
#46Author here. I've been working on Fo part time for 4 months. Feel free to ask me anything.
Did you consider parameterized packages? The idea is you can declare a set of related objects/types/methods as well as have concrete type specific initialization. E.g. package stack[t] type Type []t func New() Type { return Type{} } ... Then it can be used so: import s “stack”[int] var s1 = s.New()
Re: Show HN: Fo: An experimental language which adds generics on top of Go
#47Earlier quoted context omitted.
Eh, rust’s result type has shown that you can do the same thing in way that is more type safe and more ergonomic.
Sure, if I had proper sum types + pattern matching in go that'd be great. I'm just saying that I'd prefer the status quo over adding exceptions specifically.
Re: Show HN: Fo: An experimental language which adds generics on top of Go
#48Re: Show HN: Fo: An experimental language which adds generics on top of Go
#49You really missed the opportunity here to call your language Foo
Re: Show HN: Fo: An experimental language which adds generics on top of Go
#50Earlier quoted context omitted.
Isn't interface{} a generic?
No, interface {} is more like void pointers in C and C++ or Object in C# and Java. It can hold values of any type. One of the major selling points of actual generics is that they provide type safety, but interface {} doesn't provide that.