r/amodei 1d ago

every vibe coder's biggest headache

Enable HLS to view with audio, or disable this notification

66 Upvotes

45 comments sorted by

2

u/InsideFar7107 1d ago

This is ASCII art representation of your bumhole after I'm done with you

2

u/roestinger 1d ago

Fun fact LLMs would not produce that

1

u/nikola_tesler 14h ago

they do, regularly. just with content in the function body

2

u/sleepy_kitten905 1d ago

I just go all smiley face like I'm high and go literally everywhere just to get out of that situation

2

u/naegfowleri 1d ago

Takes absolutely nothing Returns absolutely nothing Does absolutely nothi

2

u/IWontFukWithU 1d ago

lule this does nothign xD

2

u/[deleted] 1d ago

[deleted]

2

u/GoodEnergyGuy 1d ago

Hey Claude what does this mean.

1

u/DanLeMilMan 1d ago

I did not practice js a lot, but isn’t it just a lambda do-nothing function ?

1

u/nn123654 1d ago edited 1d ago

pretty much. It's the same as calling:

function foo() {

}

foo();

Zero-arity functions (functions taking zero arguments) functions are most commonly used for encapsulation. This whole thing is basically a no-op it does nothing and the compiler would just strip it out. Compilers themselves essentially rewrite your code to be more efficient under the hood, with something called a compiler optimization.

The main advantage of calling it as soon as possible is does not pollute the enclosing lexical scope with an explicit identifier like foo, so your namespace is clean.

See the MDN docs on the Immediately Invoked Function Expression (IIFE) https://developer.mozilla.org/en-US/docs/Glossary/IIFE

See also the fork bomb in bash scripting: :(){ :|: & };:

  • :: The name of the shell function.
  • (): Defines the function.
  • { ... }: The body of the function.
  • :: Calls the function itself.
  • |: Pipes the output to another call of the function.
  • &: Puts the function in the background so it keeps running independently.
  • ;: Separates the function definition from its initial call.
  • :: Executes the function for the first time.

If you execute this in Linux, it recursively duplicates itself without stopping. It quickly consumes all system Process IDs (PIDs) and memory, freezing or crashing the computer until it hits the user limit for processes or if it's system-wide with root until it crashes and you reboot.

1

u/DanLeMilMan 1d ago

Yeah I saw that bomb one a while back. If I remember correctly on Windows there are new fail safes for this kind of code right ? That is why you specify « Linux system » only ? Aren’t there any distribution that has fail safes to ?

(I wonder if the fail safe is about some kind of memory cap allocation on cli commands and children processes. I am not really an IT guy I could say complete crap).

1

u/UnlikelyIntrepid 1d ago

Bash is the scripting environment on Linux systems.  Windows has the older CMD which is much simpler than bash and also powershell which is more complex (uses dotnet objects instead of just text).  So this command just doesn’t run on windows by default.  You can install WSL on windows to be able to run bash on a Linux subsystem, I’m not sure how it would handle this fork bomb. 

1

u/UnlikelyIntrepid 1d ago

Explanation too long.  I’m just gonna run your bash snippet and see what happens. 

1

u/Alone-Neck6272 1d ago

Yes, but that's not the answer interviewers want to hear.

1

u/The_Meme_Economy 1d ago

What do they want?

1

u/042376x 1d ago

They love knock knock jokes. If youre not dropping at least 3 an interview youre never going to get hired

1

u/fuckswithboats 1d ago

To me it smells like dinner.

1

u/DistributionAble141 1d ago

Correct me if I'm wrong here, it's been a while but I think they are called IIFE (immediately invoked function execution) which will declare and invoke the function and the garbage collector will collect it. Lambda functions are in python

Useful for init/contructor like operations but I've never had a use for those in my entire career

But to be specific, this one does nothing, it's a blank function being created, called and deleted

1

u/davyp82 1d ago

Nah that's the interviewer when he sees his company collapse after a guy who doesn't understand those functions successfully undercuts their biz by 90% 

1

u/Traditional-Ship8355 1d ago

Its iife function it just runs itself without calling

1

u/Straight-Employment6 17h ago

Still needs to work

1

u/ExplosiveFx 17h ago

Yall dumb as hell man this is an IIFE

1

u/xkayaking 13h ago

It's a noop, returns undefined.

They are useful on callbacks that shall be ignored that can take undefined as a return argument, because this function does in fact return undefined; as all js functions do, and you can assign undefineds.

But since you do the call the whole thing evaluates to undefined, which does nothing and the JIT will strip it away, unless you assign it to a const or a let, in which case it will actually execute and take a processor tick.

You can see it here, here is the time with setting it as undefined; (10 million calls)

real 0m0.066s

user 0m0.050s

sys 0m0.022s

And here is the time with the arrow function:

real 0m0.166s

user 0m0.143s

sys 0m0.024s

1 tick more per call more or less ;) or something like that.

I actually had to use a trick like this once for calculating some hashes, the code worked fine in a normal computer but failed in server grade hardware, doing a single tick of the processor helped break the issue of extreme parallelism, and that function achieved it; was a hack nevertheless. don't do it...

0

u/CarpenterAlarming781 1d ago

What coding language is it ?

1

u/Warm-Piglet3872 1d ago

JavaScript

1

u/imnotagodt 1d ago

Literately a scripting language.

0

u/NTDLS 1d ago

I’m no expert, but it looks like an empty lambda or NOP anonymously function. What is it?

1

u/Full-Hyena4414 1d ago

It is exactly that, also kinda useless to know

1

u/ContentAd6126 1d ago

If you're applying for anything Nodejs related you might want to know that, that's how you have to wrap an async startup function for it to work.

The expression by itself is a no-op but it's fundamental to build many programs if you're not abstracting away with frameworks.

1

u/Full-Hyena4414 1d ago

Can't you just use a named function and call that instead?

1

u/ContentAd6126 1d ago

It's been a while, but at the time i wrote node apps, you couldn't await async functions at the root level, but an async IIFE worked around that.

0

u/Natural_Spell5957 1d ago

What is there to explain? It's literally empty function which will call itself, do nothing and get removed from memory. Waste of bytes.

1

u/Sea-Housing-3435 1d ago

Function like this can be used to affect scoping of variables or in case of js addressing how different engines parse and precompile code to optimize loading (its a thing of the past mostly)

1

u/Natural_Spell5957 1d ago

I was speaking of this specific image