It surprises me, because from what I've seen Go seems to be much higher level language. Or are those just all the `if err != nil` lines?
It surprises me, because from what I've seen Go seems to be much higher level language. Or are those just all the `if err != nil` lines?
In short, the Go code in the runtime is about at the same level at C code.
Don't forget that this is a straight 1-to-1 translation; this is not the time to introduce new bugs. After it's all done, the runtime code can be refactored and it might become cleaner and smaller.
PS: there are no go errors, and hence no if err != nil statements in the runtime.
There are many types of code that are significantly longer in C# or java than in C, just because C lets you do crazy things with memory mapping.
To get more terse code, you need to switch from the C family of sytax imo.
ok, err := Foo()
if err { ... }
and then the caller has to do the same thing (basically reinventing manually what exceptions do for you).As far as "Why Go for shell scripts?" I actually think Go is pretty well suited to shell scripts (aside from no or die): getting stdout/stderr pipes set up is pretty trivial with the exec package. There must be anecdotal law somewhere that states that all shell scripts tend to Turing completeness over time: what starts with "oh, a small shell script would do this" always ends up growing to a full blown 1000+ line program with multiple code paths. Writing the first script in Go is a piece of defensive programming so that when it inevitably grows, it's growing into a language that better supports its size (static typing, readability, libraries etc.) It's probably overkill for personal stuff, but it is probably the right hammer for the job over time when it comes to corporate work.
Could you provide a readability algorithm in some form of executable that we can run against the 100 lines of c and Go code — then we'll be able to judge correctly.
Sure, it's next to the objective poetry quality metric.
"Shall I compare thee to a summer's day?"
> TYPE ERROR
https://codereview.appspot.com/99380043
https://codereview.appspot.com/140050044
https://codereview.appspot.com/136980044
https://codereview.appspot.com/139930044
https://codereview.appspot.com/139930043
https://codereview.appspot.com/135070043
https://codereview.appspot.com/123700044
https://codereview.appspot.com/126210046
https://codereview.appspot.com/130340043