Go 1.18 RC1 is out
groups.google.com
groups.google.com
How is ASAN used in a memory-safe language like Go? Is it useful only if I do uintptr shenanigans?
Hopefully generics alleviates some of this boilerplate.
It will be nice not to have to do that, though, if I get back to Go again.
[0]: https://github.com/golang/go/wiki/SliceTricks#additional-tri...
https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe...
No need to alter the type system of the language, while it’s clearly a syntactical improvement you’re looking for.
(ps: Hi, Ed!)
I'm excited and anxious about generics in go.
Using interface{} where you truly don't know and can't predict the data being sent to you is mostly something that libraries (like encoding/json) have already handled, so I don't have to interact with it much directly.
I think generics are going to have the biggest impact in adding effortless type safety to all kinds of libraries, though.
You can potentially test this for yourself by opening two large open source projects in each language and trying to figure out an issue from their issue tracker.
FWIW I think their complain even if not totally objective still have more weight as compared to non-users who say "I will use Go only when it has real generics/error handling/sum types/21st century features blah..blah.."
If not, there are a lot more non Golang programmers out there than there are current Golang programmers.
I wanted to like go for its crossplatformness, compile speed and relatively small memory usage while still being more practical than C++.
But not having generics and having to constantly check for errors was the two big things that made me bail.
Just to clarify, I don't want exceptions, I just want some language mechanism that changes err, value to be errOr<value>, which if passed to any function while an error will just propagage that to the return value of the function.
Maybe for extra sugar something like errOr<value> | valueToUseIfError. This makes the code nice and thight, mean that I don't have to declare variables to give them one value to pass into the arguments of the next function and still perserve all the nice properties of Go.
Also a nice cross gui library would be nice, but that is a lot harder. Still 20 years on the best cross gui library that compiles once and runs anywhere is Java...
Yes that is indeed the next most-frustrating thing about Go! In the last Go language survey (https://go.dev/blog/survey2020-results), about 90% of people wanted generics and 60% of people want better error handling. So, one down, one to go.
Modern languages like Zig and Rust show how you can do "errors as values" way better. Zig has error returns and stack traces built in, there's no reason Go has to be so impoverished here.
Is that the correct reading?
edit: Wrong, see below
x := val ? foo() : bar()
Versus var x Type // now this is default initialized, which may or may not be a valid state for your program
if val {
x = foo()
} else {
x = bar()
}
Honestly, I'd be fine with it being for initialization only (like the walrus operator)The go alternatives are too horrible to even contemplate, but here goes:
if a {
f(b, d, e)
} else {
f(c, d, e)
}
or var tmp WhatFuckingTypeIsThisAgain
if a {
tmp = b
} else {
tmp = c
}
f(tmp, d, e)
It's hard to say which one is worse, but there is no doubt that the C version is "unquestionably easier to read."Re; your example, what about
tmp := a ? b : c
f(tmp, d, e)
Even in C++ that's likely how I'd write it.Go core are very smart people so I’m sure they have their reasons, but my Lisp-addled brain can’t understand why you’d ever want statements instead of expressions with potentially discarded values.
I sadly don’t see it getting added to Go.
v := if foo() {
7
} else {
11
}
But this means {} blocks now have values, which is weird in a C derivative. Of course, one could do v := func() int {
if foo() {
return 7
} else {
return 11
}
}()
but... that's kind of awful. x = bar()
if val {
x = foo()
}
Is both shorter and functionally more equivalent with the ternary example.I'd still rather a ternary over any of the above options though!
x := func() Type {
if val {
return foo()
}
return bar()
}()Python has some interesting shortcuts too, like being able to do `if 1 <= number <= 10:` to do chained comparisons but I much prefer the longer hand syntax. I have a solid amount of Python experience but no formal math background beyond HS Algebra. I often don't see this shorthand method to compare a range but when I do I always have to stop and decipher it.
I know this thread isn't about Python but I think it falls in line with this conversation. A language that sticks to slightly more verbose syntax for the sake of crystal clear clarity is very appealing.
I think we should respect language creators to keep a clear vision on their language, this way the audience who uses it can either strongly love it or hate it. If you try to do everything and cater to everyone then you'll end up with a worse result IMO.
It's the same way with music. You wouldn't expect a deathcore band to release a country album because a small portion of folks were interested in that, it would alienate their true fans and would likely leave the band internally not liking that decision. If you want to listen to a different style of music then you can pick a different band or genre.