4 ms·
I found some pleasant similarities between Pascal and Go (Golang)
by aubergene 14y ago
I found some pleasant similarities between Pascal and Go (Golang)
- TazeTSchnitzel 14y agoWhat are they, aside from just := and the lack of brackets?
- jbarham 14y agoGo's declaration syntax (http://golang.org/doc/articles/gos_declaration_syntax.html http://golang.org/doc/articles/gos_declaration_syntax.html) and package system are inspired by the Pascal family, according to the FAQ (http://golang.org/doc/faq#ancestors http://golang.org/doc/faq#ancestors).
- snogglethorpe 14y agoActually Go's use of := is almost anti-pascal: it means something rather different, but similar enough to be confusing, and so is likely to confuse anybody who's used to the vastly more common meaning of := in Algol-family languages (Pascal, Ada, etc). ... and then there's Go's screwed up version of Pascal-style declaration syntax... [a link to my earlier rant on this subject: http://news.ycombinator.com/item?id=4520104 http://news.ycombinator.com/item?id=4520104 (TL;DR: Go: "var foo, bar int"; Pascal: "var foo, bar : int"; the colon vastly improves readability, and has no real drawback)]
- dualogy 14y ago> the colon vastly improves readability We have gofmt for that :)
- snogglethorpe 14y ago> > the colon vastly improves readability > We have gofmt for that :) Er, what? gofmt doesn't improve the readability of declarations at all... [there's really not much it can do]
- dualogy 14y agoIt spaces them evenly if you have multiple subsequent lines of them. Readable enough: var ( i, j int foobarStuff string bebop bool ) What's not readable?
- snogglethorpe 14y agoEr, ok, it can slightly mitigate the problem in a few cases. Even to the extent that it work though, this is a very fragile "solution" — (1) declarations often occur alone, (2) multiple declarations can have similarly sized variables, meaning there's no big whitespace chunk to act as a separator, and (3) one shouldn't have to run one's code through a code formatter, or use awkward formatting practices, to get basic readability.... Simply following standard practice (over decades), and including a colon, on the other hand, would have made all declarations more readable, and be more familiar, for no real cost. Really, some of Go's syntax decisions are completely baffling... [Sure there are lots of crazy computer languages around, but these guys really should have known better—and anything they do is much more likely to have an impact than most random languages, so it'd be nice if they could take a bit more care...]