Make your language unusable
JavaScript Shell
This will make the language completely unusable.
clear(this);
Isn't it nice how JavaScript has such a nice function to destroy itself?
This is pretty simple, the clear
function completely empty an object. this
refers to the global object clearing out everything including constructors and functions.
Because this clears everything, doing anything, even defining a literal will throw an error, making the language completely useless: *REPL environment not required. Uses the SpiderMonkey engine (shell not browser), the original JS engine.
Emmental
;#33!
I know this isn't code golf, but the right tool for the job, you know...
The user's code can be inserted after the !
.
Emmental is an interesting esolang which is based on rewriting the interpreter. Every single symbol (including the built-in ones) can be redefined as an arbitrary Emmental program. The language relies on this feature so much that it doesn't provide any looping constructs. Instead, you define recursive commands which appear in their own definitions.
This redefinition happens via !
, which reads a character from the stack, and then reads a string from the stack until it encounters a ;
. The character is then redefined to mean the program represented by that string.
That means, we can disable Emmental's looping features by redefining !
itself as the empty program. While all other Emmental code still runs perfectly fine, and many of the criteria of a programming language are still fulfilled, it is impossible to redefine any more symbols. Without this feature (and therefore, without being able to loop), Emmental can no longer test whether a number is prime.
PHP
One can completely kill PHP by setting the memory limit to 1.
It will completely die.
Try this:
<?php
ini_set('memory_limit',1);
//code here
This shouldn't even throw any error, since there isn't enough memory for that.
You can read more about the memory_limit
directive
If the previous one is invalid, one can use output buffers:
<?php
ob_start();
//code here
ob_clear();
This completely removes any output. Since the output buffer is still open, some other things accidentally left after the code won't be shown as well.
Using @fschmengler's idea:
<?php
define('OB_START_LEVEL', ob_get_level());
ob_start(function(){return'';}, -1, PHP_OUTPUT_HANDLER_CLEANABLE);
//or, for PHP <5.3:
//ob_start(create_function('','return"";'), -1, PHP_OUTPUT_HANDLER_CLEANABLE);
//code here
while(ob_get_level() > OB_START_LEVEL) ob_clear();
This will avoid the problem of deleting the automatically started output buffer, used to catch the output to be compressed.
This also prevents that the output buffer is deleted or flushed (sent to the browser). To re-inforce that, an output handler is added, that always returns an empty string.
Running ob_end_flush(); echo "Hello, world!";
won't produce anything, but would send the output with a plain ob_start();
.
Thanks to @LucasTrzesniewski for exposing this issue!