3 ms·
> There's also the fact that the array (I'm guessing) of bytes diverges from every other language to put them in front of the type which looks like crap. It do
by __david__ 13y ago
> There's also the fact that the array (I'm guessing) of bytes diverges from every other language to put them in front of the type which looks like crap.
It does look weird at first—I thought the same thing. But after writing some code with it, the design has a nice simplicity. When decoding C types, you have to sort of go back and forth "int * x[]" (an array of pointers to int) but in go it's always one direction: "int * []x". The type is always grouped together and that ends up being much easier for humans to parse.
Ditto for putting the return type after the function args. Seems backward if you're used to C/Java/etc but it makes things nicely composable, plus now every function starts with "func", and not a random return type.
I'm fine with the losing the parens around the ifs. Other languages do that and less syntax can look less messy. I do, however, HATE the required curlies. And the fact that stupid go-fmt always wants to format them out differently than I do:
if short_check { short_code() } // My preferred formatting for short error tests
if short_check { // go-fmt always wants to do this.
short_code()
} // Blech.
For that reason alone I refuse to use go-fmt on my code :-). But I'm stubborn that way...
- losvedir 13y ago> For that reason alone I refuse to use go-fmt on my code Nooooo! :-p I used to prefer short one-liners like that (well, still do in ruby), but in Go I'm starting to kind of enjoy the blindingly obvious, verbose way of doing it. It makes me feel like Mr. Rogers[1][2]. Sure it's plodding, but it's exceedingly clear and easy to understand. [1] http://www.youtube.com/watch?v=yXEuEUQIP3Q http://www.youtube.com/watch?v=yXEuEUQIP3Q [2] http://www.youtube.com/watch?v=Upm9LnuCBUM http://www.youtube.com/watch?v=Upm9LnuCBUM
- bad_user 13y agoOf course, you could have: def parallelWrite(data: Array[Byte]) No pointers to worry about, generics, etc ...
- azinman2 13y agoWhy not int x? :) No confusion there! Except what that actually is underlying it all. I'm actually shocked that Go even has pointers given coding C++ at Google was all about passing by reference, although at least they put a lot of sane constraints on them (no pointing to arbitrary memory addresses, no pointer arithmetic, etc). Google code style guidelines are anti-one liner, so that's not surprising to me that Go's formatter tries to enforce that. I also employ one-liners but judiciously. It can be easy to miss the condition or side effect, particularly with returns. I waffle on whether it should or shouldn't be allowed. But there's something to code compactness on large projects...