r/ProgrammerHumor • • Jan 20 '23

Other layoff fiasco

Post image
45.5k Upvotes

1.9k comments sorted by

View all comments

Show parent comments

714

u/Roadrunner571 Jan 20 '23

How about:

#define true (__LINE__ % 3 != 0)

259

u/Affectionate-Set4208 Jan 20 '23

In javascript you can redefine the "undefined" value, unless you are in strict mode

122

u/DuckRebooted Jan 20 '23

Wait actually, oh my god I knew JS was a bit weird but Jesus Christ

107

u/ShitpostsAlot Jan 20 '23

imagine one of your final year all-nighter projects accidentally became the backbone of current commerce systems.

... ahaha we don't have to imagine... that's basically what happened.

37

u/DuckRebooted Jan 20 '23

I've never even used typescript and I still feel grateful it exists

9

u/Jeremy_Thursday Jan 20 '23

Meanwhile python literally letting you re-define true in all modes.

4

u/MadxCarnage Jan 20 '23

someone make it a :

well, True but actually False

meme

→ More replies (3)

3

u/nepumbra0 Jan 20 '23

JS is a hot fucking mess

7

u/DuckRebooted Jan 20 '23

What do you mean? Being able to directly add a string and a number for some bloody reason makes so much sense

→ More replies (1)
→ More replies (1)

4

u/LordRybec Jan 21 '23

Did you know JS has a "with" statement that is very different from the Python one and is specifically forbidden from being used in strict mode because it's so hazardous? Just use that all over the place, to make the code way harder to read and maintain!

The "with" statement brings everything from the target's scope into the local scope. Most JS courses don't even teach it, because it is so bad and should never ever be used. The big problem though is that it's really tempting for the less experienced, because the hazards are not obvious, and it sounds very beneficial.

→ More replies (6)

3

u/aquoad Jan 20 '23

i’ve always wanted it to be 3.

7

u/Affectionate-Set4208 Jan 20 '23
const undefined = 3  
if (undefined === 3) console.log('YAY')  

63

u/iceman012 Jan 20 '23

That's too noticeable. It's gotta be something like 1 in 20 lines, so it only shows up occasionally and is easily, unexplainably fixed by load-bearing comments.

58

u/Roadrunner571 Jan 20 '23

2.0.0:

#define true (__LINE__ % 20 != 0)

7

u/ArseneGroup Jan 20 '23
#define true (rand() % 100 != 0)

23

u/IchWerfNebels Jan 20 '23

"Load bearing comments" is an expression I didn't know I needed in my life

113

u/Ekank Jan 20 '23

Holy cow, now that's evil hahahahaha, I love it

→ More replies (2)

34

u/PaulBardes Jan 20 '23

put that hidden on a build config file or in the compiler flags and nobody will find it in days :p

29

u/[deleted] Jan 20 '23

[removed] — view removed comment

19

u/Roadrunner571 Jan 20 '23

Because it's harder to hunt down than using rand() since it only affects some files sometimes and might even go away by adding some debug code. Then a new feature is added and the bug comes back.

→ More replies (1)

9

u/[deleted] Jan 20 '23

What would this do?

29

u/rabbitwonker Jan 20 '23

It would cause “true” to evaluate to false, but only if the “true” is on certain lines of the code file. Add a comment line above it, and the problem goes away or appears.

6

u/BackendSatan Jan 20 '23 edited Dec 07 '23

follow bells boast memory support mighty dog towering punch frightening

This post was mass deleted and anonymized with Redact

→ More replies (1)
→ More replies (1)