The Bash example is simply wrong:
#!/bin/bash
./$0|./$0& # $0 is the name of the shell script itself
There is no need for the leading ./ if the script was invoked via a relative path ($0 will already have it) and adding it will break it if the script is invoked via an absolute path or name that is resolved against $PATH.Further, what $0 holds is only a convention and up to the caller. If you are already restricting yourself to Bash, used ${BASH_SOURCE[0]} to always get the path to the script file.
But really, there is no need for a separate Bash version when the classic POSIX sh fork bomb already covers it (included in the repo as fork-bomb.sh):
:(){:|:&};: