• OpenStars@piefed.social
    link
    fedilink
    English
    arrow-up
    16
    ·
    13 hours ago

    Boss: don’t spend any time on it, just vibe code a solution.

    You: sure, I enjoy receiving a salary, what could go wrong?

  • katy ✨@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    32
    ·
    edit-2
    13 hours ago
    bool isOdd(int num) {  
    	const oddNumbers = [];  
    	for (let i = 1; i <= 10000000; i += 2) {  
      		oddNumbers.push(i);  
    	}  
    	if (oddNumbers.includes(num) {  
    		return true;  
    	}  
    }  
    
      • Mad_Punda@feddit.org
        link
        fedilink
        arrow-up
        22
        ·
        edit-2
        16 hours ago

        Might very well be an endless loop because tail recursion can be optimized to reuse the stack frame. Depends on a lot of things of course.

        • orhtej2@eviltoast.orgOP
          link
          fedilink
          English
          arrow-up
          18
          ·
          15 hours ago

          Forkbomb kills the entire system so not really.

          With the stack overflow the runtime will gracefully terminate the program.

        • calcopiritus@lemmy.world
          link
          fedilink
          arrow-up
          10
          ·
          edit-2
          15 hours ago

          No.

          A stack overflow is a symptom, not the illness. A fork bomb is an illness.

          Software coming from the mathematical point of view, assummes it has infinite resources. However, a real computer has many resources that are finite.

          CPU time is finite. Memory amount is finite. There is a finite number of network ports. And so on.

          A stack overflow just means: “you have run out of this resource called ‘the stack’”. The stack is a region of the memory. Each thread of each process has 1 stack, and it is not infinite in size. This program will cause a stack overflow because it is infinitely recursive, and each function call will consume a bit of the stack.

          A forkbomb is not the end of a finite resource. A fork bomb is a program that uses “forking” to rapidly consume system resources. A fork bomb might cause a stack overflow. Or an out of memory issue. Slow the computer a lot. Or if the OS has a hard limit for process amount, it might reach that limit.