23

The 8 year old is learning Python, and after a dealing with a syntax bug she asks: "If the computer knows I'm missing a semicolon here, why won't it add it itself?"

I don't know. I really don't know.

Comments
  • 21
    Because most of the times it's impossible to tell whether you've missed a semicolon or added a line break in the wrong place.

    You don't want it to start "fixing" such issues by altering your code, because that will lead to obscure bugs.
  • 17
    @iiii obscure bugs like javascript - which has "just asume what might have been the intention and do whatever, lol screw error messages" as main paradigma.
  • 4
    @tosensei exactly!
  • 6
    Re: Re: Re: Fwd: Fwd: Fwd: hahahaha kids are so smrt!
  • 11
    "semicolons in phyton"

    but why
  • 0
    The error message was just a suggestion. It's not 100 percent certain that you are missing semicolon. If IDEs start making assumption and start adding punctuations everywhere by themselves, soon everything will crash and be gone.
  • 2
    @SuspiciousBug you mean: "why python"?
  • 3
    @iiii: This.

    But also: Don't use semicolons in Python code!
  • 0
    When a compiler parses code it uses the rules which say this must go together with this or this with this, etc.

    Problem is that some items have multiple different things which can be at one place like detecting an expression in a statement, there is no way for a compiler to know whether you actually wanted to continue the expression spanning multiple lines or to end it with a semicolon so it just says what it expects at the place and lets you figure it out. :)
  • 0
    @SuspiciousBug Username checks out.
  • 1
    imagine all the time you used to fully cook an egg, then suddenly this AI-Equipped SmartStove™ fix your all-you-wanted-all-day-is-a-perfectly-half-cooked-egg.
  • 2
    it doesn't know.
    it just assumes a mistake at the first moment the code stops making sense to it.

    it's just the nature of how it makes sense of the code that it's often right, even though it's basically by accident, and only in the most trivial cases.

    also, python and semicolons? wat?
  • 2
    @SuspiciousBug I'm pretty sure they mean colons (or maybe the whole thing is made up). Missing colon is the missing semicolon of python.
  • 0
    @electrineer i got serious dejavu reading this so I'd go for option 3
  • 0
    @Oktokolo I'm a person of cultural, I don't use semicolons in Python but use 4 spaces instead of a tab.
  • 2
    @TestInProd423: Everyone uses four spaces for indentation. Any deviation from that would be a sure sign of insanity.
  • 0
    @Oktokolo how about three?
  • 2
    @iiii: A sure sign of commitment issues.
  • 0
    @Oktokolo Lots of people use tabs for accessibility. Much like the color of text, the typeface and the font size are up to the environment and eventually the developer, so should be the representation of blocks. It's crucial that standards are set and followed on the scale of a codebase as to whether indentation should be with spaces or tabs, but beyond that tabs allow devs with small screens or bad eyesight to set indentation to two spaces and save screen real estate.
  • 1
    @lbfalvy: Nah, the 120 columns limit solves that.
  • 1
    @Oktokolo any person with a brain uses tabs for indentation because that's their semantic meaning, and set their visual width in their IDE to equivalent to 4 spaces if they want it like that.

    sorry, but using spaces to indent code is the same as using spaces to center text in word processors.
  • 1
    @Midnight-shcode and then there's GitHub which displays tabs as 8 spaces. No, thank you
  • 1
    @Midnight-shcode I actually use 4 spaces in most of my existing projects because I felt it was more popular and I wanted to comply. I only really thought about the accessibility argument a few months ago.

    @Oktokolo You're making the same assumption just at a different level. I use a laptop and I need 20pt font size so my column width is 74 characters.
  • 1
    @lbfalvy cool, at least you started thinking about it :)

    but i personally am not even that concerned with the accessibility part =D. as i said, what irks me personally the most is programmers - people whose job it is to use symbols in their correct semantic meaning - ignoring the proper semantic usage in such an elementary case as indentation.
  • 1
    @lbfalvy: I used 80 columns as hard limit for 20 years until i finally decided to adopt the ultra-wide 120 columns standard as a compromise because everyone else insited on having no limit whatsoever... I still use 80 columns as soft limit for most code.

    80 as a soft limit actually is nice when resolving merge conflicts or doing a line-by-line cherrypick.

    The column soft and hard limits are always a compromise. 72 to 80 are the traditional limits from the previous century where we had to use low-resolution CRTs. 120 still yields plenty of old fart comments. But it is at least possible to coerce other devs into accepting it.
  • 1
    @Oktokolo Tab-based indentation isn't a compromise.
  • 0
    @lbfalvy: Of course not - it is either tabs or spaces for indentation. Can't compromise and have both.

    And spaces have won the war. Tabs are obsolete now - together with carriage returns, form feeds, the bel and other control characters from the teletype era. Only survivor is the monospaced font - because it actually is easier on the eye for texts with high accuracy requirements (like code).
  • 0
    @Oktokolo None of the other characters you listed have a function, Tab does and that function is currently fulfilled by a device less appropriate. Among the problems arising from this is the need to make compromises with line widths.
  • 1
    @lbfalvy even with tabs you'll still need rules about line size
  • 1
    @iiii Yes, but the rules can be laxer because the narrowest screens can be set to 1-space tab width.
  • 2
    @lbfalvy still not something like 200+ characters wide 😁
Add Comment