this post was submitted on 18 Jan 2024
17 points (100.0% liked)

Programmer Humor

19207 readers
1197 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 1 year ago
MODERATORS
 
all 45 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 8 months ago* (last edited 8 months ago) (1 children)

This can't be for real. I'll stick with C11 thank you.

[–] [email protected] 1 points 8 months ago

Here you dropped this:

#define ifnt(x) if (!(x))
[–] [email protected] 0 points 8 months ago

I'd take a not or "if not" operator tbh.

[–] [email protected] 0 points 8 months ago
aint (something) {
    somethingElse()
}
[–] [email protected] 3 points 8 months ago (3 children)

I propose a new, more threatening kind of control flow.

do {
  /* something */
} or else {
  /* you don't want to find out */
}
[–] [email protected] 1 points 8 months ago (1 children)
do {
  /* something */
} do hast {
  /* something */
}
[–] [email protected] 1 points 8 months ago
do {
  /* something */
} do hast {
  /* something */
} do hast mich {
  /* something */
}
[–] [email protected] 0 points 8 months ago

You just made me a offer I can't refuse. I go now to sleep with the fishes...

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

Some C++ style guides suggest the following naming convention for functions that crash on any error

OpenFileOrDie()
[–] [email protected] 0 points 8 months ago

It's funnier when you try to SysCallAndDie() :-P

(that's a real thing in perl btw - I guess that function didn't get the memo)

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

Personally, I like to call catched exception variables up, so for a rethrow I can throw up;.

[–] [email protected] 1 points 7 months ago

Except rethrowing an exception in C# is just throw;, anything else is a crime against the person who reads your stacktraces.

[–] [email protected] 0 points 8 months ago

I mean, it makes sense to call ComplainToErrorAndExit just 'die', no?

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

PHP has the always wonderful (and perfectly functional) syntax of

logUserIn() or die();

[–] [email protected] 0 points 8 months ago (1 children)
[–] [email protected] 1 points 8 months ago* (last edited 8 months ago)

Perl also has unless() for the very purpose in OP, which is a more sensible choice.

Oh, and if you need to reinforce your belief that Perl is a mess, the single-quote character can be used as a package separator instead of "::". This was set in the 90s when nobody was quite sure of the right syntax for package separators, so it borrowed "::" from C++ and the single quote from Ada (I think).

That means the ifn't() in OP can be interpreted as calling the t() function on the ifn package.

The "::" separator is vastly preferred, though. Single quotes run havoc on syntax highlighting text editors (since they can also be used for strings). About the only time I've seen it used is a joke module, Acme::don't.

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

I'm just hoping this paves the way to code with Southern dialect

iffun is == true
iffun ain't == false
[–] [email protected] 1 points 8 months ago (1 children)

May I introduce you to the joys of #define and creating your own horrible sub language

[–] [email protected] 1 points 8 months ago* (last edited 8 months ago)

That reminds me of an old paper about how to create a compilable C program out of old game ROMs. Decompile to assembly. Implement a bunch of #define statements that implement all the ASM statements. Now compile it to a native binary on whatever platform.

Won't likely be faster or more accurate than regular emulation methods, but it's a neat idea considering that the source code on all this stuff was lost a long time ago.

[–] [email protected] 1 points 8 months ago* (last edited 8 months ago) (1 children)
[–] [email protected] 1 points 8 months ago* (last edited 8 months ago)

nocap(frfr){

}

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

I believe that resolves the same as

ain't!(!untrue)

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

Reduce exclamation marks!? Great Scott!!!!! Is there a shortage of punctuation in the future!?

[–] [email protected] 0 points 8 months ago
[–] [email protected] 0 points 8 months ago

Kernighan, what was I thinking?

[–] [email protected] 1 points 8 months ago

You could have saved two, all you had to do was use the interrobang. You’re a monster.

[–] [email protected] 0 points 8 months ago

All known deposits were depleted

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

Please God let this be a humorous post that somehow does not also find a way to manage to come true...

[–] [email protected] 1 points 8 months ago* (last edited 8 months ago) (2 children)

I would have bought it if they said ifnot instead, it's the same number of characters and wouldn't require a major parser overhaul to support keywords with a ' in the name.

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

i mean, “unless” tends to be the usual term for an “if not” keyword in languages that implement such a thing

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

Which is awful and incredibly confusing. I hate ruby

[–] [email protected] 0 points 8 months ago (1 children)
[–] [email protected] 3 points 7 months ago

And my axe!

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

Yeah, to be clear, I don't like it, I don't like it one bit:-P.

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

If not anybody have time for that.

[–] [email protected] 0 points 8 months ago

*ifn't*

Oh dear Lord what have I done!? :-P

[–] [email protected] -1 points 8 months ago (1 children)
[–] [email protected] 0 points 8 months ago (1 children)
[–] [email protected] -1 points 8 months ago

^This

OP raises a valid point