6 ms·
I guess I might be the only one to say this, but is this a joke? Some sort of prank? Not a single Go program is more readable, and I would argue that they are A
by fingerprinter 14y ago
I guess I might be the only one to say this, but is this a joke? Some sort of prank? Not a single Go program is more readable, and I would argue that they are ALL less readable (and I like Go).
I honestly can't tell if he is trolling or if he is serious.
- donnyg107 14y agoI disagree. After only a brief runthrough of Go, the different types of statements are very recognizable line by line. The sytax includes less obvious breaks and parens, but I think that makes the code a lot more readable because it eliminates the nastier paren nesting you often see in C. I think the first example in chapter 2 gives clear indication of the benefits of eliminating the features of C which are more compact but less readable.
- jbooth 14y agoI think Go's strengths over C really start to shine when you're writing programs longer than 100 lines. Not having an exception mechanism, interfaces, single namespace, no attaching methods to structs etc are fine in a small program, but they make bigger programs harder to digest pretty quickly.
- Locke1689 14y agoCalling Go's panic/recover system a proper exception mechanism is quite a stretch.
- sirclueless 14y agoI think he is referring more to go's "defer" functionality and out-of-band error return values more than panic/recover.
- Locke1689 14y agoAll of these things are just really poor exception mechanisms, in my opinion. It really looks like no one with an up-to-date PLT background was consulted in the design. I agree 100% with Andreas Rossberg (who now, somewhat ironically, works at Google): It is ironic that their motivation is to tame and restrict the use of exceptions, and then they replace them by something even richer and much less structured. I fail to see any pros of this proposal. It seems mostly equivalent to exceptions, i.e., you can easily express raise/try/finally as syntactic sugar, and likely the other way round. But it is (1) much more ad-hoc -- you cannot give a simple reduction semantics for this, (2) much less orthogonal -- tying `defer' in with function definitions, (3) dependent on mutation -- for recovering and returning alternative results, and implicitly in the semantics of `defer'. One consequence is the loss of beta-convertibility, which means that you as a programmer cannot take an arbitrary piece of code and turn it into a function anymore, or vice versa, eliminate a function by inlining its body. Such abstractions/refactorings are impossible in general under this proposal, or at least require transforming the relevant code in potentially non-trivial ways.
- luriel 14y agoI disagree that panic/recover is worse than exceptions, I find it a more pleasant and lightweight mechanism, but the big difference is that panic/recover are not used like exceptions at all in Go, they are basically used only for programmer errors. They can be used for other things, but in those cases they never cross API-calls so you never have to worry about whatever a library you call might panic, you can basically ignore panic/recover exists completely, and do just fine, and that is what most people do most of the time.
- Locke1689 14y agoWell, we can argue about whether or not an exception mechanism is the best way to deal with program error conditions, but my first point still stands, which is that Go does not have a proper exception mechanism. If defer/panic/recover were to be used as a true exception system you would run into all the issues Andreas details.
- wickedchicken 14y ago
- eswangren 14y agoWell, the operating system you used to write that comment was probably written in C, so apparently it does in fact work in large projects. It has weaknesses to be sure, but I don't think lack of OO (I.e., structs with functions) is one of them.
- dllthomas 14y agoParticularly given that you can write OO code in C, and can decorate structs with functions, it's just messier.
- StephenFalken 14y ago"Object oriented programming with ANSI-C": https://ritdml.rit.edu/handle/1850/8544 https://ritdml.rit.edu/handle/1850/8544
- jbooth 14y agoDuh. "Done" and "easily done" are different things. Structs with functions isn't the biggest deal, and namespaces can be simulated with a couple underscores. But I have a hard time with error handling if you don't have exceptions, any time I have a call stack more than 3-4 deep I find myself confused about how to treat certain errors. Then there's concurrency.
- tedunangst 14y agoIt's worth noting that the bulk of the code in the kernel comes from 900 different network drivers, each of which could be considered a small program in its own right.
- shadowmint 14y agoJudging by the similarity to his much large section on C (http://crypto.stanford.edu/~blynn/c/ http://crypto.stanford.edu/~blynn/c/) I'd say serious. Also, who cares what his style is? If _you_ ever have to work on the code, run gofmt on it; if that's how he likes his go, good for him.
- scott_s 14y agoAlso, who cares what his style is? Me, because I found it unpleasant to read. Working on such code is beside the point.
- angelbob 14y agoHe's picking a bunch of problems C is really good at and then roughly, fairly mechanically translating to Go. I don't think he's trolling, but I do think he's playing to C's strengths and Go's weaknesses, possibly by accident.
- cantankerous 14y agoI agree. I don't see anything wrong what he did, but somebody should offer to submit counterpoints that better emphasize what Go is able to do.
- jlgreco 14y agoI think many counterpoints should be fairly obvious. Anything from "return a return value and an error code from a function" (trivial in both, way nicer in Go though) to "write a webserver from scratch. Which did you just schedule more time for?"
- ternaryoperator 14y agoOr anything that needed to be run in parallel.
- dillon 14y agoHe is definitely serious. I do think that all semicolons really shouldn't be used. The only time I ever use semicolons is for error checking in Go.
- drivebyacct2 14y agoHe's not helping by explicitly stating that he's ignoring gofmt style. Those examples would look lengthier but cleaner if he would run gofmt on them.
- AncientPC 14y agoI've gone ahead and reformatted his code using `indent -kr` and `gofmt`: https://gist.github.com/2932444 https://gist.github.com/2932444