Hasty Briefsbeta

Bilingual

No Semicolons Needed

10 hours ago
  • #semicolon-free
  • #syntax-design
  • #programming-languages
  • The article discusses the implementation of semicolon-free syntax in programming languages, focusing on Roto, a new scripting language.
  • Different languages handle statement termination without semicolons in various ways, including Python's whitespace sensitivity, Go's automatic semicolon insertion, and Swift's greedy parsing.
  • Python uses logical lines and enforces strict indentation rules to avoid ambiguity.
  • Go inserts semicolons automatically during lexing, which can lead to unexpected behavior if not formatted correctly.
  • Kotlin integrates newline handling directly into its grammar, making it complex but intuitive for developers.
  • Swift parses expressions greedily, ignoring newlines unless they lead to syntax errors, with some whitespace-sensitive rules.
  • JavaScript's automatic semicolon insertion is complex and error-prone, leading many developers to prefer explicit semicolons.
  • Gleam and Lua parse expressions without considering whitespace, relying on unambiguous grammar to prevent errors.
  • R and Ruby allow expressions to continue on the next line if incomplete, with Ruby adding special rules for method chaining.
  • Julia's approach is similar to Python and R, preferring to split statements at newlines if legal.
  • Odin mixes Python and Go's approaches, with semicolon insertion by the lexer but not within delimiters.
  • The article suggests a novel idea of using indentation to determine statement continuation, though it may complicate formatting.
  • The conclusion emphasizes the importance of clear, simple rules and considering the language's overall syntax design.