507
\$\begingroup\$

Notes

  • 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>

\$\endgroup\$

229 Answers 229

7
\$\begingroup\$

Carrot

4-byte code

0^*2

(Prints 000)

I have chosen to use this snippet because of its weirdness. So the first bit of the code says that the stack is 0. Then the * is string multiplication. It multiplies "0" 2 times. One would expect the output to be 00, but no! 000 is outputted instead. So the stack is repeated 2+1=3 times, which gives 000. This trick is useful for golfing when you want to output the stack 10 times. Instead of going (stack)^*10, you will do (stack)^*9 because it saves one byte!

3-byte code

$^P

The $ is the alternative to # for taking input. In the future I hope to distinguish these two similar functions... Coming back to the topic, we see the caret ^ for the first time. This is to differentiate the stack from the commands. Then comes the P. This checks if the stack is a prime or not(works for the number 1). This primality checking works on the stack both as a string or as a number. This "special power" of P can make it more useful for code-golfing.

2-byte code

#A

Outputs inputA. If the input is C, then the output would be CA

This piece of code shows two interesting properties of Carrot:

  1. One is that the string "A" does not need to be enclosed in quotes in the stack.
  2. The other one is that the plus "+" sign for concatenation is not required in the stack. The two strings, the input and the "A", get joined together automatically.

1-byte code

#

This is a simple program that prints the output as it is. The # can be used in the commands or the stack section of the program. The caret ^ is not required because we do not wish to use commands.

Factoid: Carrot is a language made by me, Kritixi Lithos, based on this carrot meme of PPCG. Every Carrot program as of version ^2 must have a ^ in it. The structure of every program is as follows: stack^commands.

\$\endgroup\$
  • \$\begingroup\$ whaaat no carrot required? XD \$\endgroup\$ – Conor O'Brien Nov 3 '15 at 17:21
  • 1
    \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ Carets are not required from Version ^3 and forth if we want to use no commands. \$\endgroup\$ – Cows quack Nov 3 '15 at 17:23
  • 1
    \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ There! The carrot is back again in the third byte! \$\endgroup\$ – Cows quack Nov 3 '15 at 17:41
7
\$\begingroup\$

JacobFck

JacobFck is a stack based esoteric language written in C#. It is capable of all basic operations as well as some more common operations. It is a slight mix of BrainFuck like syntax and Forth. The link above links to the JacobFck GitHub.

Length 1

>

This is one of the simplest instructions. It writes to the screen whatever is at the top of the stack.

Length 2

^5

The ^ instruction tells the interpreter that we are going to be pushing data (either number or register value) onto the stack. In this case, the number 5.

Length 3

"s"

Strings (encased in "") are automatically pushed to the top of the stack, and \n \t \r are all supported escape codes.

Length 4

^2<+

This code would push 2 to the stack with the ^ instruction, push user input to the stack with the < instruction, and add the two together by popping them off the stack and pushing the result to the top.

Length 5

:a<_a

This code is an example of an infinite loop. :a declared the label a. < is the instruction to prompt the user for input. _a goes to the label a.

\$\endgroup\$
7
\$\begingroup\$

Wierd

Factoid

Unlike other languages where the symbols in a program determine which instructions are executed, in Wierd, it is the bends in the chain of arbitrary symbols that determine which instructions are executed.

Chris Pressey created the angle-to-instruction mapping, and christened the entire mess "Wierd"--a cross between the words "weird" (which the language seemed to be) and "wired" (which would describe the appearance of programs written in the language)

You can try it online at http://catseye.tc/installation/Wierd_(John_Colagioia)

Length 1 Snippet

!

The actual character used doesn't matter - it can be any non whitespace character. This program doesn't do anything because there are no bends in the chain of characters - but there is a chain so at least it is a valid program.

Length 2 Snippet

++

Now we are going somewhere - we have a chain of characters. Still no bends so you wouldn't expect it to do anything but unintuitively this program does actually do something.

The current location starts in the top left corner facing "diagonally down and right". The current location always moves with inertia - it will move in the direction it is already moving until it can no longer do that and then will move in a direction closest to the current direction.

So the current location has to change 45 degrees so that it can continue to the right and that counts as a 45 degree bend so we push 1 onto the stack - exactly the same outcome as the Length 5 Snippet.

Length 3 Snippet

+
+

Same as the Length 2 Snippet this program does actually do something because the current location starts in the top left corner facing "diagonally down and right" and the current location has to change 315 degrees so that it can continue to the right and that counts as a 315 degree bend which will subtract the two items on the top of the stack. But there is nothing on the stack so the bend is a no-op and the program does nothing.

Length 4 Snippet

+
 +

The current location starts in the top left corner facing "diagonally down and right" so there are no bends in this chain of characters and so this program doesn't do anything.

Length 4 Snippet

+
++

Finally a program with a bend! But it doesn't do anything useful :(

The current location starts in the top left corner facing "diagonally down and right". The current location always moves with inertia - it will move in the direction it is already moving until it can no longer do that and then will move in a direction closest to the current direction.

So the current location moves "diagonally down and right" and arrives at the next bend. It is a 225 degree bend so if the stack were to contain a zero it would push one character of standard input onto the stack and if it were a nonzero value then a value from the stack would be written to standard output. But there is nothing on the stack so the bend is a no-op.

Now the current location moves around the bend without doing anything, the current direction is towards the left and we are at another bend. This one is a 270 degree bend so if the stack were to contain a nonzero value the current direction would reverse. But there is nothing on the stack so the bend is a no-op.

Now the current location moves around the bend without doing anything, the current direction is up and we are at another bend. It is a 270 degree bend so if the stack were to contain a nonzero value the current direction would reverse. But there is nothing on the stack so the bend is a no-op.

Now the current location moves around the bend without doing anything, and we are in an infinite loop.

Length 5 Snippet

+
 ++

Finally a program that does something!

The current location starts in the top left corner facing "diagonally down and right" so the current location moves "diagonally down and right" and arrives at the next bend. It is a 45 degree bend so we push 1 onto the stack.

There are only four ways to get values onto the stack:

  • Push a 1
  • Subtract two values already on the stack
  • Use a value on the stack to decide to read from standard input
  • Use corordinates on the stack to read a value embedded in the program

So the only way to get a value onto an empty stack is to push a 1.

\$\endgroup\$
7
\$\begingroup\$

GoLScript

Interpreter.

5-vote

HAAZW

This is another simple program.

Generation 0

H pushes 7, A pushes 0. Z is a fun command that pops Y, X and pushes the character at FIELD[Y][X], or (X,Y). In this case, the character at (0,0) is H, and so it's char code is pushed. W outputs this as a character.

The two outer-most cells die.

Generation 1

We are left with AAZ, another call to Z, pushing h's char code to the stack (as the former H is now dead and thus lowercase). However, since the W died, it can no longer function, and thus, this phase ends.

Once again, the two outermost cells die.

Generation 2

Now, only A is left, which carries out its duty in pushing a 0, and then dies. The program is effectively stopped.

4-vote

Bp
P

(newline counts as a character, iirc.) This does something rather simple:

  1. The program is first BpP. This pushes 1 (B), pops a value (1) and assumes it p => P, and does that again, popping a zero from the bottom of the stack P => p.
    1. Checking, only the new P survives, as it popped a value and lived. The rest of the characters died.
  2. After, only the P remains; it pops an empty value (0) and dies.

3-vote

JXJ

First multi-step program! Here's what happens:

Generation 0

The code is evaluated: J pushes 9 to the stack, X pops a number and prints it, and J again pushes 9 ot the stack.

The cells' live-states are updated. Both Js die, having only 1 neighbour. The X lives, as it has 2 neighbours.

Generation 1

All that remains is the X. This prints the remaining 9 off the stack.

The X dies, and the program terminates.

Final output

99

Hey, it's a start…

2-vote

@V

The shortest (?) still life in GoLScript. @ negates the top of the stack (effectively pushing true) and V reads the top of the stack, and dies if the value is falsey. Replacing @ with any of B-J would also produce a still life.

1-vote

X

Any 1-length program is valid. This one takes a zero of the stack (there is an infinite amount of zeroes atop the stack) and outputs it as a number.

0-vote (factoid)

GoLScript simulates Conway's Game of Life! Yay! Interpreter. You'll have to copy-paste the codes, and output is the bottom-most code block.


Language information

  • GoLScript is stack-based.
  • GoLScript has no native string quoting!
\$\endgroup\$
  • \$\begingroup\$ When will we run out of names beginning with Gol...? Gol><>, Golfscript, GoLScript, Golang (okay, not very golfy, but you get my point) :P \$\endgroup\$ – cat Apr 27 '16 at 22:43
  • \$\begingroup\$ @cat upvote it if you like it ;) it's "Game of Life"... \$\endgroup\$ – Conor O'Brien Apr 27 '16 at 22:44
  • \$\begingroup\$ I think you meant Game of Code Golf, since Code Golf is life... \$\endgroup\$ – cat Apr 27 '16 at 22:46
  • \$\begingroup\$ @cat GOCG doesn't have as nice of a ring to it ^_^ \$\endgroup\$ – Conor O'Brien Apr 27 '16 at 22:47
  • \$\begingroup\$ Add permalinks to the Interpreter \$\endgroup\$ – Cyoce Apr 30 '16 at 1:20
7
\$\begingroup\$

Molecule

Factoid
Molecule is the descendent of Pylongolf2, a descendent of Pylongolf which was based on CJam.

0 byte snippet:

 

This does not do anything as it is empty.

1 byte snippet:

I

I read the input.
As Molecule outputs everything in the stack once the program shuts down, this makes a decent cat program.

2 byte snippet:

()

Anything between ( and ) is looped until ! is called.

3 byte snippet:

Inh

Read the input, convert it into a number.
The h converts numbers into characters.
So you can get some funky characters by using this.

4 byte snippet:

`q`n

Now here's where you could break the program.
Molecule has a built-in reflections system that allows you to modify the source code at runtime.
`q Push the source code, `n sets the source code to itself.
From v5.5, this snippet forces the interpreter to read from the start, creating a loop.

5 byte snippet:

0(1+~)

Have your program count until it reaches Infinity.. then it crashes.
(On my computer takes about 2 minutes to crash :P)

6 byte snippet:

u10000

Print 10000. What is so interesting about this?
It's interesting because putting a simple 10000 will push 1 and 5 zeroes to the stack, while the u keyword pushes the entire number after it.

\$\endgroup\$
  • 1
    \$\begingroup\$ I can't wait for the 2 byte snippet! \$\endgroup\$ – CalculatorFeline Apr 25 '16 at 16:59
7
\$\begingroup\$

Poslin

Factoid

Poslin is a concatenative language with strict postfix notation and a metacircular interpreter.

It is similar to the language described in EWD28 in principle but is not inspired by it.

Unlike the language described in the linked paper, the immediateness of a symbol is definable in code, allowing the programmer to define almost arbitrary new syntax. Things like the symbol table and lexical environments exist as first class objects.

Every token in Poslin is surrounded by whitespace.

Length 1 snippet

!

This is actually not a working program. Executing it in a fresh session gives a stack-bottom-error. This operation is immediate and executes the operation on top of the current stack. Without it, nothing would ever happen.

Length 2 snippet

&+

This also isn't a working program. & is an immediate operation to compile something into a thread. &+ also is an immediate operation, but after compiling it executes the operation stored at a place accessible via HOOK compilation-hook slot-sub-get.

This way users can define their own optimization passes.

Length 3 snippet

[ ]

This creates an empty stack. [] also creates an empty stack ad does so much more efficiently. That's because Poslin works with something which is called the path. The path is a stack of environments, where environments are kind of like prototyped objects, that is, they are mappings (from symbols to bindings) which can have parent-environments. When some object is found by the reader which is not an immediate symbol, it is put onto a stack which is saved in a binding (besides the path, the return stack and arguably streams the only mutable data structures in poslin) which is found under the symbol STACK in the environment on top of the path.

[ puts a new environment onto the path which contains a fresh binding containing an empty stack for it's STACK. ] pops the topmost environment off the path and then extracts the stack saved in the binding in its STACK slot.

[] just constantly returns an empty stack.

[], [ and ] are all immediate.

Length 4 snippet

'& &

There is no single operation in poslin which defines a new operation. Well, actually there are several, but they're all defined in the standard library, which is written in a subset of poslin called "poslin0".

& has the purpose of transforming a given object into a thread.

For threads it's just an identity operation.

Symbols are looked up in an environment saved in a binding in the OP slot of the environment on top of the path.

Stacks are converted by turning everything but threads into constant functions returning that object and then concatenating together the resulting objects into one thread. At least, that's roughly how it works. This means, of course, that any operation which should be called inside a thread created this way needs to be turned into a thread via & before the calling thread is constructed.

Every other object is turned into a constant thread returning that exact object.

'& is special syntax: The leading ' tells the reader that this is a quotation, that is, everything after the ' is interpreted as a symbol (including any other 's) and then just put onto the current stack without checking for immediateness.

So the given snippet returns the thread of our poslin compiler. It is used in the operation ]o, which defines a new operation. With the knowledge given up to this point, you might be able to figure out how defining an operation works conceptually, even if you are missing some important operations.

Length 5 snippet

$:
":

This is the string you'd normally see as "\"" in most other languages, that is, the string containing exactly the double-quote character.

The character $ starts a delimited string. A delimited string has a delimiter, which is given between the $ and the next newline. The string contains all characters between that newline and the next occurence of the delimiter followed by some kind of whitespace.

If the delimiter occurs and is not followed by whitespace, it is a part of the string and does not function as delimiter. Remember: Every token in Poslin is surrounded by whitespace.

So, the given string could also be written as

$"
""

or even """, as Poslin recognizes the usual syntax for strings, too. It does not recognize any escape sequences.

Length 6 snippet

+ call

This is almost equivalent to + &. The important difference is that + & returns the thread of + while + call returns a thread which reads the binding which holds the definition of + and then calls the content of that binding. So, if you expect that the definition of + might change and you need to call the new definition instead of the old one, use + call.

This is necessary for defining recursive operations. There is no way to insert a thread into itself, so the binding which is later intended to contain the thread is inserted instead via call and after the thread is constructed it is written into that binding.

Length 7 snippet

. ? ! !

? consumes the top three elements off the stack. The third from the top needs to be a boolean value. If it is true, the second from top is put back onto the stack, if it is false the first from top is put back onto the stack.

. is simply the no-op.

So this is an immediate when. Imagine the following stack:

[ 2 TRUE P{negation} ]

This proceeds as follows with the above sequence:

[ 2 TRUE P{negation} . ]
[ 2 TRUE P{negation} . ? ]
[ 2 P{negation} ]
[ -2 ]

Whereas if the stack is

[ 2 FALSE P{negation} ]

It proceeds thus:

[ 2 FALSE P{negation} . ]
[ 2 FALSE P{negation} . ? ]
[ 2 . ]
[ 2 ]
\$\endgroup\$
7
\$\begingroup\$

Quetzalcoatl

6 snippet:

{c.I?}.

Makes a block with Code Snippet 4.

5 snippet:

{c.I}

Makes a code block, containing the code c.I. On snippet 8, we will use this.

4 snippet:

c.I?

Same as before, but also does power. Result is xth root of x.

3 snippet:

c.I

Outputs (input, 1/input) because I in 1/.

2 snippet:

c (or any token) + -q compiler flag

Proper quine. -q outputs source instead of running code.

1 snippet:

1 or (no code) + -n (1 byte).

Like in GolfScript, numbers just push their value. This outputs 1 because Quetzalcoatl implicitly prints the stack. This works for any digit 0-9. Second snippet outputs Quetzalcoatl, because -n outputs Quetzalcoatl.

Interesting fact:

Quetzalcoatl got its name from the Aztec snake god (I wrote it).

\$\endgroup\$
  • \$\begingroup\$ Is this meant to be a golfing language? \$\endgroup\$ – Cyoce Apr 9 '16 at 21:50
  • \$\begingroup\$ @Cyoce This is a golfing language. \$\endgroup\$ – NoOneIsHere Apr 10 '16 at 15:37
7
\$\begingroup\$

Coffeescript

Description:

Coffeescript is a language that compiles into Javascript. It's much less verbose than JS (and about the same as ES6), which makes it friendlier for ing.

Factoid:

Coffeescript doesn't require brackets with function calls.

Length 1 Snippet:

=

The = sign means a lot of things in Coffeescript - it can assign both functions and variables in one fell swoop, much like Javascript.

Length 2 Snippet:

**

This is the power sign, which is used like this: a**b. It replaces JS's Math.pow(a,b), which saves 11 bytes.

Length 3 Snippet:

(n)

This is an argument in CoffeeScript, and is used like so:

{function name} = (arg1, arg2...) ->

(This is basically the same as JS, but I just wanted to show off functions - because they're so different).

Length 4 Snippet:

0..5

For-loops are different in CoffeeScript. This snippet, when put into this context:

for a in[0..5]

Is the same as JavaScript's

for (a=0, a<5, a++)

and Python's

for a in range(5)

As you can see, this snippet shows the byte-saving powers of CS.

Length 5 Snippet:

n=->1

Yay, a full function!

This snippet creates a function, n, with no arguments, which outputs 1.

Length 6 Snippet:

if n<1

This is an if statement, in CS. Notice the lack of a colon, or curly brackets (yes, no curly brackets!). This compares n, and checks if it's less than 1.

Simple enough.

Length 7 Snippet:

class A

This is a class declaration in CoffeeScript. Despite there being no support for classes in JavaScript, there's classes in CS - and they work exactly the way you expect them to.

\$\endgroup\$
  • \$\begingroup\$ That = declaring functions sounds bad to me. I would say, it is another case when a value is assigned to a variable, just the value is not number or string, but an anonymous function. \$\endgroup\$ – manatwork Aug 11 '16 at 11:15
  • \$\begingroup\$ Math.power don't exists; the correct function is Math.pow \$\endgroup\$ – TuxCrafting Sep 7 '16 at 8:48
7
\$\begingroup\$

Pip

An imperative golfing language with infix operators, with commands in printable ASCII. While these design decisions mean that Pip will probably never beat Jelly in a golf contest, they also make the language much easier to learn and use.

Factoid

To my knowledge, Pip was the first golfing language to have built-in regex support.

The header of each snippet is a TryItOnline link.

Length 1

a

Pip's default method of getting input is by command-line arguments (hereinafter "cmdline args"). The first five args are assigned to the variables a through e, and the whole list is assigned to g.

Since it is at the end of the program, the expression a is auto-printed. So this program outputs the first cmdline arg.

Length 2

/q

To get input from stdin, use the q special variable. Every time it is referenced, it reads a line of input.

Many operators have both binary and unary versions. This is expected behavior for operators like -, and makes good sense for others like ^ split and J join. Here we have a somewhat unusual example: unary / inverts its argument. Inputting 4 will give 0.25 as output, and vice versa.

This snippet also demonstrates a feature that Pip shares with Perl and PHP: numbers are strings and strings are numbers. Both are represented by a data type called Scalar. Upshot: you don't have to convert q's line of input to a number before doing math with it.

But what happens if you input something that's not a number, like Hello world? In a numeric context, it's treated as 0. Dividing by 0, like most error conditions, returns the special nil value, which produces no output when printed. If you want to see what went wrong, you can use the -w flag to enable warnings, in which case Pip will tell you:

Inverting zero

Length 3

Uses the -p flag (+1 byte).

^g

As mentioned above, g is a list of all cmdline args. Many operators work itemwise on lists, and ^ (split) is one of them. This code splits the items of g into lists of characters.

If you ran this 2-byte code without the flag, it wouldn't be obvious what the program did, because Pip's default way of outputting lists is to concatenate the items together. To demonstrate that the split operation worked, we need to change the output format. About half of Pip's command-line flags have to do with list formatting. The -p flag applies RP (analogous to Python's repr) to the list before outputting it, making it easy to see the structure:

> python pip.py -pe "^g" 42 Hello
[[4;2];["H";"e";"l";"l";"o"]]

Use the TIO link above to play around with the other list flags (-s, -n, -l, -P, -S) and see how the output changes.

Length 4

z@<h

Lowercase letters h through z are global variables, preinitialized to different values. z is the lowercase alphabet; h is 100.

The @< "left-of" operator returns a slice from the left end of an iterable (scalar, list, or range). It's equivalent to Python iterable[:index]--except that the Pip version works even when the index is greater than the length of the iterable. In that case it repeats the iterable until it's longer than the index, then takes the slice (like take + cycle in Haskell). So z@<h gives the first 100 characters of the lowercase alphabet:

abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv

Length 5

2>1>0

Comparison operators chain, as in Python. This program returns 1 (true).

\$\endgroup\$
7
\$\begingroup\$

hansl

hansl is a programming language that is used in the statistical software project gretl since 2001. It resembles a mixture of R, Stata, and C. It operates with datasets, time series, vectors, matrices, and functions. Just as in R, there are dozens of user-written packages for econometrics and data analysis. It is a matrix-oriented interpreted language that is Turing-complete (!). Its fortes are econometric estimation and numerical maximisation, and it can be integrated with R, Ox, Octave, Stata, Python, Julia, and gnuplot.

Length 1 snippet

~

You know how difficult it can be to build matrices from vectors? One can attain the effect by reading the input row-wise, column-wise, or through assembling the mess into a dataset? In hansl, you do not hassle: just write ~ between the two vectors, and voila, you get them bound in tight leather together vertically: A~B. Do you have two matrices you want to assemble? X~Y, easy as pie.

Length 2 snippet

$h

This neat accessor returns the series of estimated conditional heteroskedasticity from the last GARCH model. Doesn’t it amaze you that esoteric programming languages have abbreviations for everything? Take that, MATL!

Length 3 snippet

ols

This is probably the most frequently used estimation method in all of econometrics. This command estimates a linear regression model describing the relationship between the dependent variable and predictors (like ols wage 0 age education married), returns the full model and generates many useful accessors (like $uhat for residuals, $aic for Akaike information criterion etc.)

Factoid: Its name comes from the famous fairy tale “Hansel and Gretel” by the Grimm brothers, with a modern twist (like Flick-r, Tumbl-r, and similar names, but gret-l omitted the penultimate vowel long before it became mainstream!).

\$\endgroup\$
7
\$\begingroup\$

Logicode

Factoid:

Logicode has a very limited amount of built-ins (7 built-ins, of which 6 are single-char), which makes it pretty difficult to program anything meaningful in.

Also, it's built on logic gates, as the name suggests, and that's it - which makes it doubly hard to code stuff in.

You can try it online here.

Length 1 Snippet:

+

The + is not addition, as that can be achieved easily. It's concatenation between two "numbers" (which are binary): So, something like 11+1 is not 100, as with regular binary addition, but 111.

Length 2 Snippet:

->

-> is used in two main things: circuits (which are Logicode's version of functions) and conditionals (if statements). It is used to separate the executed code from the arguments (in the case of circuits) or the condition (in the case of conditionals).

Length 3 Snippet:

out

This is a declarer, kinda like var in Javascript to declare a new variable. Logicode has a declarer for anything: out for output, var for variables, circ for circuits (which are basically functions in Logicode), cond for conditionals.

Length 4 Snippet:

!100

The ! is a logical NOT, which is operated on every digit of the binary string that follows. In this case, the snippet evaluates to 011.

Length 5 Snippet:

1&1&1

In Logicode, you're allowed to stack multiple two-arg (dyadic) operators together, as seen here. The & is a logical AND, and the snippet evaluates to 1.

Length 6 Snippet:

@11011

Yay, ASCII support! Because the default "type" of Logicode is binary strings, the @ converts binary to ASCII codes (mod 256). In this case, the character generated is ESC (ASCII character code 27).

Length 7 Snippet:

1000<<<

This program takes the tail of 1000 three times. A tail is essentially every character but the first, so repeating this three times gives us:

1000 -> 000 -> 00 -> 0

So this evaluates to 0.

\$\endgroup\$
7
\$\begingroup\$

Racket

Factoid : A programmable programming language: Racket is a full-spectrum programming language. It goes beyond Lisp and Scheme with dialects that support objects, types, laziness, and more. (https://racket-lang.org/)

(I am surprised no one has added Racket till now).

Functions or procedures need to be in parentheses. First term in parentheses is procedure name, rest are its arguments. If an argument is a procedure, it has to be in its own brackets. Values (non-procedures) are written without brackets.

Main syntax difference between Java and Racket is f(a, b) vs (f a b), x+y+z vs (+ x y z), x == y vs (eq? x y) and x=2 vs (define x 2), or if already defined, (set! x 2). There is no need to declare types like public static void or int char string etc.

Length 1

i

Prints value of i.

Also: + - / * are functions:

(+ 1 2 3 4)  

Output: 10 (all numbers are added together)

(* 1 2 3 4)

Output: 24 (product of all numbers)

(/ 20 5 2)

Output: 2 (20 is divided by 5 as well as 2)

(- 10 5 2)

Output: 3 (5 and 2 are subtracted from 10)

Length 2

pi

Prints value of pi:

3.141592653589793

Length 3

let 

For local binding as in:

(let ( (x 5)   (y 10) )
  (println  (* x y))
)
; x and y are not visible here; 

Also:

map

Subjects each item of a list to the sent function, e.g. to double every item of the list:

(map    (lambda(x) (* 2 x))    (list 1 2 3) )

Output:

'(2 4 6)

Also:

for 

Standard for loop as well as its extensions:

for* for/list for/sum for/product for/first for/last for/and for/or 

There are more extensions https://docs.racket-lang.org/reference/for.html !

Length 4

Conditionals:

cond 

For example (from https://docs.racket-lang.org/racket-cheat/index.html):

(cond 
  [(even? x) 0] 
  [(odd? x) 1] 
  [else "impossible!"]) 

Also

list

Being derived from Lisp & Scheme, list is very important data structure here:

(list 1 "a" #\a (list 1 2 3)) 

Length 5

match 

Match is like case-switch:

(match x
  [3 (displayln "x is 3")]
  [4 (displayln "x is 4")]
  [5 (displayln "x is 5")]
  [default (displayln "none of the above")])

Also:

apply 

This opens a list and provides all elements to the function, for example:

(apply + (list 1 2 3 4 5))

becomes:

(+ 1 2 3 4 5) ; => 15

Length 6

Define: a very basic function- to assign value to a variable:

(define s "A string")
(define n 10)

Also:
printf - the print function:

(printf "~a ; ~a ~n" s n)

Output:

A string ; 10 

Also: Filter - a function that filters a list for items which give true value to the specified function (sent as an argument):

> (filter string? (list "a" "b" 6))
'("a" "b")
> (filter positive? (list 1 -2 6 7 0))
'(1 6 7)

The test function can be specified:

> (filter 
    (lambda(x) (> x 2))    ; function to test each element
    '(1 2 3 4 5))          ; full input list to be filtered

Output:

'(3 4 5)                   ; output list of elements greater than 2

Length 7

println : one of most commonly used function. Prints out the sent string with a newline character at end:

(println "String to be printed")

(Note: examples are from various sources on the net).

\$\endgroup\$
7
\$\begingroup\$

MiniStringFuck

MSF- is a way to compress the unique characters of any 0-255 ASCII string to just two characters; and it does pretty well! Although code might just be long.

Length 1 snippet

.

Outputs 0x00.

Length 2 snippet

+.

Outputs 0x01. This does not only demonstrate the . (output), but also the + (accumulator). + essentially changes the accumulator's value (acc) to (acc + 1) % 256.

Length 3 snippet

,+.

It does not really output the next character; it's the same as above, because non-+. characters are ignored.

Length 4 snippet

+.+.

Yay multiple chars!! This outputs \1\2 (escaped chars).

Length 5 snippet

+.+..

This prints \1\2\2. Yes, we need too much upvotes yet to get to a reasonable program.

Length 6 snippet

+.+.+.

Prints \1\2\3. Finally something that looks a little bit more interesting than just some random sequence of unprintables.

\$\endgroup\$
  • \$\begingroup\$ A language with just two commands? Isn't this basically similar to the 0s and 1s of Binary? ;p Ah well, +1, looking forward to see what it got in store for us. \$\endgroup\$ – Kevin Cruijssen Sep 20 '16 at 14:42
  • \$\begingroup\$ To downvoters: Please do not downvote just because the language isn't awesome. It still has to be showcased. \$\endgroup\$ – Erik the Outgolfer Nov 13 '16 at 7:41
7
\$\begingroup\$

Stax

Stax is a stack-based golf-oriented language. That's a pretty crowded space, but stax has a few novel properties. There's an online interpreter.

Two stacks

There are two data stacks, "main" and "input". The language name is inspired by this. Normally standard input starts on the input stack, split into lines. Most operations operate on the main stack. However, if the main stack is empty, read operations fall back to the input stack instead.

Types

Falsy values are numeric zeroes and empty arrays. All other values are truthy.

  • Integer Aribitrary size
  • Float Standard double precision
  • Rational Fractions of integers
  • Block Reference to unexecuted code for map/filter/etc
  • Array Heterogeneous lists of any values

Compressed string literals

Stax has a variant of string literals suitable for compressing English-like text with no special characters. It is compressed using Huffman codes. It uses a different set of Huffman codes for every pair of preceding characters. The character weights were derived from a large corpus of English-like text. "Hello, World!" could be written as `jaH1"jS3!`. The language comes with a compression utility.

Crammed integer arrays

Similarly to compressed string literals, stax also has a special feature for efficiently representing arrays of arbitrary integers. It uses almost all the printable ascii characters. It uses the information in each character efficiently to embed how long each integer is, and their values. This feature is new in Stax 1.0.6.

Debugger

Stax has a web-based development and execution environment. It runs entirely client-side with no ajax calls. It features a step-through debugger that shows the current state, including all registers, stacks, and current instruction. |` is a programmatic break instruction. There is also a C# GUI and CLI for Stax.

PackedStax

PackedStax is an alternative representation for Stax code. It is never ambiguous with Stax, since PackedStax always has the leading bit of the first byte set. That means the same interpreter can be used for both representations with no extra information. For ease of clipboard use, PackedStax can be represented using a modified CP437 character encoding. It yields ~18% savings over ASCII.

Rationals

Stax supports fraction arithmetic. You can use u to turn an integer upside down. So 3u yields 1/3. Fractions are always in reduced terms. 3u 6* multiplies 1/3 by 6, but the result will be 2/1.

Implicit input eval

Normally the text in the input starts in the input stack. The stax runtime can parse input into stax data structures. This is rather convenient for many PPCG posts, where input formats are flexible. This happens only when certain conditions are met.

  • Input contains no newlines
  • Parsing input succeeded. Support types are integers, floats, rationals, strings, and arrays.

For example, this input would be parsed into corresponding values on the input stack.

1 2.3 [4/5, "foo"]

Examples

Snippet: Length 0

An empty program in stax will reduce a fraction. This is the result of automatically evaluated input, and a built-in rational type. Rational values are always in reduced terms. And since there's no explicit output in the program, the top of the stack is implicitly printed.

Run and debug it

Snippet: Length 1

A one character stax program can filter out the blank lines from standard input. f is generally used to use a block to filter an array, but when it's the first character of a program, it uses the remainder of the program to filter the input lines. The rest of the program is blank, so the filter is an identity filter, and blank lines are falsey.

f

Run and debug it

Snippet: Length 2

This program iterates over the positive integers from 1 to n and adds them.

F+

Run and debug it

Snippet: Length 3

This program gets the first n letters of the alphabet. Va is the lowercase alphabet. ( truncates to the specified input length.

Va(

Run and debug it

Snippet: Length 4

In 4 bytes, you can use a block to map each character to its ascii code in hexadecimal. There aren't strings per se in stax, but arrays of character codepoints are treated as strings in many contexts. {...m establishes a block and maps every element in an array using the contents. |H converts a number to hexadecimal.

{|Hm

Run and debug it

There is also a length-4 proper quine in Stax, which is quite different from how most proper quines are constructed.

..SS

Run and debug it

. is the leading character for a two-character literal and ..S is the string literal ".S". S builds the powerset of the array, excluding the empty set, i.e. [".",".S","S"]. The result is then implicitly flattened and output.

\$\endgroup\$
6
\$\begingroup\$

Reng

5-vote

1¶:+!

This uses an intersting feature: default stack pop override! pops n and sets n to the default value when popping from an empty stack. (This is 0 by default.) What this code does is initially lay down a 1, sets that as a default pop, : duplicates value (getting default pop) and adds it with the default pop, leaving twice the default pop on the stack. ! skips the 1 instruction, and sets the default pop to twice what it was.

4-vote

is~o

This is a cat program. It takes input (i), s jumps if the byte != -1, and o outputs. When reading EOF for input, -1 is put on the stack, and the program terminates.

3-vote

9#q

This stores the number 9 in the variable q.

2-vote

{}

Reng has codeblocks! This pushes an empty codeblock to the stack. Forever.

1-vote

~

This ends the program.

0-vote

Reng is like ><>, but with some more functionality. Not made for golfing, as you may come to see... ;)

\$\endgroup\$
6
\$\begingroup\$

Desmos

Factoid: The Desmos community has a wealth of programs that use many math equations to make them work. Take, for example, this 3D visualizer.

1 byte

x

One of my favorite things about Desmos is that you can write out equations like this without having to put y= before it, as Desmos automatically does it for you.

\$\endgroup\$
6
\$\begingroup\$

Sonic Pi

Code Snippet 4:

dice

You don't see anything on the output, but if you show it with puts, it's a random number. Don't worry if your number is always the same, Sonic Pi uses the same random seed for every run, but that's good because else your songs would sound different every time.

Code Snippet 3:

:e1

This equals the MIDI-Note 52 and the frequency 164.81377845643496 hz. It must start with a : so Sonic Pi knows it's an integrated constant.

Code Snippet 2:

[]

Empty list. Sorry, nothing else except comments can be written in two bytes.

Code Snippet 1:

#

Starts a comment.

Factoid: Sonic Pi is a sound coding language and is a full valued programming language.

\$\endgroup\$
6
\$\begingroup\$

StackyLogic

Factoid:

StackyLogic is originially from a codegolf challenge, as seen in the link. It consists of a series of "stacks", however there are no "push" operations.

Length 1 Snippet

<

This is not a full program at all. This is just the pointer symbol. This symbol denotes where the pointer starts

Length 2 Snippet

?<

This program takes a bit of input, and outputs it. It would be a cat program, if it looped, however Stackylogic possesses no loops.

First, the program will substitute the ? for either a 1 or 0, depending on input. Then, it will execute this command. 1 will make the pointer move down one, 0 will make it move up one. Then, upon discovering the empty stack (which are always implicitly exist), it will halt, and output the last executed command, either a 1, or 0

Length 3 Snippet

?1<

This program always outputs one, the ? is never used. This is because, as stated in the previous snippet, 1 will move the pointer down one, and the implicit empty stack will cause the last executed command to be printed. the ? isn't used, because the pointer is never directed to it.

Length 4 Snippet

?
?<

Our first program with multiple non-empty stacks.

This program outputs the result of an OR operation on two bits.

How it works:

It first substitutes the ? under the pointer with a bit from input, and executes it. If it is a 1, it will go forward, find the empty stack, halt and print 1.

?<

If it is a zero, it will go up one, and act like the above code: it will substitute the ? for a bit, execute it, and then move onto an empty stack and output it.

Note how the code after the first ? is executed is the same as snippet 2

Length 5 snippet

1
??<

This program, like the last program, outputs the OR of two bits. However, the ?s are on the same line. if the first bit is one, it will move forward on to an empty stack, output 1, if it is a 0, it will move back one, on to the one, and then move forward back on to the second ?, again being identical to the length 2 snippet. This illustrates how multiple programs can have the same effect. You might have noticed that no new language features have been introduced this time. This is because they have all been introduced.

Length 6 Snippet

1
?<
0

This program outputs the not of one bit (the opposite of snippet 2). You might, by now, think that StackyLogic is really boring, and can't do anything interesting. This isn't (entirely) true. It can be used for more interesting things, it just takes A LOT of characters. However, even after these lots of characters, it is not capable of much computation, it cannot even store the input, most challenges are closed out to it (in fact, the linked example actually checks which year it is, if it divisible by 4, to see if it is a special case (not a leap year))

Length 7 Snippet

?<
?1
?

This program "nests" an OR in a surrounding program. I say it nests it, because if the first bit is 1, it changes to be the exact same as the OR, and executes the same things. This program is (x AND (y OR z))


I don't really know anymore decent snippets, there isn't much more to show. I plan on making another answer with my derivative, Eseljik, after I actually make the interpreter, but before that decide on the final part of the spec. Anyway, there are a lot more commands in Eseljik, so I shouldn't easily run out of things to show, like I have here.

\$\endgroup\$
  • \$\begingroup\$ Does StackyLogic fulfill our definition of programming language? \$\endgroup\$ – Luis Mendo Jul 26 '16 at 15:03
  • \$\begingroup\$ No. If this is an issue, maybe you'd prefer HQ9AddPrimality+? Seriously though, perhaps we should not judge on these arbitrary requirements, that try to regulate boring languages, but using common sense to determine what should and shouldn't be allowed. Though this lacks many abilities of normal languages, it is not abusive, like the language HQ9+, and is kind of fun to answer questions with. \$\endgroup\$ – Destructible Lemon Jul 27 '16 at 1:11
6
\$\begingroup\$

ListSharp

factoid: ListSharp is an interpeted langauge for list manipulation and web scraping, still in development yet it can already do some neat stuff!

  • syntax is heavily word based so a good amount of votes will be needed for functional snipplets

Length 4 snipplet:

SHOW

SHOW is the standard STDOUT of ListSharp and lets you display a variable in complete disregard to its type

Ex:

SHOW = "Hello world"
SHOW = {"1","2"} + "3"
SHOW = variable_name
\$\endgroup\$
6
\$\begingroup\$

Golisp

Factoid

Golisp is a very simple programming language, but despite it's name it's not a Lisp dialect.

Length 1 snippet

0

Return 0, but since this value isn't used this is a no-op.

Length 2 snippet

""

Return a empty string, but since this value isn't used this is a no-op.

Length 3 snippet

(0)

Create a list with 1 element, 0

Length 4 snippet

+[1]

Call the function + with one argument, 1. The returned value is 1.

Length 5 snippet

chr@5

Use the shorthand notation function@argument. Return the ASCII character ENQ (5), but as always, nothing is printed :/

Length 6 snippet

+[3 5]

Simply add 3 and 5.

\$\endgroup\$
6
\$\begingroup\$

Woefully

Now with TIO!

Factoid:

Woefully is a 2d language with no traditional conditionals (ooh, that rhyme). The closest thing it has to conditionals is the boolean/not_zero command, which pushes int(stack_A.pop()!=0). It's also pretty weird in other ways.

It isn't really possible to even write a program in less than 7 characters, unless you count printing the "error" message as a program, or immediately halting as a program, so perhaps I'll multiply the votes by 4 to get the amount of bytes I can have, if that's allowable (context: it takes 266 bytes to write a truth machine, unless it could be golfed more,)

1*4 bytes

boom

this program technically doesn't error, but just prints "confuse :(", the "error" message of the language, which counts as regular output as it goes to STDOUT, not STDERR. This program doesn't conform to the program composition requirements (needs to have no characters that aren't pipes, spaces and newlines, needs to have at least one space, needs to have no spaces at the start and end of lines), and so automatically prints the message "confuse :("

BTW it is going to be a while before anything really interesting, like even a program that just takes input, or pushes a number, so you might want to look at my truth machine to see what Woefully looks like

2*4 bytes

| |
|| |

Ooh, we have the first program that doesn't just print "confuse :(" and die. This program does... nothing. It is in an infinite loop of nops

Why it nops forever

diagram!

v
|\|
||\|
  X

The char pointer, the first of two pointers, starts at the character pointed to by v. The instruction pointer will find the first space after this char, and execute the path of spaces it is a part of. The \ shows the path. the instruction pointer goes down this path, but does nothing, since lines that are two-long are nops. Once it finishes the path, (symbolised by the X), the instruction pointer returns to the char pointer, which has not moved, and executes it again, forever.

3*4 bytes

| |
| |
| ||

This program terminates in an error (not confuse, but an actual error), but why?

three down executes the A to B command, popping the top of the A stack, and pushing it to the B stack. (there are two stacks). However, the program does not immediately fail, because the stacks start with values already on them: one zero each, it runs once normally, then fails the next iteration of the loop.

4*4 bytes

||| |
|| ||
| ||

This program pushes zero to stack A infinitely. this is because all diagonally down left commands push the length of the command, minus three. minus three because a command that is two long is a nop, so the shortest push command is three long, and the smallest push-able value is zero.

5*4 bytes

| || |
||| ||
|| |||

I didn't really have anything interesting (apart from some more erroring commands) to show this time, but I realised none of the snippets halt, though some error, so this snippet just halts, without doing anything (including the push at the right)

diagram!

v       char pointer starts pointing here
|X||a|   X has the first space after that character, so it's path is executed
|||a|| X halts the program
||a|||   a - never executed
\$\endgroup\$
6
\$\begingroup\$

Majc (formely hashmap)

Factoid
hashmap is not necessarily a golfing language, although it's commands can make it so. (Also it's spelled hashmap, not Hashmap).
It was renamed in June 11, 2016 to Majc.

0 byte snippet:

 

This does nothing.

1 byte snippet:

.

Clear the stack... now.. there's nothing in the stack.. so...

2 byte snippet:

id

Convert input to a number, this is also the long version of h.

3 byte snippet:

h2^

h is short for id, so we're taking the input as a number and get it's squared.

4 byte snippet:

{}:a

5 byte snippet:

isrsr

Kind of lost ideas here, but i takes an input, sr reverses it.

I'm not sure if this still works but this created a code block (based on CJam) and assigns it to variable a. Code blocks are like anonymous functions (unless assigned to a variable).

\$\endgroup\$
  • \$\begingroup\$ 2 byte snippet? \$\endgroup\$ – Conor O'Brien Jul 26 '16 at 0:32
6
\$\begingroup\$

SX

Length 1 Code

Compiles to: pass

Length 3 Code

10才

returns 11. 才 is equivelant to C's ++.

Length 4 Code

品*30

returns the circumference of a circle with a diameter. Assuming math was importing.

Length 5 Code

送我(@)

compiles to def __init__(self):print(self) and will work if put inside a class.

Factoid: sorry pass isn't really that interesting. Sorta interesting, SX is one of the first golfing langauges (I made it when I was in 7th or 8th grade. It also compiles to python.

\$\endgroup\$
6
\$\begingroup\$

Processing

Factoid:

Processing is kind of like the nicer brother/cousin of Java with its syntactic sugar, which introduces a lot of golfing opportunities, as well as GUI stuff which is built-in (because Processing is made for designers to get into programming). See the snippets for its golfing power (especially for graphics stuff).

18 bytes:

size(400,400,P3D);

This snippet not only sets the dimensions of the window to 400x400, but also enables 3D rendering (in just 18 bytes!).

7 bytes:

println

Yup, it's just println, not System.out.println. It's as simple as that.

3 bytes:

str

There's a builtin for converting to Strings from other types (e.g. int, float, long, etc.) in Processing!

\$\endgroup\$
  • \$\begingroup\$ You aren't restricted by votes anymore, you know. \$\endgroup\$ – Pavel Jan 2 '17 at 4:58
6
\$\begingroup\$

Pyramid Scheme

With all the scheme dialects out there, I suppose it was inevitable that a Pyramid Scheme should arise. Created in early 2017 by our very own Conor O'Brien, this 2D esolang does in fact read very much like Scheme!

Length 1

^

This little guy is the start of everything. The tip of a pyramid. Without the caret, there can be no Pyramid Scheme. On its own, though, it's not a valid program; you've gotta rest the pyramidion on something...

Length 3

^
-

There it is. A full pyramid, complete with base and capstone. This 3-byter is the shortest program that will not error; it prints 0 followed by a newline and terminates gracefully. What it's really doing is accessing the default value of the variable-without-a-name; more on variables later, once we have larger pyramids.

Length 4

​
^
-

Exactly as before, but now with a leading blank line! This program does nothing; it is the shortest possible program of the sort. Execution in Pyramid Scheme always begins on the first line. Each pyramidion on that first line is evaluated, and then the results are printed with linefeeds between if nothing has yet been printed. As the first line here is blank, nothing gets evaluated or printed.

Length 5

^^
--

On the other end, here's a program with more than one pyramid at the top. The one on the left will be evaluated first (yielding 0, as in the length-3), followed by that on the right. The results are collected in a list during execution; once all evaluation is complete, since nothing has yet been printed, the results are dumped to stdout:

0
0
​
\$\endgroup\$
5
\$\begingroup\$

PyCal

Factoid:

PyCal is a math-based programming language written in Python, hence the name. It's designed to compete in code-golf challenges that need math.

Length 1 snippet

!

OK, let me explain a little about PyCal. PyCal has two "variables". One variable's value can be set by the user. The other variable's value comes from the values that some commands return. For example, the F returns the nth Fibonacci number.

Anyways, the ! command outputs the value that is in the user-set variable. By default, it's 0, so the above snippet outputs 0.

Length 2 snippet

IP

This snippet outputs the first n prime numbers as a list.

Let me explain what this does:

I gets input, and converts it to an integer before storing it in the variable. (From now on, I'll call the variable that the user can change "variable". The other one will be called the result. Read snippet 1 for more info)

P takes the variable's value and prints n prime numbers. For example, if the value is 5, it will output the first 5 primes.

So, here's what it will look like if the input is 10:

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

Length 3 snippet

(7)

Ah, it's good to be back, I took a long break.

Anyways, let's get on with the explanation. Well, this is actually really simple. It changes the value of the variable to 7. Of course, this doesn't output anything. You can add a ! to the end to output the number.

Length 4 snippet

(wip)

Length 5 snippet

(i)S!

This snippet gets the square root of the input. (i) sets the value of the variable to the input and converts it into an integer. S calculates the square root.

\$\endgroup\$
  • \$\begingroup\$ I didn't think it would be Python + Math, I thought it would end up being Python + Pascal... \$\endgroup\$ – XiKuuKy Sep 20 '16 at 12:37
  • \$\begingroup\$ @XiKuuKy It's Python + Calculator. PyMath and Pyth (:P) are both taken \$\endgroup\$ – m654 Sep 25 '16 at 9:24
5
\$\begingroup\$

Straw

Straw is a 1D stack-based language I created.
It mainly operate on strings.
You can try it online here.

Length 1

<

Take one line of input and exit.

Length 2

->

- take an item from the secondary stack, and > print it.
Straw have 2 stacks: The first is initialized with an empty string, and the second with Hello, World!.
So this code prints Hello, World!.

Length 3

9#>

Any character which is not a command is pushed on the stack, and # convert a decimal number to unary. It's needed to make any operations on numbers, because Straw don't have numbers, it only operate on strings. So this example prints 000000000.

Length 4

<<+>

Take two lines of input, concatenate (+) and print.

\$\endgroup\$
5
\$\begingroup\$

Arithmescript

Making an entry for Arithmescript here.

Codes

Length 1 snippet

i

Prints the value of i in the console.

Factoids

  • I am the creator of Arithmescript.
  • Arithmescript extends JavaScript.
  • It is sort of discontinued.

Demos

You can try out code in the latest version of Arithmescript at the official site.

\$\endgroup\$
  • 3
    \$\begingroup\$ Will you add snippets 2-4? \$\endgroup\$ – acrolith Sep 26 '16 at 0:05
5
\$\begingroup\$

Dotsplit

(whoops I forgot the link before :p)

(pair of) Factoid(s):

Dotsplit is a mostly syntax free language, with odd builtins (kind of like mathematica), but is currently in it's infancy. Dotsplit is named after the tokeniser used in the interpreter: str.split(). This is a weak tokeniser, but it fulfills all needs of the language, so far anyway.

1 byte:

D

D does

...

nothing. it isn't a tiny builtin, unless you count a nop as a builtin, and it's only a nop because it isn't a defined command. Dotsplit has relatively long command names for most things. Note that the shortest happens to be three long. anything that isn't a defined command is ignored. also note commands are case insensitive, so if it were a command, d would be the same as D

2 bytes:

still not much interesting

 b

b with a leading space. This program functions identically to b, as well as D, because nops, but if b was a command, b and D would not be the same, but b and [space]b would. Spaces are used to separate commands, but otherwise are ignored. Next upvote, and we get an actual command!

3 bytes

First command!

aDd

This will pop a and b, and push a+b. Popping from an empty stack yields 0. hence, this program will leave one 0 on the stack. add is case insensitive, and will function regardless of case (AdD will also work)

4 bytes

There are a fair amount more commands with 4 bytes, not many still. I chose this one

derp

This program will wait for input by the user. If input is "derp" (case-sensitive), it prints "Derp". Otherwise, "Nope"

\$\endgroup\$
  • \$\begingroup\$ That derp though... \$\endgroup\$ – Qwerp-Derp Oct 30 '16 at 8:10
5
\$\begingroup\$

D2

Factoid

D2 is a Brainfuck-like turing tarpit with a 2D memory model

Length 1

.

This prints 0. Why?

. is, like in Brainfuck, the print command. But since cells are limited to 36 values, D2 use a shift-state system to print most ASCII characters. In shift state 0, the alphabet is 0123456789abcdefghijklmnopqrstuvwxyz, and since the cell is initialized to 0, this print 0.

Length 2

;.

Now this print !.

The ; instruction increment the shift state. In shift state 1, the alphabet is !@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ, so this print ! because the current cell is 0.

Length 3

>}+

Explanation:

>   Turn the cursor 90° to the right
 }  Advance in the tape
  + Increment the pointed cell

So the memory after this is:

0
1

This demonstrate D2's 2D tape

Length 4

+$}^

This set the first cell of the tape to 1, put the value in the register, advance one cell and put the value of the register in the cell.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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