Dev Tools rant


  • 🚽 Regular

    Why is is that all Dev tools are hot garbage? From IDEs to actual hardware tools we are expected to put up with barely functional tools just because we are developers. It's almost embarrassing how often Visual Studio explodes with a 'helpful' error message, for example.

    I've just spent 3 hours trying to troubleshoot a problem with a new board, I'm using an ICD 4 hardware debugger, this is an expensive in-circuit debugger with RGB lighting:

    eb196c1a-99d9-4496-8796-1c34292b0dac-image.png

    This code was failing, error_message_fail_counter was incrementing from 0x00 straight to 0x02 and getting stuck there forever:

    if (++error_message_fail_counter >= MAX_ERROR_MESSAGE_FAILS_PER_HOUR)
    

    The disassembly looked fine:

    09b3485d-85b1-46d8-a709-8baab3416b18-image.png

    OK, lets change it to:

    error_message_fail_counter++;
    if (error_message_fail_counter >= MAX_ERROR_MESSAGE_FAILS_PER_HOUR)
    

    This works as expected! So, what's different in the assembly that could possibly cause this??

    b3a6d582-0bc0-4b1c-8e55-041754ce2b41-image.png

    So...it's identical...it was a tool issue. I hope everyone at Microchip comes down with some terrible venereal disease :fu:


  • Considered Harmful

    :trwtf: is if statements with side-effects.



  • @error You're right, with the exception of this sort of construct:

    if (DoSomethingUsefulThatReturnsTrueIfItSucceeded()) {
        log.error("Something useful was done! :doing_it_wrong: ");
    }
    

    e: But in this case the if statement isn't the star of the show, it's whatever the thing is actually doing.


  • 🚽 Regular

    @error said in Dev Tools rant:

    :trwtf: is if statements with side-effects.

    Even for a timeout counter like this? I'll stop doing it if it's considered bad form.


  • ♿ (Parody)

    @Cursorkeys said in Dev Tools rant:

    @error said in Dev Tools rant:

    :trwtf: is if statements with side-effects.

    Even for a timeout counter like this? I'll stop doing it if it's considered bad form.

    People often miss the side effect when reading the code. Also, you have to be careful about prefix vs postfix operators and how they affect the execution, which is a problem that a separate statement doesn't have.


  • Considered Harmful

    It's definitely still a devtool wtf, but I'm guessing you're looking at a heisenbug because the debugger is evaluating the if condition multiple times. So, in this case, it's more than a good practice: it's actually a workaround.

    In general, though, you want your code to be understandable to a junior maintenance dev just skimming the code quickly for the first time. You even verified it yourself: separating out the increment to a different line didn't affect the emitted code at all, so it's increased readability at zero cost.


    Filed under: And you get paid for one more SLOC


  • BINNED

    @Cursorkeys said in Dev Tools rant:

    So...it's identical

    You clearly have a different "Program Memory" tab selected.


  • 🚽 Regular

    @Cursorkeys said in Dev Tools rant:

    Why is is that all Dev tools are hot garbage? From IDEs to actual hardware tools we are expected to put up with barely functional tools

    As a software developer yourself, you of course know the reason.

    Developing good software takes time and patience and less pressure to market.


  • kills Dumbledore

    @hungrier said in Dev Tools rant:

    @error You're right, with the exception of this sort of construct:

    if (DoSomethingUsefulThatReturnsTrueIfItSucceeded()) {
        log.error("Something useful was done! :doing_it_wrong: ");
    }
    

    e: But in this case the if statement isn't the star of the show, it's whatever the thing is actually doing.

    Why would you log an error that something useful succeeded?


  • 🚽 Regular

    @kazitor said in Dev Tools rant:

    @Cursorkeys said in Dev Tools rant:

    So...it's identical

    You clearly have a different "Program Memory" tab selected.

    It's the same data, I promise. You can have multiple identical tabs open. I assume it's a bug.


  • Considered Harmful

    @Jaloopa said in Dev Tools rant:

    @hungrier said in Dev Tools rant:

    @error You're right, with the exception of this sort of construct:

    if (DoSomethingUsefulThatReturnsTrueIfItSucceeded()) {
        log.error("Something useful was done! :doing_it_wrong: ");
    }
    

    e: But in this case the if statement isn't the star of the show, it's whatever the thing is actually doing.

    Why would you log an error that something useful succeeded?

    Because he's writing a dev tool?



  • @Cursorkeys It's not bad form. It's unfortunate that an offshore replacement duhveloper may change code without understanding it but that's on them, not you. It would be a different story if it was spaghetti code spread across 17 files but it's right there in the if statement.


Log in to reply