Code Art – like ASCII art, only sucks so much more to create….

I have made two examples of Code Art - taking a piece of code that does something and placing the text in such a manner that it conveys the idea of the program. The reason it sucks so much more than ASCII art is two-fold:

a. It is very hard to do significant touch-ups to the "art" - since the order of the characters is important (it's a program!)

b. You only have so many characters to play with. You need to gauge the needed size of the "art"

There are a few rules:

1. You cannot use comments as part of the "graphics" - every single character needs to be something that actually compiles.

2. You cannot create "nop" functions for filler. You can, in some cases, make things longer than they need to be. For example, if you have a "+2" somewhere, you can type "+ 1 + 1" if you need longer text. However, you should use that as a last resort.

3. You should not have "dead" code. Every piece of code that's in the art needs to be reachable (and should actually be reached where it makes sense).

Here are the screen-shots of the examples. The first is a program that calculates Pi to the 1000th character. If you cut and paste the code as is into Visual Studio, into a C# project, it will compile and show PI on a console window.


The following code shows the Bubble-sort algorithm:


(If you don't get it, these are 3 soap bubbles at the top and the plastic thing you use to create them at the bottom).

A download of both source files are attached to this post.

Comments (8)

  1. MSDN Archive says:

    You have waaaay too much time on your hands. 🙂 Now you just need to write a program that will generate these for you. And then write an Excel Server UDF to do this with text in cells.

  2. Check out this blog post from Shahar, one of the devs I work with.

  3. Shahar Prish says:

    That’s cute, but the #defines make it much easier to create something nice. It’s much more challenging to only use the code. 🙂

  4. tammy.dyer says:

    mary cassatt is  a loving artist

  5. Erica says:

    Challenge accepted, haha!

    Although heavy Perl regex would maximize use of the more bizarre characters, like this incredible masterpiece:

Skip to main content