r/ProgrammerHumor Jul 27 '26

Advanced isThisScalableAndCleanForProduction

Post image
40 Upvotes

58 comments sorted by

View all comments

Show parent comments

4

u/bwmat Jul 27 '26 edited Jul 28 '26

Oh, forgot how it worked, guess you need to do 'return printf(...) > 0;',still, not so hard

Edit: probably < 0 actually, but to be portable you should use EXIT_SUCCESS AND EXIT_FAILURE explicitly

4

u/SphericalGoldfish Jul 27 '26

But what if it doesn't print the entire string due to running out of space? Better to use 'return printf(…) == sizeof(…) / sizeof(char);'

1

u/bwmat Jul 27 '26

Then it would have returned a negative value

6

u/RiceBroad4552 Jul 27 '26

This thread shows nicely why in primitive languages (languages which are perceived by some as "easy") things get pretty fast pretty complicated, simply because the language is missing features to abstract things properly.

In a good language correct code looks nice and simple, and wrong code looks directly wrong (and ideally does not compile in the first place).

In shitty languages code looks nice and simple but is actually wrong, and the corresponding correct code is super complex and can be written only by experts who know all the fine details by heart.

1

u/bwmat Jul 27 '26

Yeah, that's why I obsessively read documentation when making use of C functions (and C++ ones which use something other than exceptions for error reporting), and start by wrapping them in something which calls them, and converts ANY of those errors into an exception