Self modifying code is frowned upon on modern platforms, due to its security implications.
Self modifying code is not allowed on some o/s because pages with code are marked as non writable, because bad things can happen when code is writable, eg buffer overflows.