• Pedro (unregistered)

    The second code has a brace in a different spot. Did the editor do that when fixing the whitespace aligment? :) Also, FRIST.

  • Pedro (unregistered)

    ... not to mention different variable names for the chips.

  • (nodebb)

    Fancy misspelling "transceiver" five times.

  • that other guy (unregistered)

    I don't understand how fixing the whitespace caused the line sysIntEnablePIC (chipTwoChan[i].level); to jump into a set of braces it previously wasn't in.

  • ray10k (unregistered) in reply to that other guy

    The whitespace just hid the fact that the first for-loop didn't have a closing brace, causing the next lines to get pulled into the loop too.

  • Little Bobby Tables (unregistered)

    "Bobby, please help me debug my javascript," was a frequent plaint of a colleague of mine.

    "Certainly," I reply. "Let's format it neatly on the page, shall we?"

    "What do you mean?"

    "Indent the code consistently, and make sure the braces are positioned likewise consistently. There, you see? There's too many close braces. Oh, and you've included this assignment within the loop instead of outside it."

    "I don't understand what you did. I don't understand how you reformatted it. I don't see how it helps."

    She genuinely did not understand the concept of conventional code indentation. It was a mental block, like some people are tone deaf, and others can't read numbers, and others are colour blind. That was, to borrow a phrase from a different context, a "tough gig".

  • Karsten Bock (github) in reply to Little Bobby Tables

    I wonder how such a person would fare in python.

  • ray10k (unregistered) in reply to Little Bobby Tables

    Sounds a lot like my mother re. anything computer related. "OK, so I used to click this menu here, then that option, then OK to save, but the latest update moved the menus around! Help" "Have you tried the menu with the same name yet?" "...No, but can you please come over and show me?"

    I love her to bits, but she's just not very confident around computers, to the point where she doesn't even try.

  • Poxun (unregistered)

    I hate to say it but the nested loop fubar was obvious even with the messed up formatting. If you need known bugged code to be perfectly indented to read it you might want to consider a change of job.

  • capt bullshot (unregistered)

    It's all about the "editors" having their own ideas of how to indent my code.

    Back in the times, I did indent everything manually and was used to use a rather "dumb" editor. Code was consistently indented. Today, sometimes I do edit the same code on three different computers, each one has the same editor (Same in the sense of the same name, but not the same version). Each time I indent the code on one of these, one of the other completely fucks up with that. Code looks ugly and randomly indented today.

    Why the heck do the makers of such kind of editor (won't name it) cannot use consistent default settings for tab size, auto indenting and all the stuff. Or one simple global setting: "Disable all automatic indenting once and forever and don't use tabs at all".

  • (nodebb)

    Last time I worked on an embedded box with a serial interface I had to do an install in Paris. I tested the box thoroughly before we shipped it, and everything looked fine. Got it on site, and it did nothing except light a few LEDs. Hooked up the serial diags. Nothing....

    Turns out the hardware guy had tidied the CPU board up, and had decided to rotate two of the charge pump capacitors, so they all faced the same way and the pick-and-place machine had an easier time, but he forgot to move the tracks. The electrolytic caps had been fine reverse connected in the lab, but at some point between me testing the port and needing it in earnest, they'd blown.

    The other, more fundamental problems with the box weren't his fault though, so I forgave him.

  • tbo (unregistered) in reply to Little Bobby Tables

    There's a big push to include more women in STEM and coding, and while I'm not opposed to more women, I am opposed to encouraging anyone to code who doesn't have an aptitude for it and desire to do it.

    That's why.

  • Dave (unregistered) in reply to Little Bobby Tables

    Your (or my) poor teaching ability doesn't equal an inability to comprehend the concept, it just equals an inability to understand your explanation of it.

    If someone doesn't understand your explanation, maybe they should, and are an idiot for not understanding, but that doesn't help you as much as an explanation they do understand. In my experience with enough patience you usually find that there's something really basic that you're each thinking of differently, and once that's cleared up you can talk to one another productively.

  • (nodebb)

    For you youngsters out there, way back (prehistoric times), the entire AT&T network crashed. After a couple weeks of OMG HACKERZZZ and all sorts of threats including death and worse for whoever had caused every AT&T relay to shut down, the software forensics folks found a curly brace off by one line. That led to one relay trying to reset and issuing resets to its direct neighbors, who then tried to reset and issued.... you get the drift.

    I think it's in one of MItnick's books or Stephenson's In the Beginning was the Command Line.

  • Brian Boorman (google) in reply to ray10k

    Maybe, for some insufferable reason, your mother just misses you and uses this as an excuse to make you come see her while she's still alive.

  • Brian Boorman (google) in reply to ray10k

    Maybe, for some insufferable reason, your mother just misses you and uses this as an excuse to make you come see her while she's still alive.

    Addendum 2019-02-25 11:51: Edit: Click button once, get two submissions. TDWTF must be running a Groupon promotion or something.

  • get off my lawn (unregistered) in reply to ray10k

    Muscle memory.

    A recent change to one of our applications was moving a menu from the top of the page to the side. Other than having icons, which weren't there before, everything is the same. Yet everyone is finding themselves going to where the menu used to be, sometimes clicking that spot and having to deal with the unintended consequences.

  • get off my lawn (unregistered) in reply to capt bullshot

    I experienced one editor which automatically converted between spaces and tabs depending on hidden rules, which was tolerable until you tried editing tab delimited files...

  • I dunno LOL ¯\(°_o)/¯ (unregistered)

    I long ago got the religion of putting braces on EVERY control statement in which they were optional. Look up the "goto fail" incident for one of the reasons. Literally the first thing I do (usually fighting the editor's auto-indent while doing so) is to put both braces in place, and then I start working on the code that goes inside them.

  • Christian (unregistered) in reply to get off my lawn

    Editors that automatically convert spaces and tabs are horrible if you want to use a version control system efficiently. So I would strongly suggest to use another editor if that behavior isn't changeable.

  • PageTurner (unregistered) in reply to capt bullshot

    I think the Captain is looking for 'editorconfig' https://editorconfig.org which is designed to give consistent formatting across editors.

  • Klaus (unregistered) in reply to Karsten Bock

    I guess when you are told "indent or it doesn't work", you can skip the arguments.

  • (nodebb)

    What are people using to write their code? I mean pretty much anything that isn't traditional vi does highlights matching braces/brackets/curlies/parentheses. Are people just not even bothering to do even the most basic checks on their code?

    Like how hard is it for these people to just highlight an opening character and inspect where is match is?

  • xtal256 (unregistered)

    ( Easy Reader Version: While I'm still not entirely sold on pure whitespace languages, like Python (despite doing loads of Python these days), I recognize the value in saying: you should be using whitespace anyway, so why NOT make it our way for identifying blocks? )

    But you shouldn't be using whitespace, at least, not explicitly. The language should provide a way of delimiting blocks (such as { and }) then and auto-formatter can do all the whitespace stuff. Way easier than manually doing it. And yes, I have used languages which do this, so it is possible.

  • sizer99 (google)

    This is one reason python is great. I know, some people just can't wrap their head around it, but what you see is what you get for program flow. You can't fail to understand what it's doing, which is the whole point of python - readability.

    Unless you're an evil/lazy SOB and use 1-space indents, which I've seen before.

  • xtal256 (unregistered) in reply to get off my lawn

    These problems would all go away if everyone used Elastic Tabstops: http://nickgravgaard.com/elastic-tabstops/

  • (nodebb)

    Original submitter here. This was one of the least WTF parts of that whole project, but the most easily submitted.

    There was the typical no source control, with an added dose of 'new' backup copies showing up over time. The copies had no easy way to place them in order, and in some cases there were multiple branches of development, again with no way of telling which was which. I ended up having to play evolutionary biologist to even make sense of what I had. The older copies were even for older hardware that had a different set of serial chips. For those of you noting that the 'fixed' version changed more than whitespace, I must have grabbed the wrong broken version when submitting or submitted an otherwise edited version. Or perhaps moved things around when fixing the whitespace. This wasn't the kind of shop that had tools to fix such things, it was all by hand.

    And yes, once I did more than skim past this function and actually looked at it, the error was instantly obvious. The real trick was knowing that the problem was the interrupts (we assumed for a long time that we weren't even booting that far, a problem acerbated by the post code LEDs being on the side of the motherboard that was hidden by other packaging, leading us to assume there weren't any at all).

    As for what we used to edit the code, I was using notepad on Windows XP. On a box we had to pull out of storage, because the entire toolchain was that old. But it was better than the 90s era C++ compiler for a different project. I was never able to convince my colleague to upgrade that one...

  • Gerry (unregistered) in reply to sizer99

    This is one reason python is great. I know, some people just can't wrap their head around it, but what you don't see is what you get for program flow. You can't fail to understand what it's doing, which is the whole point of python - readability.

    FTFY My only Python experience so far was helping my son debug his homework. Whatever tool set he was using resulted in a mix of space and tabs. Looked OK, but was completely off kilter. I pasted into Notepad++ with "Show All characters" enabled, and immediately saw the issue.

  • Friedrice the Great (unregistered)

    Silly Python! Tabs are for kids!

  • RichP (unregistered) in reply to RobyMcAndrew

    "Turns out the hardware guy had tidied the CPU board up, and had decided to rotate two of the charge pump capacitors, so they all faced the same way and the pick-and-place machine had an easier time, but he forgot to move the tracks. " The pick-and-place doesn't care about the orientation. There's 25% chance it has to rotate all of the caps anyway, depending on how the board is oriented on the machine and how the parts come on the reel. Most machines will rotate while the head is moving, so there's no throughput advantages either. People manually inspecting the boards will appreciate a consistent orientation, as will the end user who gets more reliable boards, so it is a good practice. Modern PCB design tools make it fairly hard to do what your hardware guy did. Some make it surprisingly easy to drag tracks over each other creating a short. Good reminder to always re-run your design rules checks after making changes. Oh, and obligatory comment: Remy, you were lucky. RGB LEDs? hah, in my day you got eight red LEDs and an 8-bit shift register, and we liked it.

  • (nodebb) in reply to Poxun

    Agree with you there. The formatted code didn't make much clearer because some quick analysis had already found that the first loop wasn't closed.

  • Jeff (unregistered) in reply to tbo

    Interesting that you equate women with not having the aptitude or desire for a career in STEM .

  • Dave (unregistered) in reply to xtal256

    Thanks for that, I can always use a good laugh. So, he's defined tabs wrongly - they're very much not just a bunch of spaces - and then his solution to the problem he's invented is... The conventional definition of tabs.

  • Shortest Circuit (unregistered)

    Or they could do what Woz did when he couldn't figure out the 6502's interrupt handling: just sit in a loop and check over and over if some data appeared.

  • (nodebb) in reply to Poxun

    Tell this to the camelCasing cult.

  • (nodebb)

    Unless you're an evil/lazy SOB and use 1-space indents, which I've seen before.

    I once saw C code that had been written with an 8 space (8 spaces, not a tab) initial indent, and one space per level thereafter. Reading that was way harder than it should have been.

  • (nodebb)

    Huh, that grouping of 4-to-2 and 2-to-1 fooled me into thinking that a nested loop was needed.

    Although I still don't like the way chip 1 is inconsistently also the UART.

  • jgh (unregistered) in reply to Little Bobby Tables

    I've had times like that. Just yesterday: Them: I've scanned my signiture but I can't get it into my (Word) document. Me: sits down, inserts signiture. Me; So, what's going wrong? Them: How did you do that???? Me: Well, you wanted to INSERT the PICTURE of your signiture into your WORD document, so opened your WORD document (points), and INSERTED (points) the PICTURE (points) of your signiture.

    They had some sort of expectation that the scanner software was a word processor, and were insisting that it was at fault for not being so.

  • owlstead (unregistered)

    Of course, the counter being initialized out of the for loop and the ridiculous reuse of it in the next loop should be an obvious hint.

    However, C / C++ compilers by a little company called Microsoft famously declared it outside the for loop even if it was in declared in the first expression of the for statement, so the declaration may be just to make sure it is declared at the same place for all compilers.

    Still, reusing the variable i here is not acceptable practice and this error would not have occurred for modern compilers if the counter was not reused. Just re-declare the counter already!

  • Duke of New York (unregistered) in reply to xtal256

    Problem: Devs don't understand tradition tab stops, as simple as they are. Solution: given them new, fancier tab stops.

    Sorry, no.

  • tlhonmey (unregistered)

    If you've got three LEDs to debug with, use two for data bits and one for a clock bit and then tape an arduino with optical pickups and an LCD to the front of the box and go back to printing sensible error messages. If you want more bits some optical pass filters will let you take advantage of the RGBness.

Leave a comment on “The Serial Killer”

Log In or post as a guest

Replying to comment #503584:

« Return to Article