Cum Grano Salis

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.

image

The following code shows the Bubble-sort algorithm:

image

(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.

Published Tuesday, August 21, 2007 6:32 PM by Shahar
Attachment(s): CumGranoSalisCodeArt.zip

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

MSDN Blog Postings » Code Art - like ASCII art, only sucks so much more to create.... said:

August 22, 2007 1:52 AM
 

jrock said:

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.

August 22, 2007 6:56 PM
 

votive, wix, vsip, and all things microsoft said:

August 22, 2007 7:01 PM
 

Noticias externas said:

Check out this blog post from Shahar, one of the devs I work with. http://blogs.msdn.com/cumgranosalis

August 22, 2007 7:12 PM
 

Mr. Pig said:

August 22, 2007 8:22 PM
 

Shahar said:

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

August 22, 2007 8:49 PM
 

tammy.dyer said:

mary cassatt is  a loving artist

July 24, 2008 1:12 AM

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Submit

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker