5 ms·
Love go as a platform.. self contained binaries have been a miracle for ops..but have a few big hangups about using the language full time because of the sucky
by geenat 4y ago
Love go as a platform.. self contained binaries have been a miracle for ops..but have a few big hangups about using the language full time because of the sucky ergonomics.
* No optional/named parameters. Writing a whole function per parameter for function chaining is excessive. This would not be difficult to add to the compiler (i've done it and have seriously considered using the fork) but it seems like the team is just stubborn about adding stuff like this.
* No default struct values. 0 isn't good enough in real world scenarios.. have fun writing BlahInit(...) for everything.
* Would be nice to get the question mark syntax for error handling. Error handling shorthand for if err != nil would also be very welcome.
- doctor_eval 4y ago> No default struct values I love Go too but this does drive me nuts, especially when parsing JSON and wanting to set sane defaults for missing values. Like, for example, booleans that should default to "true".
- xvello 4y agoFor that use case, I think that you can assign your defaults before passing your target struct to the unmarshaller. The unmarshaller will iterate on the json input and set struct fields when json fields are found. This means that struct fields that don't match the json are ignored, and values you have set before will be left as is.
- doctor_eval 4y agoWhile true, this approach doesn’t work for nested structs, which are instantiated by the parser.
- icholy 4y agoWrite a DefaultFoo function which returns a Foo with default values set. Then unmarshal into that.
- baby 4y agoI think if Golang would have been invented a couple of years later it def would have had sum types. But then, Rust probably wouldn’t have had its insane tooling that is most likely inspired by golang
- kaba0 4y agoIt’s not like sum types weren’t known a decade before that. Or generics. They just didn’t care.
- randomdata 4y agoI doubt it. It seems quite apparent that Thompson just wanted to take another stab at creating the next generation in the B -> NB (New B) -> C -> Go family tree. It would have likely been named D if the name wasn't already taken. Pike slapped his Newsqueak's CSP paradigm on top and the rest is history.
- pjmlp 4y agoGo is basically an AOT compiled version of Limbo with the method syntax and UNSAFE package from Oberon-2, and they stopped there.
- 0xjnml 4y ago> I think if Golang would have been invented a couple of years later it def would have had sum types. How to combine sum types and a precise garbage collector?
- IshKebab 4y agoI agree. I wonder if we'll start to see other languages target the Go platform, like with the JVM.