• This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional questions.

  • This is no longer a , nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

  • All answers should include the name of the programming language at the top of the post, prefixed by a #.

  • Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

  • Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

  • The snippets do not need to be related. In fact, snippets that are too related may be redundant.

  • Since this is not a contest, all programming languages are welcome, whenever they were created.

  • Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

  • Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('<li><a href="/a/' + data.items[i].answer_id + '">' + temp.innerText || temp.textContent + '</a>');}}})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul>

  • 1
    \$\begingroup\$ Why preserve a tag for one question, is it still bad for SE to have untagged question? \$\endgroup\$
    – l4m2
    Jan 4 at 1:43

241 Answers 241

5 6 7 8


Note: [min]mod is too difficult to use for most code challenges, and is a horrible golfing language too. Please tell me whether or not I can still keep this submission here.


[min]mod is a language where all data is possibly nested stacks of instructions. Variables storing such stacks can themselves be executed, in which case their contents are executed element by element.

Length 0 snippet

Try it step by step! (click on the program.[m]m file to see the contents, and the play button to execute)

The program is stored in a sub-stack in IS, the built-in instruction stack; so in this case IS stores [[]]. The sub-stack is popped since it doesn't contain any instructions, and the program then terminates since IS is empty.

Length 1 snippet


Try it!

This will attempt to execute the variable A, and will throw an error since A is uninitialized.

Length 2 snippet


Try it!

This is the shortest infinite loop in [min]mod, and one of the shortest valid non-empty programs.

Since the instruction stack is a variable, it can be executed like any other. In this case, the value of the instruction stack will initially be [[IS]]. The program will try to execute the first instruction in IS, which is IS itself, by pushing its contents onto IS as a new sub-stack. At principally the same time, it pops that instruction from IS, making IS now contain [[[IS]] []]].

Since the first instruction in the first sub-stack in IS is now a stack, it will be popped. Simultaneously, its contents are pushed as a new sub-stack, making IS contain [[IS] [] []]. Now, IS will be executed again, grow, be executed again, grow, and so on forever (assuming the computer has infinite memory).

Length 3 snippet


Try it!

Unlike the length 1 snippet, this won't throw an error since it won't actually execute A. The number of periods after an instruction determines its indirection level. An instruction or sub-stack with an indirection level of 0 will be executed, but with an indirection level of one or more, the instruction or sub-stack will instead be pushes onto the data stack, or the DS, which is another built-in variable.

The instruction pushed onto the data stack will have an indirection level one lower than the one executed, so A.. pushes A. onto the data stack.

Length 4 snippet


Try it!

Since the program itself is a stack (or, rather, a sub-stack of the instruction stack), one might expect B to be pushed first, since it's presumably the top element of the stack. That's not true, however, since the program stack and its sub-stacks are reversed before being pushed onto IS for that exact reason: it's difficult to write code backwards. In other words, the above program pushes A, then B.

Length 5 snippet


This program first [] is pushed onto the data stack. Then, the built-in variable IF is executed. IF contains a special magic instruction that pops once from the data stack, then once more if the first element was an empty stack (or a variable whose value is an empty stack). Here, the stack is empty, but there's no elements left to pop after it's gone, so the program will throw an error.

Try it!

Length 6 snippet


Try it!

Unlike the length 5 snippet, the IF instruction here is applied to a non-empty stack, so it'll only pop once and will therefore not throw an error.

Length 8 snippet


Try it!

This program pushes B and A onto DS before executing the SET instruction, which sets the top element of DS to the second element from the top. Since both A and B are uninitialized, they'll retain their (nonexistent) values, so it would probably make more sense to set A to [] or something.

Length 9 snippet


Try it!

After pushing IS onto DS, the built-in UNWRAP instruction will replace IS with a reference to its value. This means that if the current value of IS changes, so will the stack reference in DS. If IS is reinitialized by the SET instruction, however, the stack reference in DS will still refer to the previous value.

Length 10 snippet


Try it!

The built-in variables that makes sense to execute aren't defined as magic instructions, but rather as stacks containing magic instructions. Therefore, they can be given a new value like any other instruction. This program sets SET to an empty stack, making SET a noop and [min]mod Turing-incomplete.

5 6 7 8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.