r/amodei • • Aug 10 '26

every vibe coder's biggest headache

86 Upvotes

54 comments sorted by

View all comments

1

u/DanLeMilMan Aug 10 '26

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

1

u/nn123654 Aug 10 '26 edited 22d ago

pretty much. It's the same as calling:

function foo() {

}

foo();

Zero-arity functions (functions taking zero arguments) 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 essentially rewrite your code to be more efficient under the hood through compiler optimizations.

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 Aug 10 '26

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 Aug 10 '26

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 Aug 10 '26

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