Hacker News new | ask | show | jobs
by rrrazdan 1862 days ago
I could literally not use any indentation and the machine would still understand me. Not sure how they matter for machines?

They do matter for humans though. The reason we write code and structure it the way we do is for human convenience. One of those conveniences is thinking of the layout of code as a visual help to scan and read it. As such I am very much organizing my code like a graphic designer would organize information.

Edit: Indentations do matter in some languages and used to signify information. But not in a lot of them. The point still stands that most of the time we are using them for visual purposes not information to the compiler/interpreter.

1 comments

Only in the sense that all characters are "for visual purposes". Tabs have a distinct meaning from spaces, and can be rendered however you want (arrows or chevrons, for instance); "whitespace" is a poor term for them.
If I ever have to program in python, I'm absolutely going to pull out some of my obsolete translation programming and write a preprocessor that translates brackets to the semantically equivalent indentation, yes this will make python sort of an intermediate language LOL
I thought they were for aligning columns in a table (hence “tab”), rather than indentation? This goes back to typewriters. Sure you could abuse it for indentation and perhaps that became common practice at one point but it doesn’t mean that’s what it’s “for” any more than spaces.
> This goes back to typewriters. Sure you could abuse it for indentation and perhaps that became common practice at one point [...]

Indentation (specifically the first line of each paragraph) was arguably the first widespread use of the tab key. The annoyance with using it for actual tables was that generally you'd want numeric data to be right-justified (so that digits of equal significance align vertically). So I wouldn't really call it an abuse, especially on modern keyboards.

Arguably yes. And arguably spaces are better for indentation as a matter of convenience and accessiblity and you can’t make any strong argument that it’s what tab is “for” based on original purpose.
> and you can’t make any strong argument that it’s what tab is “for” based on original purpose

I didn't claim as such - I'm just contesting your claim that using tab for indentation is an "abuse" because it's "for aligning columns in a table".

That’s fine. You’re supporting my point in that case.
I'd say they're "for" whatever we want. Nowadays they're far more widely used for semantic indent than for tabular alignment.
Sorry I misunderstood you, I thought you were making the argument that spaces aren’t for indentation.