Remix.run Logo
notepad0x90 20 hours ago

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 is used to indicate part of a sentence is done, yet there is still related continuation of the statement that is yet to be finished. Periods are confusing because they're used in decimal points and other language syntax, so a semi-colon seems like a good fit.

If I had my pick, I would use a colon to indicate the end of a statement, and a double colon '::' to indicate the end of a block.

func main(): int i - 0: do: i=i+1: print(i): while(i<10):: ::

another downside of indentation is it's award to do one-liners with such languages, as with python.

There is a lot of subjectivity with syntax, but python code for example with indents is not easy for humans to read, or for syntax validators to validate. it is very easy for example to intend a statement inside a for loop or an if/else block in python (nor not-intend it), and when pasting around code you accidentally indent one level off without meaning to. if you know to look for it, you'll catch it, but it's very easy to miss, since the mis-indented statement is valid and sensible on its own, nothing will flag it as unusual.

In my opinion, while the spirit behind indentation is excellent, the right execution is in the style of 'go fmt' with Go, where indenting your code for you after it has been properly parsed by the compiler/interpreter is the norm.

I would even say the first thing a compiler as well as interpreter do should be to auto-indent, and line-wrap your code. that should be part of the language standard. If the compiler can't indent your code without messing up logic or without making it unreadable, then either your code or the language design has flaw.

xigoi 17 hours ago | parent [-]

> 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
notepad0x90 14 hours ago | parent | next [-]

with apples in that list for example, you used '2.1' to indicate a new item, the space is cosmetic, the functional indicator is '2.1'

This wouldn't look right:

Introduction

  Fruit

    Apples

      Red apples

      Green apples

I'm sure you can work it out, but it doesn't feel natural, or ideal. (i can't get hn to format it without making it all one line so i used double new line).
lelanthran 15 hours ago | parent | prev [-]

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

xigoi 15 hours ago | parent [-]

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.
notepad0x90 13 hours ago | parent | next [-]

it would look better still with a dash or a bullet point for every sub-entry. We're not arguing that it is possible to do that, we're arguing what is ideal for readability.

In that list you can naturally guess what that ordering is, but if the items were not so interrelated it can be confusing. if the top level item is 'Ham' and the indented item under it is 'sandwich' are you wrapping the same phrase 'Ham Sandwich' , because indentation (even in python) is used when wrapping lines, or is sandwich under ham as one of the things done with ham. it is thus error-prone and more confusing, clear and specific punctuation alongside indentation makes it easier to read.

lelanthran 14 hours ago | parent | prev [-]

No one is saying that indentation can not be used to display lists/sublists, I'm saying that markers remove ambiguity even across movement of blocks of texts.

Indentation is fragile.