this post was submitted on 05 Apr 2025
168 points (95.7% liked)

Programmer Humor

36218 readers
196 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
[–] [email protected] 2 points 2 months ago

Endl is faster to type

[–] [email protected] 22 points 2 months 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.

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

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

Within reason.

Over optimization is a curse on getting done.

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

Who in the hell is using iostreams in an RTOS

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

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

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

Several. Probably dozens

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

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

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

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

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

Environment.NewLine might exist in C#

[–] [email protected] -1 points 2 months ago

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

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

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

[–] [email protected] 3 points 2 months ago
[–] [email protected] 17 points 2 months ago

#define endl "\n"

[–] [email protected] -1 points 2 months 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.

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

Why should no one be using c++?

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

Rebel side \0

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

os.linesep

Lol jk none of my stuff runs on Windows anyway

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

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

[–] [email protected] 1 points 1 month ago

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

load more comments
view more: next ›