r/programminghorror • • Sep 18 '26

Not again 😭

Post image
456 Upvotes

41 comments sorted by

15

u/anatomiska_kretsar Sep 18 '26

sigma ibm vga fallback font

1

u/sonesoul Sep 18 '26

fuckin love it

41

u/Major-MacZongo Sep 18 '26

Why?

110

u/Krohnos Sep 18 '26

the error explains it!

else if { } is a shortcut for else { if { } } and is creating more nested blocks. there's a hard limit for the maximum nests.

7

u/sonesoul Sep 18 '26

damn I didn't know that

44

u/UltimateFlyingSheep Sep 18 '26

and you don't even need else if for that because of return....

37

u/creeper6530 [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Sep 18 '26

Well I don't know about you but to me it's definitely not obvious that the else if is silently inserting nested blocks

31

u/_killer1869_ Sep 18 '26

If you've looked into how compilers handle the many intermediate steps they perform, it can be obvious. By "can" I mean you wouldn't ever think of it, unless the compiler explicitly tells you "blocks nested too deeply" or similar, something that isn't actually in your code directly, forcing you to actually think about what the compiler sees, like here.

10

u/the_horse_gamer Sep 19 '26 • Mindblown

consider that you don't need {} if there's only a single statement. well, an if/else is only a single statement. so, else if requires no additional grammar.

you can do else while and else for all the same

the K&R C book directly mentions this fact

3

u/creeper6530 [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Sep 19 '26

I never thought of this, always considering else if as a separate keyword containing a space character (save for Python's elif), but it makes disturbingly too much sense that it's all just an artifact of brace-less if-else.

TIHI.

1

u/the_horse_gamer Sep 19 '26

i should add that this may not be true in some newer languages, like rust for example. in rust, you CANNOT omit {} for a single statement, but else if is still possible (in the ast, each "if" node may have a corresponding else, which is either another if node (for else if) or a normal block (for else))

another cursed fact: the "omit {}" thing applies to switch (in C/C++, atleast. i didn't check, but it probably doesn't work in java or C#). this is completely legal (and works as you'd expect):

switch(x)
case 1:
case 2:
    puts("hi");

1

u/ierdna100 Sep 20 '26

Its not true in lua for example, if, else and else if are only 2 keywords, but that will make you need to write a chain of end end end end end end at the end, so the proper keyword is elseif. I wonder if Lua interpreters handle it "better"?

6

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Sep 19 '26

I did not even know such a limit existed. I probably never encountered it because I'm not insane enough to write code like this. Even if the OP is just meming.

Though I suppose the parse tree would eventually fill up all the memory if you kept doing shit like that.

1

u/ierdna100 Sep 20 '26

There's a bunch of really funny limits if you ever want to try to reach them. Some examples include: parameter limits (C standard goes up to 127 I think? 65k (16 bits) in C#), generic type depth limits (65k (16 bits) in C# for example), and some others that are escaping my mind. Gotta remember the compiler is just another piece of code, its gotta also run on your machine

1

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Sep 20 '26

RAM is finite, unfortunately.

2

u/ElectricalPrice3189 Sep 20 '26

No it's not.

if(...) { ... } else { if(...) { ...} } else { ... }

Makes no sense. You can't have two "elses".

1

u/Grounds4TheSubstain Sep 19 '26

That's crazy that there would be a limit. It seems harder to enforce that than to not have a limit.

1

u/Tyfyter2002 Sep 20 '26

It's not really intuitive because blocks only really exist in two senses: scope, where the else block doesn't meaningfully exist, and where the unconditional branch in the if block goes, where the else block still doesn't meaningfully exist

1

u/Aaron1924 Sep 22 '26

Fun fact: According to the C99 standard (ISO/IEC 9899:1999) §5.2.4.1 "Translation limits", a correct C compiler only has to support 127 levels of nesting

5

u/amsylum Sep 18 '26

Is that Fixedsys? Niceh

7

u/sonesoul Sep 18 '26

it's ibm vga

165

u/StranglerOfHorses Sep 18 '26

Literally 1984

162

u/Rigamortus2005 Sep 18 '26

Imagine the compiler calling your code too dogshit to compile

1

u/84_110_105_97 Sep 22 '26

lol 🤣🤣🤣

12

u/PQP_The_Dev Sep 18 '26

it's over. They got you

7

u/UselessGuy23 Sep 18 '26

Are we not going to talk about the output statements?!

4

u/SteroidSandwich Sep 18 '26

Damn even the compiler had enough

4

u/yuehuang Sep 18 '26

640 nested block ought to be enough for anybody.

4

u/mrheosuper Sep 19 '26

Bro is limited by current technology 😭

1

u/iamacuteporcupine Sep 19 '26

I choked on this one, rofl

1

u/Certain-Flow-0 Sep 18 '26

So, where’s the python code that generates this “monstrosity”?

1

u/sonesoul Sep 19 '26

i made that in c++ (kidding, i wrote it all myself)

1

u/KaleidoscopePlusPlus Sep 19 '26

what font is this daddy

3

u/Certain_Time6419 Sep 19 '26

Well, at least you can write the correct output for all values up to 1984 and for half the values larger than this (up to [2³²/2]-1, I suppose). So, even if it is close to 50% (naive randomness), you can argue that you have an edge above it (by impressive 35*10-8 % !)

1

u/DistearRoyl Sep 19 '26

We need to use a compiler with deeper limits.

1

u/questionabl3_dude Sep 21 '26

Someone bless this man with the knowledge of “% 2”

1

u/Kadabrium Sep 21 '26

Apparently its an interview question that when will a compiler get a stackoverflow. Idk if this is one of them

1

u/pskocik Sep 29 '26

I've played with some transpilation that produced a lot of {} and ran into this with clang. Ended up doing some work to reduce the number of {} generated. Thankfully gcc didn't seem to have such arbitrary limits. Computing is better when there's no arbitrary limits. If I've got the RAM for it, let me have as many braces as I want.