News for hackers. Stuff that matters.
Re:Xz: Can you spot the single character that disabled Linux... by capitainenemo on Saturday March 30, 2024 @11:00AM (#39875495)
Yeah, if anything, python worsens the situation. I had a friend DOS our server because he accidentally inserted a tab, causing the illusion that one statement was inside a block but was actually outside it. He swore off python at that point. I personally avoid the language, but I understand due to issues like that these days mixing tabs and spaces is an error (or is it just a warning?) by default. Regardless, still pretty silly to me to have whitespace play such a major significant role, besides the fact that I find it visually harder to read, like text without punctuation or capitalisation.
Re:Xz: Can you spot the single character that disabled Linux... by secstate on Saturday March 30, 2024 @11:49AM (#39875988)
Mixing tabs and spaces usually throws a runtime exception. I'm not gonna make a value judgement about that, but your story doesn't make sense based on how I understand py3

Edit, sorry, shoulda read your whole commebt before replying

Re:Xz: Can you spot the single character that disabled Linux... by capitainenemo on Saturday March 30, 2024 @12:03PM (#39876104)
Yep. It was a few years ago while that was stilled allowed (as I'd noted ;) ) but regardless. Significant whitespace is just annoying.. There's a lot of things that render as whitespace, and source code one might be reviewing could be printed wrapped or copied and pasted in odd ways. Other languages are more robust to this.
Re:Xz: Can you spot the single character that disabled Linux... by _visgean on Saturday March 30, 2024 @07:24PM (#39879634)
Never had this happen, this is largely eliminated by using tools like black or other autoformatters.
Re:Xz: Can you spot the single character that disabled Linux... by eru on Saturday March 30, 2024 @10:18PM (#39880743)
And/or linters.

This issue is no worse that having multiple different variables that look the same and only in their obscure same-looking unicode symbols.

A linter can handle this. As can a decent font, or editor settings.

Re:Xz: Can you spot the single character that disabled Linux... by MrDresden on Sunday March 31, 2024 @03:52AM (#39882312)
The point still stands that this is an inherit possibility in the language it self.
Re:Xz: Can you spot the single character that disabled Linux... by eru on Sunday March 31, 2024 @04:15AM (#39882425)
Well, in C the visual indentation and the meaning of the code (given by {}) can diverge. That's even worse, and happens in practice. Many style guidelines for C have evolved specifically to address that problem with 'the language itself'.
Re:Xz: Can you spot the single character that disabled Linux... by worik on Sunday March 31, 2024 @04:35PM (#39887842)
> Well, in C the visual indentation and the meaning of the code (given by {}) can diverge.

How?

Re:Xz: Can you spot the single character that disabled Linux... by eru on Sunday March 31, 2024 @08:29PM (#39889596)
The compiler doesn't check your indentation at all. (OK, not true, these days you get warnings for misleading indentation.) But here's an example of misleading indentation in C:

    if(some condition)
        do something; {
        do something else;
    }
    do another thing;
You can stretch 'some condition' out over multiple lines and have some more parents inside of it, to make it more confusing.

See also https://softwareengineering.stackexchange.com/a/16530

Re:Xz: Can you spot the single character that disabled Linux... by worik on Monday April 01, 2024 @07:57PM (#39900854)
I see.

Yes

I class that as a bug in the original C specification

Re:Xz: Can you spot the single character that disabled Linux... by eru on Monday April 01, 2024 @10:38PM (#39901857)
But you either make visual indentation significant, or you risk having a discrepancy between visual indentation and what the language sees.
Re:Xz: Can you spot the single character that disabled Linux... by worik on Monday April 01, 2024 @10:55PM (#39901938)
> But you either make visual indentation significant...

That would be Python. I do not like it, which does not mean it is bad, it is a matter of taste

The alternative is you say "blocks are delimited by {}"

`if(foo) bar` should be invalid

`if(foo){bar}` is OK by me. Worik's tick of approval

(Neither is valid C I think)

Re:Xz: Can you spot the single character that disabled Linux... by eru on Tuesday April 02, 2024 @04:03AM (#39903367)
> That would be Python.

Not necessarily. In practice, in C-as-actually-used people (should) set up linters and formatters, so that you can rely on indentation.

When programming, this means that you can behave as if both curly braces and indentation are significant, and you get an error when they are out-of-sync.

Re:Xz: Can you spot the single character that disabled Linux... by _visgean on Sunday March 31, 2024 @06:41AM (#39883071)
I think its more of an tooling issue. If your editor / diff viewer cant differentiate between different whitespaces get a better one. Also if you want to ensure some function isnt in local scope etc just test it.
Re:Xz: Can you spot the single character that disabled Linux... by probably_wrong on Sunday March 31, 2024 @08:14AM (#39883563)
I feel that the main point still stands, though. Saying that Python doesn't have a whitespace problem because you can send the code through a tool that detects whitespace-related problems still acknowledges the existence of said problem.
Re:Xz: Can you spot the single character that disabled Linux... by heavenlyblue on Saturday March 30, 2024 @10:14PM (#39880726)
You can enable showing whitespace characters in your editor, in PyCharm they are visualised perfectly well as to not distract from the non-whitespace.
Re:Xz: Can you spot the single character that disabled Linux... by deanishe on Sunday March 31, 2024 @10:29AM (#39884609)
> There's a lot of things that render as whitespace

Like what? As you note, mixing tabs and spaces is now an error.

I've never understood the objection to semantic whitespace. Complaining about having to indent code correctly strikes me as being akin to complaining about having to pee in the toilet instead of the bathtub.

Re:Xz: Can you spot the single character that disabled Linux... by capitainenemo on Sunday March 31, 2024 @03:15PM (#39887149)
there is a huge difference between having a coding standard (handled easily by a linter on commit in most languages) and making a particular whitespace indentation a critical language feature.

Bonus, if there's a good reason to change the linter format, you can do so. Rust handles this rather well I think.

Re:Xz: Can you spot the single character that disabled Linux... by katbyte on Saturday March 30, 2024 @07:01PM (#39879515)
white space as a delimiter is why i never use python.
Re:Xz: Can you spot the single character that disabled Linux... by naikrovek on Saturday March 30, 2024 @07:07PM (#39879542)
> white space as a delimiter is why i never use python.

Whitespace is a delimiter in (almost?) all languages humans use.

Whitespace determining which scope you’re in is one of the many problems of making whitespace significant.

Re:Xz: Can you spot the single character that disabled Linux... by ratmice on Saturday March 30, 2024 @08:02PM (#39879910)
Regarding your almost query. There was a debate over Ogham space mark in unicode. It is considered whitespace though, with the rationale that it is sometimes visible, but sometimes invisible. Depending upon whether the text has a stem-line. That doesn't make the set of non-whitespace delimited languages empty. Perhaps there is one with an always-visible delimiter that didn't get the whitespace justification, but does at least give one human language delimited by a printable character (which happens to be whitespace).
Re:Xz: Can you spot the single character that disabled Linux... by eru on Saturday March 30, 2024 @10:17PM (#39880741)
> That doesn't make the set of non-whitespace delimited languages empty.

Well, there's also the opposite: Goldman Sachs's Slang allows space as part of identifiers.

Re:Xz: Can you spot the single character that disabled Linux... by skissane on Sunday March 31, 2024 @06:19AM (#39882959)
> Well, there's also the opposite: Goldman Sachs's Slang allows space as part of identifiers.

Many SQL implementations permit whitespace in identifiers, but then you need to use quoted identifiers.

Re:Xz: Can you spot the single character that disabled Linux... by eru on Sunday March 31, 2024 @06:21AM (#39882968)
That's reasonably sane of SQL. In Slang, you don't need to quote. (The syntax is still unambiguous. In principle, eg Python could do something similar, because they don't have any existing syntax where you just put two identifiers next to each other with only a space in between. But C could not, because variable declaration is just two identifiers, one for the type and one for the variable name, next to each other with a space in between.)
Re:Xz: Can you spot the single character that disabled Linux... by skissane on Sunday March 31, 2024 @06:44AM (#39883090)
In Slang, are “x y” with different number of spaces in the middle different identifiers or different spellings of the same identifier? SQL standard says different identifiers

> eg Python could do something similar, because they don't have any existing syntax where you just put two identifiers next to each other with only a space in between

The interaction with keywords would cause some issues. For example, right now, “if” is not a valid identifier (keyword), but “if_” and “_if” are. However, with this proposal “x y” could be a valid identifier, but “x if” would introduce ambiguity

> But C could not, because variable declaration is just two identifiers, one for the type and one for the variable name, next to each other with a space in between

This is one aspect of C syntax I have never liked. I always wish it had been Pascal-style `x:int;` instead of `int x;`

Re:Xz: Can you spot the single character that disabled Linux... by eru on Sunday March 31, 2024 @11:26AM (#39885103)
> In Slang, are “x y” with different number of spaces in the middle different identifiers or different spellings of the same identifier? SQL standard says different identifiers

Sorry, I don't remember, and I can't seem to find it out online. I could ask my friends who still work there, if it's important. (For what it's worth, I never remember anyone complaining about mixing up a different number of spaces in their variable names. So either all number of spaces were treated the same, or perhaps multiple spaces in a row in an identifier were just banned (via linter or via language?).)

> The interaction with keywords would cause some issues. For example, right now, “if” is not a valid identifier (keyword), but “if_” and “_if” are. However, with this proposal “x y” could be a valid identifier, but “x if” would introduce ambiguity

Yes, you would need to sort out these details, if you wanted to add this 'feature' to Python.

> This is one aspect of C syntax I have never liked. I always wish it had been Pascal-style `x:int;` instead of `int x;`

I'm glad Rust made the same decision.

I do like using the 'space operator' to denote functions calls, at least for a language like Haskell or OCaml.

Re:Xz: Can you spot the single character that disabled Linux... by tomoyoirl on Saturday March 30, 2024 @07:32PM (#39879692)
“The thing that controls scope is the count of certain nonprinting characters, which happen to come in multiple widths” is reasonably insane, yes
Re:Xz: Can you spot the single character that disabled Linux... by eru on Saturday March 30, 2024 @10:16PM (#39880734)
Which non-printing characters are you talking about? Whitespace characters are very much printable.

Yes, I agree that Python should just forbid tabs. As a second best, you can tell your linter (and/or formatter) to forbid tabs (and any weird unicode whitespace). That's basically the equivalent of compiling your C with -Wall.

Re:Xz: Can you spot the single character that disabled Linux... by takeda on Sunday March 31, 2024 @02:44AM (#39881994)
This was an issue in Python 2, where for some dumb reason it allowed mixing tabs and spaces and equated tab to 8 spaces (I think). Python 3 doesn't have that issue.
Re:Xz: Can you spot the single character that disabled Linux... by capitainenemo on Sunday March 31, 2024 @03:41PM (#39887361)
Of course, if one was coding an exploit, one could still use python2. It is still commonly available due to a long tail of legacy scripts and in some cases (like a script I use routinely but didn't write) the difficulty of porting it to python3 (I've asked over a dozen pythonistas over the years, they kept running into same problems)
Re:Xz: Can you spot the single character that disabled Linux... by WirelessGigabit on Saturday March 30, 2024 @11:10PM (#39881027)
Human language is also way more ambiguous. One of the reasons I love coding is a massively reduced vocabulary and a way more strict grammer.
Re:Xz: Can you spot the single character that disabled Linux... by throwaway2037 on Sunday March 31, 2024 @05:55AM (#39882851)
Really? Another one of these comments? Do we yet have an LLM plugin for HN reader app to auto-filter them? Right up there with "When I last used Java version 5..." and "When I last used C++ in 1998..."

Guido van Rossum has a famous retort to this comment. You can find it on YouTube.

Further, if you are so easy to knock a good programming language that has more than proven it's worth at this point, you can just as easily "cancel" ALL other programming languages for equally trivial reasons. If you dare, share your favourite languages, and the votes and replies will not be generous.

Re:Xz: Can you spot the single character that disabled Linux... by raverbashing on Saturday March 30, 2024 @07:32PM (#39879698)
Yes mixing tabs and spaces is a big no no and rightfully throws an error now
Re:Xz: Can you spot the single character that disabled Linux... by worik on Sunday March 31, 2024 @04:41PM (#39887899)
Not an improvement

Tabs still have syntactical meaning and are still invisible

Python will never be a success, I predict, because of this

Trust me

Re:Xz: Can you spot the single character that disabled Linux... by fragmede on Saturday March 30, 2024 @11:04PM (#39880986)
humans are weird creatures sometimes. there was this bad thing that happened that won't happen again now, but now I can't use the thing forever because Reasons.