Live data from Hacker News

No Semicolons Needed

terts.dev

1–10 of 92 posts

Re: No Semicolons Needed

#4
post #2

Can anyone give a good reason why supporting syntax like: y = 2 * x - 3 is worth it?

It's not. Your eyes can deceive you by guessing the correct indentation. Indentation should never be used for grammar separation. Explicit characters such as } ] ) are clearer and unambiguous.

Re: No Semicolons Needed

#6
post #2

Can anyone give a good reason why supporting syntax like: y = 2 * x - 3 is worth it?

By "is worth it" you mean it's worth the work?

Because it's very little extra work.

If you want to know if it's a good syntax, AFAIK it's the only way to do a semicolon-less language that doesn't break all the time.

Re: No Semicolons Needed

#7
Classic mistakes in language design that have to be fixed later.

- "We don't need any attributes", like "const" or "mut". This eventually gets retrofitted, as it was to C, but by then there is too much code without attributes in use. Defaulting to the less restrictive option gives trouble for decades.

- "We don't need a Boolean type". Just use integers. This tends to give trouble if the language has either implicit conversion or type inference. Also, people write "|" instead of "||", and it almost works. C and Python both retrofitted "bool". When the retrofit comes, you find that programs have "True", "true", and "TRUE", all user-defined.

Then there's the whole area around Null, Nil, nil, and Option. Does NULL == NULL? It doesn't in SQL.

Re: No Semicolons Needed

#8
> I would love to see a language try to implement a rule where only an indented line is considered part of the previous expression.

Elm does this (so maybe Haskell too). For example

    x = "hello "
     ++ "world"

    y = "hello "
    ++ "world" -- problem

Re: No Semicolons Needed

#9
post #2

Can anyone give a good reason why supporting syntax like: y = 2 * x - 3 is worth it?

Mostly eye-candy, especially for some long one-liners.

In PowerShell you can do that by explicitly instructing what the next line is actually a continuation of the previous one:

    $y = 2 * $x `
       - 3

Re: No Semicolons Needed

#10
Because formatters are increasingly popular, I think it'd be interesting to see a language that refuses to compile if the code is improperly formatted, and ships with a more tolerant formatter whose behavior can change from version to version. This way, the language can worry less about backwards compatibility or syntax edge cases, at the cost of taking away flexibility from its users.
Post reply on HN