this post was submitted on 05 Apr 2025
3 points (100.0% liked)

Programmer Humor

25040 readers
1819 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
top 11 comments
sorted by: hot top controversial new old
[–] Gustephan@lemmy.world 2 points 3 months ago (2 children)

Fuck endl, all my homies hate endl

[–] jdeath@lemm.ee 1 points 3 months ago

bloods 4 lyfe

[–] DragonTypeWyvern@midwest.social -1 points 3 months ago

Cout << "\n"; is dumb and you should feel bad

[–] heavydust@sh.itjust.works 1 points 3 months ago

No debate, std::endl can be a disaster on some platforms due to flushing crap all the time.

[–] Oinks@lemmy.blahaj.zone 0 points 3 months ago* (last edited 3 months ago) (1 children)

I am very sorry to remind everyone about the existence of Visual Basic, but it has:

  • VbCrLf
  • VbNewLine
  • ControlChars.CrLf
  • ControlChars.NewLine
  • Environment.NewLine
  • Chr(13) & Chr(10)

And I know what you're asking: Yes, of course all of them have subtly different behavior, and some of them only work in VB.NET and not in classic VB or VBA.

The only thing you can rely on is that "\r\n" doesn't work.

[–] MTK@lemmy.world 1 points 3 months ago (1 children)

Apology not accepted, fuck you for reminding me!

[–] jdeath@lemm.ee 1 points 3 months ago

great reminder to avoid microsoft products as much as i can

[–] Archr@lemmy.world 0 points 3 months ago* (last edited 3 months ago) (1 children)
[–] Croquette@sh.itjust.works 1 points 3 months ago

I just learned that in Python, it's fucking terrible. Python is a fucking mess and my next script will be in a different language.

[–] palordrolap@fedia.io 0 points 3 months ago (1 children)

If endl is a function call and/or macro that magically knows the right line ending for whatever ultimately stores or reads the output stream, then, ugly though it is, endl is the right thing to use.

If a language or compiler automatically "do(es) the right thing" with \n as well, then check your local style guide. Is this your code? Do what you will. Is this for your company? Better to check what's acceptable.

If you want to guarantee a Unix line ending use \012 instead. Or \cJ if your language is sufficiently warped.

[–] pelya@lemmy.world 1 points 3 months ago

Ah don't worry, if you do fopen(file, "w") on Windows and forget to use "wb" flag, it will automatically replace all your \n with \r\n when you do fwrite, then you will try to debug for half a day your corrupted jpeg file, which totally never happened to me because I'm an experienced C++ developer who can never make such a novice mistake.