Live data from Hacker News

No Semicolons Needed

terts.dev

61–70 of 92 posts

Re: No Semicolons Needed

#61

It's very subjective, and I don't want to say that semicolons are good or bad, indentation is good or bad, etc. But I think a language should decide whether white space is significant or not. If it's not, don't add exceptions! Operators changing meaning when surrounded by spaces in otherwise context-free languages are an abomination!

> Operators changing meaning when surrounded by spaces in otherwise context-free languages are an abomination!

How does that make the language not context-free?

Re: No Semicolons Needed

#62

Earlier quoted context omitted.

Javascript's delimeter soup ((){([]{})}); can become near impossible to parse barebrained, especially when mixed with indents and semicolons. Semicolons are just noise. They're absolutely redundant. Some brackets are necessary, but whitespace/indent languages make it clear there's a lot of redundancy there too. The goal is to minimise errors and cognitive load. The fewer characters the better.

> whitespace/indent languages make it clear there's a lot of redundancy there too. The only purpose for whitespace indentation is to make the code easier on the eyes. A space shouldn't have an impact in terms of execution, that would be too hazardous. It's too easy to randomly insert a space rather than a character.

> It's too easy to randomly insert a space rather than a character.

What are you doing with your code? I never find myself just randomly inserting characters.

Re: No Semicolons Needed

#63
post #43

This article makes a strong case for every language to use ‘;’ as a statement separator.

Exactly. I genuinely do not understand how any significant user of python can handle white space delimitation. You cannot copy or paste anything without busywork, your IDE or formatter dare not help you till you resolve the ambiguity. One day https://github.com/mathialo/bython one day!

> your IDE or formatter dare not help you

Get the ones that do help you! Problem solved, enjoy your clean reading experience!

Re: No Semicolons Needed

#64

> I would love to see a language try to implement a rule where only an indented line is considered part of the previous expression. After python, it seems like every language decided that making parsing depend on indents was a bad idea. A shame, because humans pretty much only go by indents. An example I've frequently run into is where I forget a closing curly brace. The error is reported at the end of the file, and…

What language is this? In C I get the correct position of the error because GCC also monitors the indentation as it parses.

A linter can point out errors based on indentation, and they frequently do. There's no need for the language to do it and then band-aid additional fixes for problems caused by significant white space.

Re: No Semicolons Needed

#65
post #58

Earlier quoted context omitted.

we don't even use indents that way in natural language. We use things like bullet points, we need specific markers. space is for spacing, tabs are for tabulation, they are not in any human language I know of used as terminators of statements. You know what is the equivalent of an indent or a semicolon in english? a period. We have paragraph breaks just like this to delimit blocks of english statements. A semi-colon i…

> we don't even use indents that way in natural language. Have you never seen a nested table of contents? 1. Introduction 2. Fruit 2.1 Apples 2.1.1 Red apples 2.1.2 Green apples 2.2 Oranges 3. Vegetables 3.1 Carrots

Your example remains valid after the indentation is stripped, because it has markers to delineate the list and sub list items.

Re: No Semicolons Needed

#66
post #58

Earlier quoted context omitted.

> we don't even use indents that way in natural language. Have you never seen a nested table of contents? 1. Introduction 2. Fruit 2.1 Apples 2.1.1 Red apples 2.1.2 Green apples 2.2 Oranges 3. Vegetables 3.1 Carrots

Your example remains valid after the indentation is stripped, because it has markers to delineate the list and sub list items.

It doesn’t need to; that’s just the section numbering. In a biology textbook, you could have something like (made up names)

  Arabateciae
    Arabaticopoda
    Arabaticoquasicae
  Bidoroca
    Pseudobidoroca
    Superbidoroca
      Superduperbidoroca
and the hierarchy is still clear.

Re: No Semicolons Needed

#67

I never actually type semicolons in my JavaScript / TypeScript. In work projects, my IDE adds them for me thanks to the linter. In personal projects, I just leave them out (I don't use a linter, so my IDE does not add them), and I've never had a problem. Not even once. Semicolon FUD is for the birds.

Cormack McCarthy proved to me that when structured correctly conversive language does not need any quotation marks (while remaining entirely comprehensible).

But " " still exist (for us/mere mortals) because few can write so clearly.

I know nothing about coding (beyond changing others' variables to fit my installation), but would imagine this parallels many coding environments (e.g. yours).

Re: No Semicolons Needed

#68
post #62

Earlier quoted context omitted.

> whitespace/indent languages make it clear there's a lot of redundancy there too. The only purpose for whitespace indentation is to make the code easier on the eyes. A space shouldn't have an impact in terms of execution, that would be too hazardous. It's too easy to randomly insert a space rather than a character.

> It's too easy to randomly insert a space rather than a character. What are you doing with your code? I never find myself just randomly inserting characters.

> I never find myself just randomly inserting characters.

Hasn't it ever occured to you trying to insert a space at your mouse but your cursor wasn't there? People sometimes forget to click (or think the cursor is already there), myself included. Characters are easier to spot because they are not invisible and random letters cause compile errors.

If it has never occurred to you, then good for you. However I do not see what the benefit of not using closing brackets would be.

Re: No Semicolons Needed

#69
post #17

> I would love to see a language try to implement a rule where only an indented line is considered part of the previous expression. After python, it seems like every language decided that making parsing depend on indents was a bad idea. A shame, because humans pretty much only go by indents. An example I've frequently run into is where I forget a closing curly brace. The error is reported at the end of the file, and…

Scala 3 decided to go with indents.

Kind of. It supports an end operator as well, and imo everyone should be using it. I actually really like the `end name` approach as opposed to the Lua-style plain ends.

Re: No Semicolons Needed

#70
post #62

Earlier quoted context omitted.

> It's too easy to randomly insert a space rather than a character. What are you doing with your code? I never find myself just randomly inserting characters.

> I never find myself just randomly inserting characters. Hasn't it ever occured to you trying to insert a space at your mouse but your cursor wasn't there? People sometimes forget to click (or think the cursor is already there), myself included. Characters are easier to spot because they are not invisible and random letters cause compile errors. If it has never occurred to you, then good for you. However I do not se…

I don’t use the mouse when editing code, so this particular mistake does not happen to me.

> I do not see what the benefit of not using closing brackets would be.

Less visual noise. And the ability to use braces for other syntax.

Post reply on HN