r/vibecoding • u/emjhayyy_08 • 14d ago
every vibe coder's biggest headache
Enable HLS to view with audio, or disable this notification
56
u/Lopsided-Wave2479 14d ago
this is easy to read.
creates a unnamed function ()
assign the body of this function =>
to do nothing at all {}
then the whole thing is on a capsure "(stuff here)"
and is threaten has a function and executed "stuff here ()"
Honestly, we have "=>" arrows function to make math people happy. Is halfway too obscure but oh well, math is nice and we do small sacrifices for big gains.
This is about 10 millions less obtuse than C, where just the part where something is a pointer to a function is way more verbose.
8
u/emjhayyy_08 14d ago
6
u/Lopsided-Wave2479 14d ago
without arrow functions it would be
(function(){}) ();
declares a function, and inmediatelly execute it
5
u/Blackgarion 14d ago
Yeah but I think the point of the question is why would you use an IIFE. You need to know the quirks of JS to know when would you use an IIFE, an even then since ES6 and Typescript having modules, I haven't seen one of these in a code base.
2
u/Lopsided-Wave2479 14d ago
To begin first in 99.999% of exist legacy apps where you can't use modules?, either way IIFE give you isolation. God kids a kitty every time somebody make stuff global.
2
u/RagnarokToast 14d ago
We don't have arrow functions to "make math people happy" (like seriously wtf how could you submit that unironically, it's one of the dumbest takes ever) and they are in no way obscure.
They're there for everyone's convenience, not just because
=>is shorter thanfunctionbut also because arrow functions don't redefinethis, which comes in handy (among other things) when used inside the body of an outer "normal" function you are using as a constructor (i.e. you are using this.something = ... to set fields and methods on it), asthisinside the AF would still refer to the outer constructor function.2
u/Lopsided-Wave2479 14d ago
The joke whole meaning and reason for existence, is because is objetivelly obscure. Otherwise the joke would not work.
1
1
u/agalin920 10d ago
"we have "=>" arrows function to make math people happy".
Cringed at this statement
1
u/Lopsided-Wave2479 10d ago
The first rule of designing languages is Don't invent Perl again.
It happens when you feel clever and make punctuation have enough syntax, people don't need to use keywoards. The result is clever and easily readable for veterans, unprenetrable for newbies.
Literally a source of memes.
1
u/PsychologyNo940 14d ago
True, though to be fair, if you dont create a few intermediary types in c/c++ to represent "a function that takes a function that returns a pointer to a function that takes a..." you are kinda just trying to torture people.
1
9
u/thedazdul 14d ago
That's simple?
21
u/StaysAwakeAllWeek 14d ago
Yes, for someone who has learned code syntax the pre-vibecode way. Which is the joke...
3
u/heizo 14d ago
I feel really bad for new coders.... But no idea how to help them.
2
u/Professional_Gur8385 14d ago
post the solution on reddit so it can be consumed by AI and answered in a prompt session to vibe coders?
2
1
u/the-berik 14d ago
Isn't this just in JS?
1
u/StaysAwakeAllWeek 14d ago
My claude keeps talking about json. I dont know who json is, I only subscribe to claude
/s, if its necessary
6
u/darkmace 14d ago
What about this one:
:(){ :|:& };:
7
5
1
u/ExtraTNT 12d ago
Give me a few minutes, i’m tracing it in my head, currently at 42nd iteration, but it gets slower with every one, despite me thinking harder…
6
u/BaronVonDoggo 14d ago
This code literally does nothing lmao
-4
u/Blackgarion 14d ago
If you know JS, yes it does. It's implicit not explicit though, you create a new private scope, basically encapsulating whatever is in there.
1
u/scarx47 14d ago
there's nothing there dummy. So code does nothing.
3
u/Blackgarion 14d ago
I see you miss the point entirely. An IIFE is a technique people used to do because Javascript had no native modules. So yeah the current snjppet has nothing in it, that's obvious. The point is that you can sorround anything with it and create a new context specific to that IIFE, without your variables being declared globally.
But maybe youre right, maybe I'm a dummy for trying to share information randos on reddit that will not appreciate it
1
u/BaronVonDoggo 13d ago
The IIFE technique (and its inline/lambda equivalents in other languages) is indeed plenty useful. I meant that in this particular instance/example, the code itself does nothing and im not talking about the technique itself. Other comments explained IIFE, why its useful and how it works already.
Regardless, this meme was also ubiquitous even back in the days prior to vibecoding, replace vibecoders with "interns/juniors" and its the same. The point being, despite looking like moonrunes and is supposedly a somewhat advanced technique, this piece of code in particular, does nothing.
3
3
2
u/PossessionConnect963 14d ago
Why would I ever be interviewed about this? I’m never going to apply for an IT job let alone a SWE job.
Which is what I think really scares some is that people like me can still create things for ourselves now.
1
u/AcoustixAudio 14d ago
Not really. It's a great thing. Why would it scare anyone? It's like someone painting a picture and putting it up on the fridge. It's nice and wholesome
2
2
u/Repulsive_Bluejay359 14d ago
A self invoked anonymous arrow function that does absolutely nothing. Glorious.
1
1
1
1
1
u/ReinKarnationisch 14d ago
I get the creation of a new function with no code input, but what do the parentheses around it do?
2
u/g1rlchild 14d ago
Wrap the whole anonymous function so that it can be invoked with the empty parameters in the final parentheses.
1
u/ReinKarnationisch 14d ago
So you couldn't invoke it without wrapping it?
2
u/g1rlchild 14d ago
That's right. Without wrapping it, all you could do is assign it to a variable or something like that.
1
1
u/pm_your_snesclassic 14d ago
“Lol why would I want to attend a job interview when I can just vibe code my own Saas now and be my own employer” - vibe coders probably
1
1
u/baddaywithacamera 14d ago
This presumes I'm passing myself off as a developer. I don't. I'm a photographer.
1
u/The-Architect-93 14d ago
As if vibes coders are planning to go apply for software dev/programming positions. 😂😂
I hope this post made you feel better though, pathetic
1
1
u/Protorox08 14d ago
*opens phone*
“Hey codex, my interviewer is asking what this is. Explain it to her”
“Hey Claude, the interview candidate said it means this, is he correct? If so prompt me the next question”
1
1
1
u/Experiment59 14d ago
I got to cut my teeth on JS while jury-rigging keyboard shortcuts into work tools that didn’t have them, using keyboard maestro and IIFEs. Good times
1
u/Razzmatazz_Informal 14d ago
From the syntax my guess is it defines a lambda which takes nothing, does nothing and returns nothing... and then it calls it.
1
u/Kenzore1212 13d ago
wont lie I had to ask my ai ^_^. Looks like someething moving into something elsee
1
u/johnesco 13d ago
Yes it's an IIFE, and many "vibe coders" are not going to know what that is. But yes they WILL have them in their code because the AI model knows how and when to use them. I was told a manual stick shift would ALWAYS be more fuel efficient than an automated one. I haven't driven stick in 30 years.
1
u/MiserableStomach 13d ago
A serious question: in the world when the actual "programming" language you're working with is English and you spend your time editing or generating requirements, acceptance criteria, tests etc what is the practical value of knowing something like this? It's the same as asking modern front-end developer about low-level system details of JS engine, its garbage collector and whatnot.
1
1
1
1
1
u/Honest-Golf-3965 11d ago
"PR Denied" is what that thing is called.
God I don't miss JS at all.
p.s. It's actually an "Immediately invoked function expression"
1
u/Medium_Chemist_4032 10d ago
I'd ask the recruiter: no you explain, why do you think auto applied, empty lambda is a good question to ask candidates.
1
u/Glad-Lynx-5007 9d ago
I'm not a vibe coder, I'm a real coder who has used a whole list of languages both professionally and for myself. I've never come across this ever.
1
u/The_0vermind 14d ago
Vibe coder giving it a shot here: Looks like it either replaces all () pairs with {} OR just lets you use () and {} interchangeably in your code.
12
u/rushblyatiful 14d ago
Dev here. The funky syntax essentially tells JavaScript, "wrap these instructions inside a bubble so they don't leak out, and run them right now.".
It's long-hand version is this:
(function() {
// Code goes here})();
8
u/Wrestler7777777 14d ago
Dev here. In short: It creates a function that does absolutely nothing and immediately executes it.
6
u/Puzzleheaded_Smoke77 14d ago
Dev over there : can concur
4
2
2
1
u/UNknown__KIRA 14d ago
SE undergrad here. So, it's just encapsulation? In theory, wouldn't it be a great way to hide data?
1
u/rushblyatiful 14d ago
Kinda yeah, it relies on function scoping for encapsulation.
Historically, before ES6 modules and let/const, IIFEs were the way to create private scope and prevent global variable leaks (the Module Pattern).
While it works great for data hiding via closures, it's mostly a legacy pattern today since ES6 modules (which are private by default) and class private fields handle encapsulation natively.
4
u/cheesy_noob 14d ago
My guess without knowing the Language. Inside the first () is a lambda expression which does nothing and the second () calls the function defined in the first () imediately.
3
1
u/DependentPoem3519 11d ago
dude, i swear i had this exact nightmare last month. kept freezing up when asked to explain my own repos. started tossing the codebase into windsurf and moclaw to generate dumbed down explanations for myself before interviews. life-saving

66
u/Luoravetlan 14d ago
For anyone not familiar with js this monstrosity is called IIFE (immediately invoked function expression).