this post was submitted on 13 Oct 2023
722 points (93.1% liked)

Programmer Humor

32410 readers
1 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS
all 41 comments
sorted by: hot top controversial new old
[–] pixelscript@lemmy.ml 59 points 2 years ago (2 children)

It's 2023. If you're not using an IDE or a highly extensible text editor with simple static analysis features, I really don't know what to tell you.

[–] GigglyBobble@kbin.social 32 points 2 years ago (1 children)

I had to read it repeatedly and check if it really said "syntax error". What will those people do if they encounter their first race condition?

[–] Arigion@feddit.de 10 points 2 years ago (1 children)

They insert sleep(1) and print statements. No shit. I had to fix this in two projects. One was a complete rewrite.

[–] AVincentInSpace@pawb.social 2 points 2 years ago* (last edited 2 years ago)

Reading this made me nausesous. I feel your pain.

[–] qaz@lemmy.world 2 points 2 years ago* (last edited 2 years ago) (3 children)

Clang won’t tell you if you’re missing a return statement, even with all warnings on and will just let it crash during runtime. Static analysis won’t save you from all stupid mistakes.

[–] pixelscript@lemmy.ml 12 points 2 years ago (2 children)

Static analysis won't save you from all of them, but they will definitely save you from the great majority of the ones ProgrammerHumor seems to get worked up about.

I still see people sharing ancient memes about pouring over code for hours looking for mismatched curly braces, missing semicolons, and greek question marks. These and the bulk of minor syntax problems like them should all be complete non-issues with modern tooling.

[–] TunaCowboy@lemmy.world 5 points 2 years ago (1 children)

clangd should have warned you about this before you even considered compiling.

[–] qaz@lemmy.world 2 points 2 years ago

Thanks, I’ve tried it and it works a lot better than the built in intelli-sense.

[–] sonymegadrive@feddit.uk 3 points 2 years ago (1 children)

Clang won’t tell you if you’re missing a return statement.

Is this C++? Have you got some code examples?

I’ve been writing C++ for 20+ years and the last compiler I encountered this with was Borland’s. In the late 90s.

[–] qaz@lemmy.world 1 points 2 years ago* (last edited 2 years ago) (1 children)

It's on the company computer, but I have a backup from earlier today that seems to have the same code.

bool load_metadata() {
    uint8_t marker_field = EEPROM.read(0);
    // Write to ROM if marker has not been set
    if (marker_field != MARKER) {
        metadata = {
            0,
        };
        EEPROM.put(1, metadata);
        EEPROM.update(0, MARKER);
    }
    else {
        EEPROM.get(1, metadata);
    }
}

I have to admit, my experience with C++ is rather limited, last Monday was the first time in my life that I used a C++ compiler. I had some issues getting it to work with Visual Studio, so I ended up using VS Code WSL with clang 😅.

[–] sonymegadrive@feddit.uk 2 points 2 years ago (1 children)

Does this compile with -Wall -Werror? (might not be an option if your dependencies’ headers contain warnings)

Looks like it may be embedded code for a SoC or similar. The only things I can think of is that the tool chain you’re using maybe non-standard… or you’re invoking the dreaded Undefined Behaviour somewhere :(

[–] qaz@lemmy.world 1 points 2 years ago* (last edited 2 years ago)

I didn’t use -Werror but no warning about it showed up either. The project uses a semi-custom toolchain for a microcontroller, but I’m not using it to compile this code. I have another file with an entrypoint which tests some classes to be used by the microcontroller. The EEPROM in the code example is actually a macro for a class I’ve written that emulates the EEPROM library by writing and reading to a file on disk.

It’s a bit of a mess but this dual toolchain setup seemed easier than emulating the board and peripherals in it’s entirety. I might have to retry that though using Wokwi.

[–] Synthead@lemmy.world 24 points 2 years ago

Read your errors fully, kids

[–] Cornelius@lemmy.ml 21 points 2 years ago

Dynamically typed/interpreted language?

Python Yup that checks out.

I've never understood why so many languages insist on a feature that causes such a obtuse and tedious programming experience.

Python is great, until you don't remember a function call, and can't guess using your LSP to tell you. :/

[–] dan@upvote.au 19 points 2 years ago (1 children)

As someone with 20+ years coding experience, this only gets worse as you get more experienced.

[–] MajorHavoc@lemmy.world 8 points 2 years ago (1 children)

Yes. I tell my mentees this all the time.

Decades ago, as a new developer, I expected to stop getting stuck like this.

Instead I get stuck, like this, on really interesting problems with really valuable solutions.

So that was a fun surprise, I guess. Lol.

[–] Stumblinbear@pawb.social 4 points 2 years ago* (last edited 2 years ago) (1 children)

I was stuck on a problem for six months, and after figuring that out I banged it out in an afternoon. If anything you get stuck for even longer

[–] dan@upvote.au 3 points 2 years ago (1 children)

If I'm stuck on something for more than a few hours, I ask one of the more junior developers on my team if they have any ideas. Sometimes, a new perspective helps a lot!

[–] Stumblinbear@pawb.social 3 points 2 years ago

Unfortunately it was for a personal project and nobody else understands the system so, haha

[–] dingleberry@discuss.tchncs.de 15 points 2 years ago

There are way too many Notepad enthusiasts out there.

[–] AVincentInSpace@pawb.social 15 points 2 years ago* (last edited 2 years ago)

You should switch to Rust. Through massively impressive feats of compiler engineering and a phenomenal amount of novel syntax constructs that make Rust the hardest language for existing programmers to learn, the rustc team has successfully managed to move this agony from after the program compiles to before.

This is clearly an improvement.

[–] MajorHavoc@lemmy.world 11 points 2 years ago

I have gained nothing from this experience and will do it again.

Whichever vendor or framework puts that on a shirt will get free advertising from me.

[–] LolaCat@lemmy.ca 10 points 2 years ago
Image Transcription:

number-1-haxorus-fan

[In large text]
The coding experience:

"Okay, everything looks good, time to run it"
Code fails
"What? Let me try again…"
Code fails
"What the fuck, where's the issue???"
Checks syntax error
"GOD DAMN IT TELL ME WHERE THE FUCKING ISSUE IS YOU PIECE OF SHIT"
Hopelessly tries to fuck around with the code and find the error
"PLEASE PLEASE JUST WORK WHY WON'T YOU WORK-"
Notices obvious error that I should have noticed like 15 minutes ago
"Oh. I'm a fucking idiot."
Code works now
"I have gained nothing from this experience and I will do it again"

#coding #coding pain #python #coding hell
#this is from painfully personal experience
#but replace 15 minutes with a fucking hour

57 notes

[–] Vishram1123@lemm.ee 8 points 2 years ago

Me and my cs prof i'm TA'ing for trying to debug two swapped lines for an hour yesterday be like

[–] tiredofsametab@kbin.social 7 points 2 years ago

Write smaller units. Test those units. Save time.

[–] tdawg@lemmy.world 5 points 2 years ago

Hey at least they didn't have to trace a bug in their core framework. Only to find it is both in the issue tracker and 10 years old, and there is no offical fix. So you have to make a hacky patch yourself

[–] WhyYesZoidberg@lemmy.world 5 points 2 years ago (1 children)

15 minutes.. rookie numbers

[–] _dev_null@lemmy.zxcvn.xyz 3 points 2 years ago

I've spent more time wondering if I farted and forgot or if it was the guy in the cube next door.

[–] xantoxis@lemmy.world 4 points 2 years ago

The thing is, you don't make syntax mistakes on purpose. Especially if you know a language extremely well, a syntax error will happen at random, you won't notice it (if you did, you would have fixed it), and it therefore becomes invisible to you.

Part of your brain "knows" there's no error, because you know the language extremely well, and because if you had made an error, you would have fixed it.

This leads to acute, irrational frustration. It's very human.

There's not really a solution, just smoke more weed and take your eyes off the screen occasionally.

[–] wraithcoop@lemmy.one 4 points 2 years ago

I've learned that in these scenarios, show it to somebody else. They'll see the stupid mistake you made within seconds.

[–] dandroid@dandroid.app -2 points 2 years ago

Just use a debugger.

[–] Knusper@feddit.de -4 points 2 years ago (2 children)

I mean, it's not unlikely for a programming beginner to write Python, but I certainly had a hunch this was Python before reading to the end.

So, yeah, this is at least partially the Python experience, not generally the programming experience...

[–] tdawg@lemmy.world 2 points 2 years ago (1 children)

As someone who has taught people a variety of languages. No. This happens regardless of what language you choose. It's just a universal programmer experience to get frustrated at your work

[–] Knusper@feddit.de 1 points 2 years ago (1 children)

I am not saying that you don't get frustrated at your work in other languages. I'm saying this particular frustration is characteristic.

[–] tdawg@lemmy.world 1 points 2 years ago (1 children)

What issue is that you think is unique to python?

[–] Knusper@feddit.de 1 points 2 years ago* (last edited 2 years ago) (1 children)

Well, I'm not just talking about issues.

everything looks good, time to run it

This sounds like they did not or could not explicitly compile it. Pretty much all popular languages are compiled. JS isn't, but people are less likely to say that they 'run' that one. Ruby isn't, but it's not as popular as Python.

Well, and my preferred version of "everything looks good" is "everything compiles", which with a strict enough language does also make failure during the first run much less likely.

I'm also not saying that these aspects are unique to Python.

The language failing to tell you where the issue is also happens in JS/TS, C/C++ and I'm going to presume Ruby, too.
Python is just again rather popular and some of these choices don't make sense with my first hunch.

[–] tdawg@lemmy.world 2 points 2 years ago* (last edited 2 years ago)

Honestly man it just sounds like you have struggled with dynamic languages and by extension prefer static (compiled) ones. Which is totally fine you don't have to like everything. But I do think you're missing the real issue with "everything looks good." It's a lack of experience with the tool. It doesn't matter if you're using something as strict as Rust or dynamic as Lisp. "Everything looks good," is always bad. You should know "this is how this works," which is just not something a newbie can handle when they still don't know the difference between pass-by-reference and pass-by-value (or that those words even exist!)

[–] BeigeAgenda@lemmy.ca 2 points 2 years ago

I can suggest using pylint, it can find a lot of the syntax errors.