Thursday, 10 September 2009

#songsincode - Lyrics for Programmers

#songsincode#songsincode are small pseudo-programs which display a song title or part of the lyrics. The more refined examples use conditional code and control stuctures to define the song.

The tag was first used on twitter a couple of weeks ago. After a sudden burst of popularity, #songsincode has slowed to about 20 tweets a day. Here's an example by testydonkey:

if(Door.Color == System.Color.Red)
{ Door.Color = System.Color.Black; }

This is Paint it Black by the Rolling Stones, “I see a red door and I want it painted black”.

Here's the top 25 countdown of the very finest #songsincode. Can you identify all 25? Is your favourite missing? Let me know :-)

anurse:
var s = new Submarine(Color.Yellow);
s.Residents.Add(Us); for(int i=0;i<2;i++)
{Assert.IsTrue(s.Color == Color.Yellow);}

darrennisbett:
h=new hotel(); h.name="california";
h.guest.addEvent("checkout");
h.guest.removeEvent("leave")

royvanrijn:
if(grass=="green" && girls == "pretty")
{ takeMe(paradiseCity); }

injenierobarsa:
for (int i = 1; i <= 99; i++)
{ redBalloons[i].goBy() }

3d0:
if(my.sexyness>shirt.sexyness) pain();

phikachu:
me.color = 0x0000FF;
me.text = “Da Ba Dee Da Ba Di”;

Borisson:
($horse_name == false ? $location = desert : ' ');

plaxdan:
self.vehicle = new CombineHarvester();
you.setKey(vehicle.getKey());

cargoweasel:
SubwayWalls.write(words_of_the_prophets());

Leadhyena:
I.send("...---...",world);
I.send("...---...",world);
while(!(someone.receive(bottle)&&
bottle.contains(message)){I.hope()}

antallan:
substring("the tiger",6,1)

pitsk:
void shootPeople() { shootSherif; return;
shootDeputy; }

sbruchmann:
if ($angelsDeserveToDie) { iCry(); }

royvanrijn:
while( !me.like(mondays) ) { tellWhy(me); }

Levistica:
cuts.firstElement().deepness = max;

uberTof:
final--;

plaxdan:
while (thing != that) { doForLove(thing);

numptygeek:
jumpWithDirection(left); stepWithDirection(right);

CarstenHagemann:
$jealous_sky[$sun] = $you->tell()
if ($we->walk($fields_of_gold));

numptygeek:
if(somethingStrange==true && location ==
neighborhood){ ghostbusters();
printf("I ain't afraid of no ghost");}

draconum:
//roxanne.putOnLight('#ff0000');
commented out, was not necessary

brozow:
video$ kill -9 `ps -ef | grep radio*`

rennyhernandez:
stuff={'red door','a line of cars', 'my heart'}
stuff.each do |it| it.setColor('#000000') end

codepo8:
.clowns{float:left;}.jokers{float:right};
#me_you{position:fixed;margin:0 auto;width:100%}

royvanrijn:
for(Leaf leaf:leafs)
{ leaf.setColor(new Color(139,69,19)); }
sky.setColor(Color.GRAY);

#moviesincode, #tvincode, #booksincode!


#songsincode has inspired three new tags. Can you see #moviesincode, #tvincode or #booksincode catching on? :-)

sijmen:
TypeError: Result of expression this.spoon'
[undefined] is not an object

rhizomecowboy:
trace(isNAN(prisoner));

nail7:
var i = count(MonteChristo);

#songsincode, lyrics for programmers

40 comments:

  1. [...]
    if ($They->say("Why, why?"))
    {
    $You->tellEm("It's just human nature...");
    }
    [...]

    ReplyDelete
  2. int problems = 0;
    int bitch = 0;

    for(int i = 1; i<=99; i++) {
    problems = i;
    }

    assert (bitch != 1)

    ReplyDelete
  3. what about this one, it runs in the python console!

    RT @jackboot7: ", ".join(["In you I %s" % n for n in ["feel so dirty", "crash cars", "feel so pretty", "taste god"]]) #songsincode #python

    is one of my favorites

    ReplyDelete
  4. assert (suzanne.floor == luka.floor - 1);

    ReplyDelete
  5. Great post I love what people do in 140 chars. It inspired me to come up with:

    if(u==STRANGER)people=STRANGE;
    if(u==ALONE)faces.look=UGLY;
    if(u==UNWANTED)women.seem=WICKED;
    if(u==DOWN)streets.even=false;

    ReplyDelete
  6. An HH classic:

    while (true) {
    currentMoney = getMoney();
    if (money > prevMoney) ++problems;
    prevMoney = currentMoney;
    }

    ReplyDelete
  7. $we = new Peoples(Peoples::CHAMPIONS);

    while (1) {

    $we->fight();

    }

    ReplyDelete
  8. int it_matters(person you)
    {
    if (you.thinking(mybabe))
    {

    return !(you.match_skin_color("#00000") ^ you.match_skin_color("#FFFFFF"));

    }

    return 1;
    }

    ReplyDelete
  9. class BillieJean : public girl
    {
    public:
    BillieJean(relationship &jacko) : lover(!jacko), i(1) {}
    int i;
    relationship lover;
    };

    ReplyDelete
  10. Hey John,
    Great list. I found your site through a comment you made on my blog. With a similar post by the way.
    http://www.integralwebsolutions.co.za/Blog/EntryId/362/Songs-in-Code.aspx

    Here is a few of my own.

    If (an illusion = true); believe = false;

    If (needSomeone = true) Help();

    for Lady = 1 to 3 {ILoveYou = true;}

    ReplyDelete
  11. sm = { :location => 'sky', :status => 'waiting' }

    ReplyDelete
  12. This one is cool, any idea who it's by?

    if ($kid->deaf && $kid->dumb && $kid->blind) {$kid->pinballskill = 'mean';}

    ReplyDelete
  13. How about #poemsincode?

    while ( brillig() && toves == slithy )
    { toves.location = 'wabe';
    toves.gyre(); toves.gimble();
    borogoves = mimsy; mome_raths.outgrabe(); }

    ReplyDelete
  14. do { my.way() }

    ReplyDelete
  15. #artincode or #quotesincode maybe?

    ReplyDelete
  16. while (doctor == 'house') {patient.diagnosis != 'lupus'} #tvincode

    ReplyDelete
  17. I liked this one:
    stack.push('water');
    stack.push('smoke');

    ReplyDelete
  18. hey(hey(hey(hey("ooooh"))));

    if (you.WillComeSeeAbout(me)) {
      me.alone = true;
      me.dancing = true;
      you.Know(it, "baby");
    }

    try {
      you.Tell(me, you.troubles);
      you.Tell(me, you.doubts);

      you.Give(me, __EVERYTHING__);
    }
    catch (DidNotGetInsideException dnie) {
      LogException(dnie, "inside");
    }
    catch (DidNotGetOutsideException dnoe) {
       LogException(dnie, "out");
    }

    love = (Strange)((Real)so).inTheDark);

    you.Think(Cache["OurWork"] as
      Thing<Tender>[]);

    if (((Slow) change).pullsApart(you, me))
      you.heart.Add(new Light(), "baby");

    function Chorus() {
      you.forget[me] = false
        = false = false = false = false;
      you.forget[me] = false;
    }

    if !(you.StandAbove(me) && you.Look(me.way) && !you.Love(me));
      while (rain.count > 0)
         rain.KeepFalling(Direction.Down, Direction.Down, Direction.Down);

    if ((you.Recognize(me) && (!you.CallByName(me) || you.WalkOnBy(me))
      while (rain.count > 0)
        rain.KeepFalling(Direction.Down, Direction.Down, Direction.Down);

    hey(hey(hey(hey("ooooh"))));

    // ...

    ReplyDelete
  19. var startMeUp = true;
    do(
    startMeUp = true;

    )while(startMeUp==false);
    // never stops

    ReplyDelete
  20. for(j=0; j <= 500; i++)
    {
    if you.walked == j then
    {
    i.walk = j+500;
    }
    }

    or

    if i == 0 then
    {
    ;
    }
    else
    {
    matters();
    }

    or

    if( location = angryChair()) then
    {
    sitting = inMy()
    }

    ReplyDelete
  21. Are you taking part in #songsincode day, Friday 20 November? Lets get #songsincode trending again :)

    ReplyDelete
  22. var items = [ seasons, wind, sun, rain ];
    for ( x in items ) { x.fear( the_reaper, false ) };
    baby += my_hand;
    baby.fear( the_reaper, false );

    ReplyDelete
  23. assert(i instanceof Looser);
    if(why!=null) i = null;
    i.tell(why);


    SELECT * FROM haircut LEFT JOIN devil ON mind


    regularcrowd.filter(x => x==this).forall(x => { regularcrowd.forall(y => x.jar.put(y.bread)); x.singSongOf(x)})

    ReplyDelete
  24. public class MohammedAli {
    float like_a_butterfly;
    string like_a_bee;
    }

    ReplyDelete
  25. public interface MalucoBeleza ...

    ReplyDelete
  26. Here's a cool one by @iMartyn


    Function TimeWarp inline
    begin
    MOV ax, 'left'
    JMP ax
    SHR ax
    end;

    while true TimeWarp(again)

    ReplyDelete
  27. Noelle = new Object;
    dirtbag.dream( Noelle );
    Noelle.ringsbell = true;
    Noelle.rocks = true;
    Noelle.givesdamn = false;

    ReplyDelete
  28. procedure enter.sandman;
    begin
    repeat
    for x in everyone do
    littleone( say.prayers(x) );
    until sandman.comes ;
    end;
    { #songsincode }

    ReplyDelete
  29. function september()
    {
    do { var d=new Date() }
    while (x.getMonth()==8);
    }

    september();
    wake.me(up);

    ReplyDelete
  30. switch ( pill )
    {
    case 'blue':
    return( dreamworld );
    case 'red':
    exit( matrix );
    }

    ReplyDelete
  31. parade.color = 'black';
    parade.join();

    ReplyDelete
  32. switch ( self )
    {
    case 'human': err();
    case 'divine': forgive();
    }

    ReplyDelete
  33. for (all in em) { all.fight() }; while ( nation.army != 7 ) { me.hold_back() }; /* Seven Nation Army #SongsInCode */

    ReplyDelete
  34. After seeing the Hotel California example (I stuck it as my quit message in my IRC client) a friend responded with a version of his own: http://omgplzstfukthx.blogspot.com/2010/01/hotelcaliforniajs.html

    ReplyDelete
  35. expect(function() { nobody(); }).toThrow("The Spanish Inquisition");

    ReplyDelete
  36. switch ( trick || treat )
    {
    case trick: throw( egg );
    case treat: accept ( candy );
    }

    ReplyDelete
  37. for (shade=0;shade<50;shade++)
    {
    document.write('<b style="color: #', (shade*0x40404+0x111111).toString(16), '">GREY</b> ');
    }
    // #BooksInCode

    ReplyDelete