• (nodebb)

    Pretty stupid to show us the "correct" version first. That's the real WTF. And also, the O / 0 difference is trivial and easy to spot just scanning the code.

  • Retired Oracle DBA (unregistered)

    O versus 0 (zero) was the first thing I looked for. I still slashed my zeros for a couple decades after it became unnecessary.

  • FTB (unregistered)

    It was the only thing that COULD have been wrong in that code.

    But yeah, it happens. There's a reason why you don't use upper-case o or lower-case L as variable names.

  • (nodebb) in reply to DonaldK

    As a programmer who worked for a company that developed a version of BASIC, the difference between 0 and O was hard to see on a glass tty. Back in those days i had a problem with " " where I meant to have a space but it was actually a tab character in a column that was a multiple of 8. I was just learning 'vi' and now I make use of the :set list command. :-)

  • Brian (unregistered)

    Reminds me of college. I was a T/A for a programming class, and one of my students brought in some code for help. "I don't understand it," he said, "it's too short to have any bugs in it!" I find myself saying that all the time...

  • (nodebb)

    Some errors are hard to spot if you've never seen them before, like this one: if (x = 0) { \* Whyyyy doesn't it execute this code. *\ }. That one got so many that some courses taught the students to put the constant first in the comparison because if (0 = x) would produce a compile-time error, preventing the bug. Some newer languages will either warn you or straight up fail to compile but in C and C++ never failed to provide interesting ways to shoot ourselves in the foot.

  • (nodebb) in reply to DonaldK

    the O / 0 difference is trivial and easy to spot just scanning the code.

    I look forward to seeing how you do on your second rodeo, sir.

  • (nodebb)

    I have to admit that I totally didn't see anything like that coming, completely not at all.

    And now that you're all back from finding how many floors below you the sarcasm dripping off your screens from the sentence above managed to eat its way through (ref: Alien), I'd like to apologise.

  • (nodebb) in reply to Rick

    That's evil.

    I remember creating batch files named chr(255) .bat somewhere in the path on people's PC's and putting them in the autoexec.bat (you didn't need to say it's a batch file IIRC). It showed up as an empty line with invisible content. It would run anything that was in my batch file (fun irritating stuff, you know), and it would only stop running on boot-up if they completely replaced their autoexec.bat with a new one or deleted all empty lines. Very few peeps would think to inspect a text file with a hex editor... Fun times.

  • Hanzito (unregistered) in reply to Steve_The_Cynic

    This reader, the syntactic effort putting a subordinate clause in a subordinate clause requires appreciating admits to being somewhat surprised too. I thought the problem would be that FOR I = 1 TO 0 (zero, that is) runs once in some dialects.

    Didn't need no complex test, Nobody worried about REST, Gee our PET 2001 was the best, Those were the days

  • Joe (unregistered)

    It's hard for me to believe that, blurry CRTs or not, this problem would hang up "an entire computer science department." Like just about everyone else, I assumed that was the issue as I was reading the corrected code. Nobody thought to say to his peer "I totally believe that you typed O there but can you humor me and replace it with an O and see if it works?"

  • NotAI (unregistered)

    In that era, many CRT monitors and TTY/teletype terminals were only UPPERCASE, such as the Data General terminals I used in high school. Not much variety in fonts. We had a line-printer and one or two terminals that could show us lower case characters. We only worked in that line-numbered BASIC so we did learn to hash or zero, and reading them on paper or screen was something we noticed. If I recall correctly, the output on the teletype was also slanted a bit to the top-right. Not to indicate italics, but just for readability. Any of this was at least 5 years before the first time I saw the Internet, Unix or anything about networking.

  • (nodebb) in reply to Hanzito

    @Hanzito -

    An "All in the Family" reference? We are a really old crowd here.

  • (nodebb)

    Plus back in those days many typewriters didn't have a 0 (zero) key, so you substituted an O (oh) instead.

  • (nodebb)

    Thank you for the reference to Dartmouth Oversimplified Programming Experiment. I had never heard of it before, but it makes sense that they were experimenting with languages that led to BASIC.

    See https://en.wikipedia.org/wiki/Dartmouth_Oversimplified_Programming_Experiment.

  • Miles Archer (unregistered)

    To be honest, the first thing I checked on the original snippet was that the O was an O and not a 0.

    I leaned to program on Altair 4k BASIC, so this is kind of a natural thing for me.

  • (author) in reply to Joe

    That is what the submitter claimed, and my reason for believing it is that the code exists in a broader context. When you whittle down to the lines that are actually the problem, it's easy to spot. But when you've got hundreds of other lines to filter through, when you're getting dropped in by a junior/student dev who's like "It doesn't work and I can't figure it out," I can 100% see how that "O" hides out for awhile.

    I've seen similar things happen with missing semicolons, though maybe not a "whole department".

  • (nodebb)

    In the early '80s, had a friend who was doing some outside-of-class work in Fortran77 and suddenly started seeing divide by zero errors. Traced it down to a line that contained "/4". Took him a fair bit of time to realize that in trying to debug somewhere else in the routine he had inserted "4 = 0". As Remy said, easy to spot in isolation, harder to spot in the midst of a big chunk of code with dodgy display fonts.

  • (nodebb) in reply to Llarry

    somewhere else in the routine he had inserted "4 = 0".

    So we're back to variable names frist?

  • lemgandi (unregistered)

    Back in the day, I worked on Vermont Views. It had a macro to make a borderless window, which was unfortunately called "BDR_P0". And I was the hero who figured out that it was BDR_P(Zero), not BDR_P(cap O). Good times.

  • (nodebb) in reply to FTB

    Keep on mind that in that era, it was not uncommon to have just a single casing, typically UPPER case. I do recall some systems having a slash inside of zeros to disambiguate.

  • (nodebb)

    This is why I use a font specifically designed for coders -- with a proper slashed-zero and serifs to make 'one' and 'lower-case L" easily distinguishable.

  • Pr0methean (unregistered)

    I wonder how anyone making a Danish-based programming language would've coped, since they'd need O, 0 and Ø.

  • Lurk (unregistered)

    Now; it /was/ a long time ago (in a galaxy far, far away), i.e. about 1977, and memory fades so I could be misremembering, but I'm convinced that in the first implementation of BASIC I used on a SWTPC 6800 O (letter) and 0 (number) could, in some circumstances, be used interchangeably. Oh what larks.

  • (nodebb) in reply to n9ds

    My first typewriters lacked 0 and 1 keys, so one had to use capital O and lower-case l to write numbers. I seem to remember early programming manuals reminding people to use the number keys instead of the letter keys, but I couldn't find an example. I do remember the "joy" of moving back and forth between a PLATO® keyboard (with the 0 key to the left of the 1 key) and a normal computer keyboard (with the 0 to the right of the 9 key).

  • (nodebb)

    I did work experience at the local town council and found a lot of entries in their system where the number 0 had been placed instead of the letter o. I also recall helping someone writing a problem in BASIC for the Apple II. They were getting the same random result every time. I realised they'd set the seed value to 0.

  • Ray (unregistered) in reply to AGlezB
    Comment held for moderation.
  • (nodebb)

    It's why I use the DOS VGA font as my text editor and terminal fonts. Those VGA fonts were made to make common letter pairs distinct and I prefer it much over the other "terminal" fonts commonly shipped. They were originally made for CRTs so they retained their distinctiveness.

    (www.int10h.org is where I got mine).

  • (nodebb) in reply to Bananafish

    in fortran it was possible to change the value of literal 4 to 0 by a function call, something like this:

        call wibble(4)
        a=a/4
    

    C At this point the program will crash

    Subroutine wibble(i) i=0 return

    NB I don't remember the exact syntax cos this was fortran iv. and 45 years ago.

    Addendum 2025-10-29 18:03: sigh lets try again

    call wibble(4)
    a=a/4
    ....
    Subroutine wibble(i)
    i=0
    return
    
  • (nodebb) in reply to thosrtanner

    in fortran it was possible to change the value of literal 4 to 0 by a function call

    I can accept that some FORTRAN compilers did as you say. However, my experience with VAX FORTRAN back in 1985 was different; that code wouldn't crash because each instance of a hard-coded number was a separate memory location. You have two "4"s so that would have been two places, and only the first would be set to zero, leave the "a=a/4" to work correctly.

    But the passing mechanism was indeed "by reference" even for constants, so code like this would crash on a VAX:

    DO I = 1, 5
        CALL WIBBLE(4)
    END DO
    ...
    SUBROUTINE WIBBLE(N)
        PRINT N
        N = N * 2
    RETURN
    

    would result in

    4
    8
    16
    32
    64
    
  • John (unregistered)

    People have mentioned uppercase terminals. But I recall that they also had slashed zero characters.

  • (nodebb) in reply to Joe

    When I was, ahem, "learning" coding, which is to say copying someone else's code and mutilating it till it did what I wanted, I eventually graduated to writing some short snippets by myself. Being nearsighted, I confused a period for a comma in several expressions, and you can guess what happened next.

Leave a comment on “A Basic Mistake”

Log In or post as a guest

Replying to comment #:

« Return to Article