News for hackers. Stuff that matters.
Re:Modern Pascal is still in the race (2022) by zozbot234 on Wednesday October 11, 2023 @01:02PM (#37847098)
Historically, 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 notation using <% and %> and COBOL goes as far as writing out arithmetical operators as English text, such as DIVIDE x INTO y GIVING z.
Re:Modern Pascal is still in the race (2022) by KerrAvon on Wednesday October 11, 2023 @02:39PM (#37848523)
I 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.
Re:Modern Pascal is still in the race (2022) by pavlov on Wednesday October 11, 2023 @04:42PM (#37850002)
Maybe both? COBOL predates the first draft of ASCII by several years. Character sets were far from standardized in those days.
Re:Modern Pascal is still in the race (2022) by noizejoy on Wednesday October 11, 2023 @07:10PM (#37851562)
Lots (most?) of classic COBOL used EBCDIC[0]

[0] https://en.wikipedia.org/wiki/EBCDIC

Re:Modern Pascal is still in the race (2022) by dwheeler on Wednesday October 11, 2023 @03:27PM (#37849152)
Ada, 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.
Re:Modern Pascal is still in the race (2022) by Sakos on Wednesday October 11, 2023 @03:55PM (#37849469)
Ngl, 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
Re:Modern Pascal is still in the race (2022) by zozbot234 on Wednesday October 11, 2023 @04:25PM (#37849817)
Most programming languages now support reformatters out of the box. Part of the point of those is to make mismatched closing braces more visible.
Re:Modern Pascal is still in the race (2022) by suby on Wednesday October 11, 2023 @05:46PM (#37850653)
Rainbow brackets, so the brackets themselves are color coded to match with their corresponding partner, are also a godsend.
Re:Modern Pascal is still in the race (2022) by usrusr on Wednesday October 11, 2023 @07:41PM (#37851805)
I'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.

Re:Modern Pascal is still in the race (2022) by bombcar on Wednesday October 11, 2023 @09:31PM (#37852452)
Code folding is phenomenal for understanding a codebase and I'm really surprised it wasn't utilized more.
Re:Modern Pascal is still in the race (2022) by usrusr on Thursday October 12, 2023 @05:24AM (#37855047)
Everybody getting burned by fold+forget exactly once would be my guess.

Perhaps new generation of editors ("post VSC") that experiments with non-uniform size could perhaps lead to some form of revival? Fold to "code minimap" excerpt instead of away. UI might want to consider cursor position in the leading whitespace for depth selection. In mouse terms, interact with the vertical line some editors display (not sure this could be helpful for keyboard knowitalls who'd select depth by repetition)

Or maybe this all exists but the shortcuts aren't sufficiently well known to reach my lowly knowledge levels, that's one of the more frustrating aspects of what-iffing editor UI.

Re:Modern Pascal is still in the race (2022) by Sakos on Wednesday October 11, 2023 @08:04PM (#37851965)
Even with all these helpers, there's too much cognitive overhead and not enough that IDEs or plugins can do to take that away. Rainbow braces are nice and all, but it's not enough when the underlying concept is broken.
Re:Modern Pascal is still in the race (2022) by trealira on Wednesday October 11, 2023 @05:48PM (#37850676)
In languages without this feature (most of them), you sometimes see long blocks get labeled at the end anyway. On then other hand, you could argue that if your block is long enough it doesn't fit on the screen, then it should be its own function anyway.

Like this, except replace "..." with many lines of code.

  if (z.p == z.p.p.left) {

      ...

  } else { // z.p != z.p.p.left

      ...

  } // if
Re:Modern Pascal is still in the race (2022) by dwheeler on Friday October 20, 2023 @10:05PM (#37963450)
> In languages without this feature (most of them), you sometimes see long blocks get labeled at the end anyway.

True. However, in Ada at least, if the block types don't match then it's a syntax error detected at compile time by the compiler. Comments like those listed above are often not checked at compile time, and thus aren't very useful for preventing errors.

Re:Modern Pascal is still in the race (2022) by kaba0 on Thursday October 12, 2023 @11:37AM (#37858706)
Scala 3 actually has a brace-less mode that supports this.
Re:Modern Pascal is still in the race (2022) by wwweston on Wednesday October 11, 2023 @06:46PM (#37851339)
You can do this with PHP, too, but it’s on the rare side except in some templating niches.

The reverse-reserved-word convention like ‘fi’ to end an if block in shell (and other?) languages seems like it functions this way too.

And I guess significant indentation also does this job, albeit with some of its own hazards.