this post was submitted on 28 Feb 2024
1012 points (97.0% liked)

Programmer Humor

33560 readers
612 users here now

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

Rules:

founded 5 years ago
MODERATORS
 
(page 3) 50 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 11 months ago* (last edited 11 months ago) (2 children)

C#: Time for a treasure hunt! Find the Null Reference Exception. Here's a map. X marks the spot.

load more comments (2 replies)
[–] [email protected] 39 points 11 months ago (20 children)

Imagine unironically praising Java.

load more comments (20 replies)
[–] [email protected] 28 points 11 months ago* (last edited 11 months ago)
gdb ./fuck
r
where

you should get a complete stack trace (complete with values of some function arguments)

[–] [email protected] 5 points 11 months ago

The ole' single C++ error turning into 600 lines of issues

[–] [email protected] 139 points 11 months ago (1 children)

Except the C++ "Core dumped" line is telling you it just wrote a file out with the full state of the program at the time of the crash, you can load it up and see where it crashed and then go and look at what every local variable was at the time of the crash.

Pretty sure you can even step backwards in time with a good debugger to find out exactly how you got to the state you're currently in.

[–] [email protected] 50 points 11 months ago (7 children)

Where does it write the file

[–] [email protected] 22 points 11 months ago (12 children)

I believe it's /var/lib/apport/coredump on Ubuntu.

load more comments (12 replies)
load more comments (6 replies)
[–] [email protected] 3 points 11 months ago

puts me in mind of the old guru meditation error messages that popped up in the stone knives and bearskins era of computing.

[–] [email protected] 2 points 11 months ago (1 children)

Why doesn't JavaScript have tracebacks?

[–] [email protected] 5 points 11 months ago

How useful would they be when they rely to such a large extent on various callback functions?

[–] [email protected] 11 points 11 months ago (1 children)

More like 100 lines of template errors

load more comments (1 replies)
[–] [email protected] 9 points 11 months ago (3 children)
[–] [email protected] 8 points 11 months ago

Rust: this garbage code is beneath me, come back when you have your shit together.

[–] [email protected] 2 points 11 months ago

Compilation: top row, runtime: button row.

[–] [email protected] 28 points 11 months ago (1 children)

Rust required you to fix all the errors before running the code.

[–] [email protected] 7 points 11 months ago (1 children)

Runtime errors are still a thing.

[–] [email protected] 14 points 11 months ago (2 children)

Compared to that trio, they are a rarity that make people excited just to spot one.

[–] [email protected] 2 points 11 months ago* (last edited 11 months ago)

Runtime errors are rare? Interesting. I guess it depends on how much error handling the dev additionally wants to do.

[–] [email protected] 5 points 11 months ago

I have a graphical application that crashes regularly when I switch between displays with Ctrl+alt+number. Something in the winit stack does not like it.

[–] [email protected] 18 points 11 months ago
[–] [email protected] 51 points 11 months ago (2 children)
[–] [email protected] 15 points 11 months ago* (last edited 11 months ago) (3 children)

https://www.youtube.com/@TsodingDaily

If you're a programmer, or think you might want to be one, I highly recommend this channel. He's a savant at all sorts of low level things, quite funny and entertaining, and does a fantastic job of explaining what's going on.

load more comments (3 replies)
[–] [email protected] 77 points 11 months ago (4 children)

Python: So you used spaces and tabs for indentation? NOW DIE!

[–] [email protected] 47 points 11 months ago (2 children)

Mixing spaces and tabs should be a warcrime.

[–] [email protected] -5 points 11 months ago (14 children)

Find me anyone who claims they use tabs for indentation, and I bet I'll find at least one case where they're using both tabs and spaces.

The only safe way to avoid war crimes is to avoid tabs.

[–] [email protected] 7 points 11 months ago (3 children)

I use the tab key but I'm pretty sure vs code converts that to spaces

load more comments (3 replies)
load more comments (13 replies)
load more comments (1 replies)
[–] [email protected] 4 points 11 months ago

Are you ok?

[–] [email protected] 22 points 11 months ago (3 children)

Good. Spaces and tabs for indentation should never be mixed in any language other than Whitespace.

load more comments (3 replies)
load more comments (1 replies)
[–] [email protected] 5 points 11 months ago* (last edited 11 months ago)

At least you are getting a dump, count your blessings. Could be worse!

Just hook your app to a debugger and load the dump.

[–] [email protected] 24 points 11 months ago (2 children)

No bounds checking, only fast.

[–] [email protected] 14 points 11 months ago

There is bounds checking, but it's opt-in. I often enable it on debug builds.

[–] [email protected] 5 points 11 months ago (3 children)

This right here - C++ iirc is used mostly for microprocessor code in an industry setting, where EXTENSIVE testing is done so that bloated code doesn't need to constantly check for programmer errors every single time, i.e. where execution speed is prioritized over programmer development time. And whenever that is not the case, well, as OP pointed out, other higher-level languages also exist (implication: to choose from).

[–] [email protected] 6 points 11 months ago

I also currently use it for a new project since all needed 3rd party libraries are from a very specific domain and the project has a deadline, so writing and testing wrappers for Rust that would provide me with any meaningful advantages down the road are too costly to budget for before the deadline.

That could become part of a future refactoring, though.

[–] [email protected] 35 points 11 months ago

C++ iirc is used mostly for microprocessor code

lol no, it's used almost everywhere where performance is important and people want(ed) OOP, from tiny projects to web browsers (Chrome, Firefox) to game engines (Unreal, CryEngine). Many of these are hugely complex and do encounter segfaults on a somewhat frequent basis.

Saying C++ is mostly used for embedded applications is like saying C# is mostly used for scripting games, i.e. it doesn't nearly cover all the use cases.

higher-level languages also exist

This depends on your definition of "higher-level", but many people would argue that C++ is on a similar level to Java or C# in terms of abstraction. The latter two do, however, have a garbage collector, which vastly simplifies memory management for the programmer(generally anyway).

load more comments
view more: ‹ prev next ›