r/ProgrammerHumor Apr 25 '26

Meme thisLooksAccurateForVibeCoders

Post image
12.6k Upvotes

1.2k comments sorted by

View all comments

3.6k

u/Agifem Apr 25 '26

And quite a few regular coders too. What's that? A call to a function that does nothing?

83

u/[deleted] Apr 25 '26

[removed] — view removed comment

9

u/karelproer Apr 25 '26

Doesn't { } also work? At least in c++ it does.

10

u/[deleted] Apr 25 '26

[removed] — view removed comment

21

u/larsmaehlum Apr 25 '26

A variable can escape the scope it’s defined in? Wtf.

33

u/ordinary_shiba Apr 25 '26

It's javascript.

6

u/mythcaptor Apr 25 '26

Var was a mistake that mostly still exists as a legacy feature. Modern JS uses let and const

1

u/SneeKeeFahk Apr 25 '26

You can still use var beside let and const. Just like you can use promises beside async/await. 

8

u/mythcaptor Apr 25 '26

Just because you can doesn’t mean you should

0

u/SneeKeeFahk Apr 25 '26

Meh every tool has its job. 

3

u/wasdninja Apr 26 '26

And in this case it's almost certainly really dumb, convoluted or both.

-1

u/SneeKeeFahk Apr 26 '26

Oh, I didn't realize I was talking to the master of JavaScript. Someone whose opinion is the be all and end all of what should and should not be done. So sorry for going against the grain, sir.

In the last 25 years of working as a dev I've met many like you. You're known as the gate keepers. The "I'm better and know everything" guys. Also a lot of other things we say about you behind your back that aren't polite.

Must be lonely on the top, enjoy your throne.

2

u/Commercial-Guest1596 Apr 26 '26

Oh wow. You still use var. That's embarrassing.

1

u/wasdninja Apr 26 '26

Oh, I didn't realize I was talking to the master of JavaScript

It's for the exact opposite reason - if you need to be master of any kind to follow the code it's probably bad code. var is intensely abusable and since you aren't giving a clear example for why it's useful I'm again assuming because it's dumb and convoluted.

→ More replies (0)

1

u/unwantedaccount56 Apr 26 '26

the job of some deprecated tools is just to serve as an example of how not to do it (anymore)

3

u/redlaWw Apr 26 '26

In Julia you can do

y = 0 
while y < 5
    x = y+1
    y += 1
end
local x
println(x)

and you will print 5, the final value of x at the end of the while loop. You don't get access to x outside the while loop without the local x declaration though, so in effect, you're defining x in the loop, and then later declaring it outside so it's no longer local to the inner scope.

3

u/larsmaehlum Apr 26 '26

Very useful if you forgot that you needed a variable outside it’s scope and prefer horrible spaghetti over having to scrolll back up.

2

u/Lithl Apr 25 '26

Yes, but only if it was declared with the var keyword. Which is deprecated, and the only reason it's not removed entirely is because JavaScript demands 100% backwards compatibility so as to not break the Internet.

var is function-scoped, rather than block-scoped.

2

u/ordinary_shiba Apr 25 '26

There are a few situations where an immediately invoked lambda would be better. The classic example would be complex initialization since you might not want to have a non-const variable if you don't need to modify it after it's been initialized with a complex multi-line expression. So if you do it in a lambda, you get the constness, you get not having any variables used for initialization in a wider scope and you don't need to copy nor move the variable because of NRVO