210 points

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

do {
  /* something */
} or else {
  /* you don't want to find out */
}
permalink
report
reply
60 points

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

OpenFileOrDie()
permalink
report
parent
reply
27 points

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

logUserIn() or die();

permalink
report
parent
reply
6 points

Or Perl

permalink
report
parent
reply
10 points

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

permalink
report
parent
reply
2 points

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

permalink
report
parent
reply
4 points

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

permalink
report
parent
reply
4 points

One of the modules in a project I’m working on is called VulkanOrDie which always makes me crack up when I see it in the compilation messages.

permalink
report
parent
reply
3 points

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)

permalink
report
parent
reply
1 point

Now what about GZDoom’s GoAwayAndDie();?

permalink
report
parent
reply
42 points

this is just a menacing try/catch!

permalink
report
parent
reply
23 points

It_would_be_a_shame_if(condition)

permalink
report
parent
reply
10 points

The better try-catch. More intuitive if you ask me.

permalink
report
parent
reply
8 points

It exists, kind of. Python has this construct

for item in iterable:
    ...
else:
     ...

which always puzzles me, since it depends on a break statement execution. I always have to look it up when the else block is executed.

permalink
report
parent
reply
6 points

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

permalink
report
parent
reply
5 points
do {
  /* something */
} do hast {
  /* something */
}
permalink
report
parent
reply
do {
  /* something */
} do hast {
  /* something */
} do hast mich {
  /* something */
}
permalink
report
parent
reply
106 points

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

permalink
report
reply
90 points
*

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.

permalink
report
parent
reply
45 points

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

permalink
report
parent
reply
21 points

Which is awful and incredibly confusing. I hate ruby

permalink
report
parent
reply
15 points

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

permalink
report
parent
reply
4 points

If not anybody have time for that.

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply
1 point

Gulp…

link]

Also, just for fun, the prequel:

permalink
report
parent
reply
98 points
*

cap () {

}
nocap () {

}

permalink
report
reply
47 points
*

nocap(frfr){

}

permalink
report
parent
reply
78 points

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

permalink
report
reply
21 points

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

permalink
report
parent
reply
15 points

All known deposits were depleted

permalink
report
parent
reply
13 points

1.21GB!!!

permalink
report
parent
reply
4 points

Kernighan, what was I thinking?

permalink
report
parent
reply
53 points
Deleted by creator
permalink
report
reply
67 points

unlessn’t

permalink
report
parent
reply
28 points

I’m sorry, I hate the “unless” so much

permalink
report
parent
reply
4 points

At one of my first jobs, I was tasked to rewrite a bunch of legacy Perl scripts in Python and the unless lines always made me trip up. I don’t know why but it really messed with my mental flow when reading Perl code

permalink
report
parent
reply
10 points

Basic used “else”.

It’s nice. “if”, “then”, and “else”. I spent a year programming a shitty roulette game on an Apple 2e back in high school. I still remember the joy of using if/then/else paired with goto to make a horrible mess of spaghetti logic.

But yeah, “else” is nice.

permalink
report
parent
reply
7 points
*

Using a standalone ‘else’ would tickle my brain in the same nice way that being able to declare a variable inside an ‘if’ statement as if it were a ‘for’ loop (which you can do in modern C++) does.

permalink
report
parent
reply
2 points

Or a rust “if let”

permalink
report
parent
reply
2 points

Many languages let you scope variables.

In c# you can create an arbitrary scope to declare variables in. Most likely in others as well.

permalink
report
parent
reply
1 point

Block scoped variables are bad?

permalink
report
parent
reply
2 points

Let’s just scrap every language except various forms of BASIC.

permalink
report
parent
reply
4 points

Please God, no. I had to unravel terminal scripting code that was written in some propriety BASIC language with basically no documentation.

Took me a chunk of time trying to figure out how it worked before I made the realization that it was BASIC

permalink
report
parent
reply
7 points

I haven’t written any Ruby for years, but I still praise it in every conversation I have regarding programming languages. It’s basically a much simpler Python, with some design ideas that are both beautiful and deeply strange.

permalink
report
parent
reply
3 points

Ruby was designed to evoke joy and they absolutely succeeded. Usually, programming is mostly a means to an end to me. But using Ruby just feels so amazing, it’s almost impossible to even describe to somebody who has never used it before.

permalink
report
parent
reply
5 points

The Perl version of it is even greater!

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

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

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 5.2K

    Monthly active users

  • 1.1K

    Posts

  • 38K

    Comments