this post was submitted on 05 Apr 2025
167 points (95.6% liked)

Programmer Humor

35773 readers
33 users here now

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

Rules:

founded 5 years ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] RandomVideos@programming.dev 2 points 1 month ago

Endl is faster to type

[–] jecxjo@midwest.social 22 points 1 month ago (2 children)

They aren't the same thing so the comparison is weird.

endl has a flush which is important when doing something like embedded work or RTOS development. If i was doing multiple lines they all were \n until the last line when i actually want to push the buffer.

Obviously depending on the tuning of the compiler's optimization multiple flushes could be reduced but the goal should always be to write as optimal as possible.

[–] lud@lemm.ee 3 points 1 month ago

but the goal should always be to write as optimal as possible.

Within reason.

Over optimization is a curse on getting done.

[–] aport@programming.dev 3 points 1 month ago (2 children)

Who in the hell is using iostreams in an RTOS

[–] jecxjo@midwest.social 2 points 1 month ago

Sometimes you work in a codebase that was decided on by others for reasons you don't know.

[–] KeenFlame@feddit.nu 2 points 1 month ago

Several. Probably dozens

[–] bramen49@lemmy.ml 4 points 1 month ago

Well, Java has System.lineSeparator so, maybe no?

[–] UpperBroccoli@lemmy.blahaj.zone 20 points 1 month ago

\n, because I ordered a newline, not a flush.

[–] nope@jlai.lu 5 points 1 month ago (2 children)

Environment.NewLine might exist in C#

[–] HiddenLayer555@lemmy.ml -1 points 1 month ago

Microsoft really creating the problem and then forcing you to use their solution.

[–] MrScottyTay@sh.itjust.works 2 points 1 month ago

It might do. I encountered it last week as I needed it for a powershell script. So it exists in that at least

[–] dave@feddit.uk 3 points 1 month ago
[–] GideonBear@lemmy.ml 17 points 1 month ago

#define endl "\n"

[–] mdhughes@lemmy.sdf.org -1 points 1 month ago (1 children)

If you write to a text (as opposed to binary) stream, \n produces \n or \r\n (or \r if old enough) depending on platform just fine.

Nobody should be using C++ anyway, but plenty of languages have silly system newline constants, which do nothing useful.

[–] MrScottyTay@sh.itjust.works 4 points 1 month ago (1 children)

Why should no one be using c++?

[–] lnxtx@feddit.nl 4 points 1 month ago

Rebel side \0

[–] lengau@midwest.social 9 points 1 month ago

os.linesep

Lol jk none of my stuff runs on Windows anyway

[–] pewpew@feddit.it 5 points 1 month ago
[–] xmunk@sh.itjust.works 9 points 1 month ago (1 children)
[–] grandel@lemmy.ml 2 points 1 month ago (1 children)

I like that you added the absolute namespace identifier or whatever its called

[–] xmunk@sh.itjust.works 1 points 1 month ago

I don't always namespace but when I do I fully qualify.

load more comments