2022 Developer Survey is open! Take survey.
540 votes
Accepted

Code that will only execute once

Vigil Finally a usecase for Vigil! def main(): raise Exception() Excerpt from the "language specification": It goes without saying that any function ...
user avatar
336 votes
Accepted

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 ...
user avatar
  • 28.4k
309 votes

Code that will only execute once

Pretty much any Linux distro, 9 chars This one is a classic! #!/bin/rm Put this in a file and run it: ...
user avatar
  • 7,801
294 votes

Write a program that makes 2 + 2 = 5

Haskell I just love how you can throw anything at ghci and it totally rolls with it. λ> let 2+2=5 in 2+2 5
user avatar
  • 7,801
294 votes

Write a program that makes 2 + 2 = 5

C Pretty cheap trick but I'm sure I will trap the most of you. ...
user avatar
  • 12.2k
290 votes
Accepted

Make it look like I'm working

JavaScript So I went a little crazy with this. I did it between breaks from working on my GUI to track IP's using Visual Basic. You can access it by going to the super serious domain I made for it ...
user avatar
  • 2,614
278 votes
Accepted

What? No error?

C++ Make sure you compile the following code in standard conforming mode (for example, for g++ use the -ansi flag): ...
user avatar
  • 4,670
258 votes
Accepted

Loop without 'looping'

Ruby def method_missing(meth,*args) puts 'Banana' send(meth.next) end def also puts "Orange you glad I didn't say banana?" end ahem Demo Clears its ...
user avatar
  • 21.8k
256 votes

Code that will only execute once

x86 binary, 4 bytes F0 0F C7 C8 Assumption: Must be run on a P5 Pentium CPU. The above instruction is commonly known as the F00F bug. It attempts to execute an ...
user avatar
  • 206k
234 votes
Accepted

So obviously, P = NP

C# Your task is to write a program for SAT that appears to execute in polynomial time. "Appears" is unnecessary. I can write a program that really does execute in polynomial time to solve SAT ...
user avatar
  • 2,815
232 votes
Accepted

4, 8, 15, 16, 23, 42

Java I decided to add another entry since this is completely different from my first one (which was more like an example). This program calculates the average of an array entered by the user... <...
user avatar
  • 2,416
208 votes

Tweetable Mathematical Art

Table cloths Flat I started out putting a plaid/gingham pattern into perspective like a boundless table cloth: ...
user avatar
  • 10.7k
190 votes

Tweetable Mathematical Art

Random painter ...
user avatar
184 votes

Why isn't it ending?

Javascript var x=prompt('Enter a value under 100'); while (x != 100) { x=x+1; } console.log('End!');
user avatar
  • 12.2k
184 votes

Write a program that makes 2 + 2 = 5

GolfScript 4:echo(2+2); Prints 5.
user avatar
  • 4,405
183 votes

4, 8, 15, 16, 23, 42

Python ...
user avatar
  • 3,121
182 votes

Make your language unusable

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 ...
user avatar
181 votes
Accepted

Programming Languages Through The Years

2013 - Dogescript Dogescript is a language created in 2013 by Zach Bruggeman. It is nothing more than a syntax-replacement for Javascript to make it read like the internal monologues of memetic Shiba ...
user avatar
  • 7,654
177 votes

Sort a list and write some English!

GolfScript Dear Boss Man. It came to my attention that my keyboard needs replacement; the keys required to write the symbols ~ $ ` . and } are not functioning properly. It's very difficult to work ...
user avatar
  • 206k
171 votes
Accepted

Random script that isn't actually random

C It's important to decide who is buying as quickly as possible, so as not to waste precious drinking time - hence C is the obvious choice in order to get maximum performance: ...
user avatar
  • 2,901
166 votes

So obviously, P = NP

Multi-language (1 byte) The following program, valid in many languages, mostly functional and esoteric, will give the correct answer for a large number of SAT problems and has constant complexity (!!!...
user avatar
  • 1,654
164 votes

Random script that isn't actually random

PHP Couldn't let this go, so here is another one: ...
user avatar
  • 2,551
162 votes
Accepted

American Gothic in the palette of Mona Lisa: Rearrange the pixels

Java - GUI with progressive randomized transformation I tried a LOT of things, some of them very complicated, then I finally came back to this relatively-simple code: ...
user avatar
162 votes

Tweetable Mathematical Art

Some swirly pointy things Yes, I knew exactly what to name it. ...
user avatar
  • 4,273
151 votes

Code that will only execute once

gzip #!/bin/gzip To much annoyance to people used to nondestructive commandline tools, gzip by default ruins the original ...
user avatar
  • 3,181
144 votes

Make an error quine!

Windows Command Prompt & was unexpected at this time.
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible