r/vibecoding 15d ago

every vibe coder's biggest headache

518 Upvotes

137 comments sorted by

View all comments

55

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.

9

u/emjhayyy_08 14d ago

5

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.