Make your language unusable

  • Try to write some code in your language and make it not satisfying our criteria of being a programming language any more.

    A language satisfies our criteria (simplified version for this challenge) of being a programming language if:

    • It can read user input representing tuples of positive integers in some way.

    • It can output at least two different possible results depending on the input.

    • It can take two positive integers and add them (and the result can affect the output).

    • It can take a positive integer and decide whether it is a prime (and the result can affect the output).

    • For the purpose of this challenge, any kind of output that isn't an allowed output method for a normal challenge is ignored. So it doesn't matter whether the program can also play a piece of music, or posting via HTTP, etc.

    • Update: You can also choose one or some of the allowed output methods, and ignore all the others. But you must use the same definition everywhere in the following criteria. And if your program can disable more than one output methods — that worths more upvotes.

    Examples like making it not able to output, or disabling all the loop constructs so it won't be able to do primality test and making sure the user cannot re-enable them.

    You should leave a place for inserting new code. By default, it is at the end of your code. If we consider putting the source code in that place in your answer and running the full code as a complete program the interpreter of a new language, that language should not satisfy the criteria.

    But the inserted code must be executed in such a way like a language satisfying the criteria:

    • The inserted code must be grammatically the same as something (say it's a code block in the following criteria) that generally do satisfy the criteria, from the perspective of whoever wants to write a syntax highlighter. So it cannot be in a string, comment, etc.

    • The inserted code must be actually executed, in a way it is supposed to satisfy the criteria. So it cannot be in an unused function or sizeof in C, you cannot just execute only a non-functional part in the code, and you cannot put it after an infinite loop, etc.

    • You can't limit the number of possible grammatically correct programs generated this way. If there is already something like a length limit in the language you are using, it shouldn't satisfy the criteria even if this limit is removed.

    • You can't modify or "use up" the content of input / output, but you can prevent them from being accessed.

    • These criteria usually only applies to languages without explicit I/O:

      • Your code should redirect the user input (that contains informations of arbitrary length) to the inserted code, if a code block isn't usually able to get the user input directly / explicitly in the language you are using.

      • Your code should print the returned value of the inserted code, if a code block isn't usually able to output things directly / explicitly in the language you are using.

      • In case you print the returned value, and it is typed in the language you are using, the returned type should be able to have 2 different practically possible values. For example, you cannot use the type struct {} or struct {private:int x;} in C++.

    This is popularity-contest. The highest voted valid answer (so nobody spotted an error or all errors are fixed) wins.


    • You shouldn't modify the code in the text form, but can change the syntax before the code is interpreted or compiled.

    • You can do other things while the code is running. But the reason that it doesn't satisfy the criteria should be within the inserted code itself. It can error because of the interference of another thread, but not just be killed by another thread.

    • All the specs basically means it should be grammatically likely satisfying the criteria if all the built-ins were not changed but not actually do. It's fine if you find any non-grammatical workarounds, such as passing the parameters to the code block correctly, but make them not able to be used in some way.

    • Again, the inserted code must be actually executed. Code after an infinite loop or crashing is considered "not actually executed", thus not valid. Those answers might be interesting, but there are already some other infinite loop or crashing questions on this site, and you may find a more appropriate one to answer. If not, consider asking a new question. Examples of those questions are:


    var QUESTION_ID=61115/*,OVERRIDE_USER=8478*/;function answersUrl(e){return""+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return""+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,/*getComments()*/(more_answers?getAnswers():process())}})}/*function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}*/function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),score:s.score,language:a[1],lang:jQuery('<div>').html(a[1]).text(),link:s.share_link})}),e.sort(function(e,s){var r=e.score,a=s.score;return a-r});var s={},r=1,a=null,n=1;e.forEach(function(e){e.score!=a&&(n=r),a=e.score,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",e.n=n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.score).replace("{{LINK}}",,t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text())/*,s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,}*/});var t=e/*[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o])*/;t.sort(function(e,s){return (e.lang.toUpperCase()>s.lang.toUpperCase())-(e.lang.toUpperCase()<s.lang.toUpperCase())||(e.lang>s.lang)-(e.lang<s.lang)});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{PLACE}}",o.n).replace("{{LANGUAGE}}",o.language).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.score).replace("{{LINK}}",,i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<(?:h\d|(?!.*<h\d>)p)>\s*((?:[^,;(\s]| +[^-,;(\s])+)(?=(?: *(?:[,;(]| -).*?)?\s*<\/(h\d|p)>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;

    body{text-align:left!important}#answer-list,#language-list{padding:10px;float:left}table{width:250px}table thead{font-weight:700}table td{padding:5px}

    <script src=""></script> <link rel="stylesheet" type="text/css" href=""> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Score</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Sorted by Language</h2> <table class="language-list"> <thead> <tr><td></td><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{PLACE}}</td><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

    Am I allowed to change the code before executing it? Also, can I run other code whilst I am running the code given?

    @muddyfish Basically no and yes. See the clarifications.

    If it wasn't for `#{...}`, I'd have a neat GolfScript answer...

    What about code that executes an infinte loop, so your code after it never gets executed. Is that valid?

    @ppperry If the inserted code is after the infinite loop so it is not executed, then no. If the inserted code runs into a infinite loop itself, it's fine.

    I'm not sure what the update means. If the intention is that it's sufficient to break `print` statements and you can claim to be ignoring output to a file then I think the current wording allows you to claim to be ignoring *all* standard output mechanisms.

    @PeterTaylor How? And note that the grammatically equivalent reference must satisfy the criteria in any definition you choose.

    What do you mean by that? That if you want to ignore all output mechanisms, you have to provide a new one?

    And if so, that seems to be in stark contradiction to the way you haven't complained that the answers which close stdin are violating the rule "*Your code should redirect the user input (that contains informations of arbitrary length) to the inserted code, if a code block cannot get the user input directly in the language you are using.*".

    This could have made a really great cops and robbers challenge I think.

    @PeterTaylor You should choose at least one output mechanism and ignore all other mechanisms. For the later comment, I have changed "cannot" to "isn't usually able to". It's only meant to prevent answers doing nothing in a language without explicit IO.

    @Sp3000 Rephrased that part a bit and hope it became clearer.

    @DankMemes There is a related cops-and-robber in the sandbox by feersum, which removed the part about hacking existing languages, but just write a new language for the robbers to use.

    So then it seems to be saying that in languages with explicit IO it's permissible to do completely boring things like reading and discarding the contents of stdin. It sets up a completely unfair playing field where some languages require you to carefully handle the IO for the inserted code, and other languages allow you to trash it and deny IO to the inserted code.

    @PeterTaylor Added a criteria to disallow it. I'm not sure this solves all the problems.

    I assume this is not allowed, but figured i would check: can I modify the user code at runtime?

    @pseudonym117 No. See clarifications.

    What about solutions that redefine some of the required operations to produce invalid output, like 2 + 2 = false?

    A lot of the answers below make the new inserted code error out. Is that OK? I mean, is it OK to modify your runtime/language in such a way that all new code are errors?

    @jdphenix That's ok, and is the supposed way solving this challenge.

    @slebetman I think it is ok. Technically, only "limiting the number of possible *grammatically* correct programs" is currently forbidden.

    Are these answers satisfying what you were looking for? Break the language so it's unusable or were you hoping for something else?

    @Luminous Some of them doesn't. The intention was to break the language by redefining the language, not by running into an infinite loop, etc, which is a normal features of any Turing-complete language.

    @jimmy23013 the clarifications do not exactly clarify what i meant to ask. What I meant was can I do something like this (using .NET as an example): before the IL code is JIT compiled to native code, change all of the IL op codes in the user program into NOPs. So the instructions would be called, they would just do nothing.

  • Downgoat

    Downgoat Correct answer

    6 years ago

    JavaScript Shell

    This will make the language completely unusable.


    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:
    Example Usage
    *REPL environment not required.
    Uses the SpiderMonkey engine (shell not browser), the original JS engine.

    That `clear` function seems to be a SpiderMonkey-shell-specific addition, not a generic JavaScript thing. It certainly doesn't appear in the ES5 spec § Function Properties of the Global Object. I tried this with `node` and got a "ReferenceError: clear is not defined". In Chrome's and Firefox's console, the `clear` function just clears the console, regardless of what arguments it is passed. Or perhaps the tool you used complied to a version of ECMAScript older than 5.1?

    @Anko I'd specified that this is uses the `SpiderMonkey` engine in a footnote. I could port this to other shells considering writing `clear` function is pretty trivial.

    Could you instead amend the statement “Isn't it nice how JavaScript has such a nice function to destroy itself”? JavaScript doesn't have that function, only the SpiderMonkey implementation does.

    @Anko SpiderMonkey is JavaScript though, it comes bundled with Firefox (SpiderMonkey *is* Firefox's JS engine). I'll write up a version for node.js, etc. later, when I have time

    I think you're confusing JavaScript (the language) with SpiderMonkey) (one of the many implementations of the language). Extreme allegory: While I *could* write a crazy *implementation* of C in which all invocations of undefined behaviour result in printing the full text of the Declaration of Human Rights, I probably wouldn't be able to argue that my C submission to "golf the UDHR" that just dereferences a null pointer is a valid C solution. :)

    @Anko that is pretty different imo . SpiderMonkey is a very mature and popular JS engine.

    @Anko As a per site rule, a language is defined by its implementation. If an answer works consistently in at least one implementation that was *published before the question*, then it is acceptable. See here and here. (So the code is valid. But I'll not comment on that specific wording.)

    ..So, basically `rm -rf`?

    @SIGSEGV `rm -rf` wouldn't affect the program being executed since most likely it would be loaded into memory by the time. Also, this is clearing the runtime environment (i.e. variables, methods) rather than the disk, so significantly less destructive

    @Downgoat Nah, I meant the code `rm -rf`'ing itself or something

    Can you write the Node.js version as you promised now?

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM