5 ms·
How about all whitespace should be represented by one character to reduce ambiguity. I shouldn't have to figure out if 'l' is 'ell' or 'eye'. Same way I should
by rrrazdan 5y ago
How about all whitespace should be represented by one character to reduce ambiguity. I shouldn't have to figure out if 'l' is 'ell' or 'eye'. Same way I should not have see visually whitespace and wonder if it's tab or space. One visualization, one ascii representation.
- DocTomoe 5y agoI think this is where a lot of the trouble comes from: Tabs are misunderstood as "whitespace", as if code was some sort of DTP by a graphic designer. Code actually is a functional instruction to a machine - semantics matter, and this is where tabs shine: they are unambigious (did the developer decide to indent this this far, or not?) If tabs-as-whitespace trouble you, editors since the 1990s have allowed you to choose/configure other representations of tabs.
- rrrazdan 5y agoI 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.
- dTal 5y agoOnly 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.
- rusk 5y agoI 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.
- dTal 5y agoI'd say they're "for" whatever we want. Nowadays they're far more widely used for semantic indent than for tabular alignment.
- rusk 5y agoSorry I misunderstood you, I thought you were making the argument that spaces aren’t for indentation.
- treesprite82 5y ago> 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.
- rusk 5y agoArguably 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.
- treesprite82 5y ago> 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".
- dangerface 5y agoBecause whitespace is not a space includes margins the spacing between letters etc, we all ready have a word for the white space character you are talking about its called space and its not used for indentation.
- rusk 5y agoHere was I thinking “tab” was for “tables”