5 ms·
I'm surprised that you draw a sharp distinction between C and Pascal syntax. They have a shared lineage and are really very close to each other. Yeah, curly bra
by PumpkinSpice 3y ago
I'm surprised that you draw a sharp distinction between C and Pascal syntax. They have a shared lineage and are really very close to each other. Yeah, curly braces won over "begin" and "end", but that's not a matter of some huge conceptual rift, just convenience.
There are numerous languages today, including Haskell and Ocaml, that are far more removed from the Algol lineage than these two. Heck, the differences between Rust and C are probably more pronounced than between C and Pascal.
- zozbot234 3y agoHistorically, the point of writing 'begin' and 'end' instead of using curly braces was mostly support for non-ASCII character sets where the curly braces are not included. It's why C also has an alternate syntax using <% and %> and COBOL goes as far as writing out arithmetical operators as English text, such as DIVIDE x INTO y GIVING z.
- KerrAvon 3y agoI was under the impression that COBOL's English syntax was intended to be a more human-readable approach, not so much a workaround for character set limitations.
- pavlov 3y agoMaybe both? COBOL predates the first draft of ASCII by several years. Character sets were far from standardized in those days.
- noizejoy 3y agoLots (most?) of classic COBOL used EBCDIC[0] [0] https://en.wikipedia.org/wiki/EBCDIC https://en.wikipedia.org/wiki/EBCDIC
- andomizczzz662 3y ago[dead]
- dwheeler 3y agoAda, at least, uses begin...end in part because it prevents certain kinds of errors. In its syntax you have to specify what you are ending, reducing the risk of invalid matches and increasing the likelihood of the error report system guessing correctly what you intended. E.g.: if X > 0 then Y := 0; end if; Curly braces are shorter, but a close curly brace will match any open curly brace. Such is the nature of trade-offs.
- Sakos 3y agoNgl, I think that's brilliant. Braces matching the wrong brace is like a daily occurrence. It's such a tedious small thing that constantly hounds me whenever I'm writing code
- zozbot234 3y agoMost programming languages now support reformatters out of the box. Part of the point of those is to make mismatched closing braces more visible.
- suby 3y agoRainbow brackets, so the brackets themselves are color coded to match with their corresponding partner, are also a godsend.
- usrusr 3y agoI'm surprised that code folding has never really become good/popular enough to make all these things non-issues. Often it's only for named blocks like functions, and not for the really unhelpful bits like that conditional branch that is long, simple and deep, but really does not deserve spamming a namespace with an unhelpful identifier. And I've yet to see a deliberately short-lived folding to lessen the out of sight, out of mind tax that code folding of associated with. If there was deliberately short-lived folding, perhaps auto-reexpanding whenever the section has scrolled out of view, I'd use folding all the time, to navigate the nesting. The quasi-permanent until explicitly re-expanded cold folding? Yeah, I hardly ever use it, to many bad experiences with forgetting to re-expand.
- nine_k 3y agoOne huge difference between C and Pascal grammars us that Pascal is LR(1), so it can be parsed easily, which helps one-pass translation. It also helps humans read it. C, on the other hand, has needlessly complicated syntax; a function definition is hard to detect, and a pointer to a function is hard to interpret, because it's literally convoluted: https://c-faq.com/decl/spiral.anderson.html https://c-faq.com/decl/spiral.anderson.html Sadly, this is a general stylistic difference: where Pascal tries to go for clarity, C makes do with cleverness, which is more error-prone.
- bluGill 3y agoHumans can normally treat C as if it is LR and get away with it, except for a few places that they can often recognize and avoid. It is a bad shortcut, but still one that you can get by with taking in a lot of code.
- deergomoo 3y agoI'm very much not a C programmer, but I've never understood why it seems far more common to write `float *foo` instead of `float* foo`. The "pointerness" is part of the type and to me the latter expresses that far more clearly.
- BaculumMeumEst 3y agoThe * binds the name, not the type. https://godbolt.org/z/GsoxrWdrG https://godbolt.org/z/GsoxrWdrG
- 3y ago