5 ms·
> Zimbu’s trademark feature was the way it let coders omit the opening curly brace around a block of code. (“It looks a bit weird maybe, at first…” Moolenaar ac
by User3456335 3y ago
> Zimbu’s trademark feature was the way it let coders omit the opening curly brace around a block of code. (“It looks a bit weird maybe, at first…” Moolenaar acknowledged to the audience. “Get used to it. It will work out fine.”)
Hahahaha, this is what we needed: a programming language with unmatched braces because the opening brace can be inferred from context... Well, no surprise that this is coming from the Vim creator.
- sph 3y agoNot that dumb as one might think. What is the purpose of the opening brace after a function declaration in C, for example? It's the only token accepted, so its sole purpose is symmetry with the closing brace, which has an actual purpose. So it might look silly, but there is no deep reason it couldn't have just been int main() printf("hello"); } That's just as unambiguous to parse.
- vore 3y agoNot in the original C, where you had to declare function parameter types like so: int foo(x) int x; { return x; } and not in C23 (or GNU C) either, where this is legal (this example is not super useful): int foo(int x) [[gnu::aligned]] { return x; }
- mikepavone 3y agoTechnically, the opening brace is needed in C to support K&R style function declarations which apparently were still legal in C11 at least, but I doubt that's a feature anyone wants to replicate in a new language.
- layer8 3y agoIn that case, I would prefer Pascal’s (and Basic’s) “end”, however.
- zarzavat 3y agoUnmatched braces completely mess up text editors, which would need to include a full parser in order to pair-match brackets (it also creates an unresolved tension that will stay with you all day :)
- goku12 3y agoI was going to say the same. And yes - it causes OCD in 90% of devs out there. But it also feels somewhat wrong for editors to match brackets to infer block hierarchy. What if blocks have some sane rule that we don't know yet (i.e other than bracketed blocks and indented blocks)? Perhaps treesitter is the one-stop solution for that problem.
- cozzyd 3y agoIndeed. Things like di{ probably don't work...
- kgwxd 3y ago> :) That’s a mouth, not a paren :/ I won’t be able to sleep tonight :)) (that’s better
- The_Colonel 3y agoMany languages are designed with IDEs in mind and "dumb" text editors are not a concern.
- vidarh 3y agoText editors need fairly complete parsers to match braces anyway. E.g. consider even something as simple as { "}" }. Or {"\"}. The former is reasonably unambiguous, but the latter requires knowing if the escape style of double quoted strings in the given language escapes the second '"' or not. Now try proc {"#{"}"}"} (valid Ruby) vs proc {"{\#{"}"}"} (invalid)
- norir 3y agoI have an even better idea: main(): int printf "hello" 0 ;)
- lambda_garden 3y agoTrouble with that is invoking main and declaring main are too similar. I prefer this: let main () = printf "hello" 0
- sltkr 3y agoWhy do we put spaces after punctuation in English?It's completely redundant.actually,why even put a capital letter at the beginning of a sentence?it can obviously be inferred. OK, I'll stop now, but the point is: matching braces provide visual structure that's helpful to read code, even if it's syntactically redundant.
- sph 3y agoProse is not a programming language, isn't it obvious? One is designed for machines to parse unambiguously, the other has grown organically and chaotically over hundreds of years. Machine parsing has never been a design concern.
- frodowtf 3y agoIndentation provides visual structure. Matching braces hardly add value to it.
- Q6T46nT668w6i3m 3y agoYou identified its purpose: symmetry.
- fferen 3y agoReminds me of TI-BASIC for the TI-83 graphing calculators... The closing ')' is optional at the end of a line, and omitting it could make your program slightly faster...
- ctenb 3y agoOne step further would be to omit the second brace too. And we arrived at the Python design choice. I think only omitting the first brace is a middle ground most people find unappealing.
- vidarh 3y agoHence Ruby or Oberon style of "end". Personally I have no intention of ever seriously using a language with significant indentation levels. It's not worth suffering the visual clutter.
- augustk 3y agoNiklaus Wirth also removed the BEGIN keyword from control statements in Modula-2 and in Oberon. Oberon: IF a < b THEN ... END Pascal: IF a < b THEN BEGIN ... END