alm

Shooting yourself in the foot in various programming environments

This is inspired by, but not directly ripped off from, the original classic computer science joke of shooting yourself in the foot in various programming languages.

Feel free to send me comments, suggestions, or criticism (see / for contact methods).

C

You load the gun and take aim at your foot, but when you pull the trigger, you discover that one of the grains of gunpowder is a NULL pointer.

Segmentation fault (core dumped)

C++

You shoot yourself in the foot, but forget to delete the bullet and leak memory.

Rust

The compiler won’t let you take the safety off.

Assembly

You build your own gun and make your own bullets. When you pull the trigger, the gun fires forwards and backwards, jams, and falls apart.

Segmentation fault (core dumped)

Machine code

You hand-forge all the parts for a gun and bullet casings, mix your own gunpowder, and assemble it. When you pull the trigger, the world freezes.

Go

The standard library provides a gun and bullets, but your foot needs to implement interface Shootable.

Java

You use a BulletFactory to produce ammunition for one of several Guns, wrap the whole thing in a ShootingManager, and fire at your foot, but the JVM hasn’t warmed up yet. Two minutes later, your foot throws a PainException.

.NET

You have a System.Armaments.Firearms.Gun, but can’t find any bullets anywhere. The documentation says they’re in the Firearms namespace with the gun, but doesn’t describe them.

Python

You shoot yourself in the foot with ease, but it takes long enough for you to get lunch and still come back in time to put your foot in front of the bullet.

BASIC

You dampen your foot and wait for it to rot.

JavaScript

There are eight frameworks for foot-shooting. Of these, three are unmaintained, two are brand-new and full of bugs, one lacks bullets, and the other two require jQuery.

Erlang

You take aim and pull the trigger, but the gun crashes because the bullets are of the wrong brand. Upon replacing the bullets and gun and trying again, a new foot, now with hole, appears from the gun. You do not know how to replace your existing foot with the shot one.

CSS

You fire and miss because your foot is where your knee should be.

HTML

You write a 15-page document describing how to shoot yourself in the foot.

TeX

You write a beautiful 5-page document describing how to shoot yourself in the foot. As a bonus, it does it for you when you compile it.

SQL

You miss, but you can roll it back and try again as many times as you like.

PHP

You use SQL to shoot yourself in the foot and send back an HTML file describing the results. Someone does some SQL injection and drops your bullets.

Windows

You load a Unicode gun with ANSI bullets and when you pull the trigger your foot is transformed into Asian gibberish.

Unix

You don’t have permission to access the foot or the gun.

Internet

You ask to be shot in the foot and are presented with 6.4 million choices for guns and bullets. By the time you finally make your decision, the request has timed out.