Different languages compared

Posted: November 29th, 2010 | Author: Mars | Filed under: Reference | 2 Comments »

A number of web sites offer comparisons of the same task implemented in different programming languages:

  • 99 Bottles of Beer: a program to print out the text of the song “99 Bottles of Beer”, implemented in 1,348 languages
  • Rosetta Code: several hundred reasonably common programming tasks represented in a few hundred different languages
  • Langref: several dozen common problems implemented in the fifteen currently-hip languages
  • PLEAC: all the examples from the Perl Cookbook, implemented to varying degrees in 28 languages; has lots of content but appears to be dead (no updates since early 2007)

2 Comments on “Different languages compared”

  1. 1 Andy said at 21:20 on November 29th, 2010:

    It will be good to see how Radian examples compare :)

  2. 2 Mars Saxman said at 22:43 on November 29th, 2010:

    Here’s a stab at the 99 Bottles of Beer program, lightly adapted from the Python example:

    #99 Bottles of Beer
    import number from radian
    import string from radian
    
    for i in number.range(0, 99):
       const quant = 99 - i
       var suffix = ""
       if quant > 1:
          const qs = string.decimal(quant)   
          io->print( qs & " bottles of beer on the wall, " & qs & "bottles of beer." )
          if quant > 2:
             suffix = string.decimal(quant - 1) & " bottles"
          else:
             suffix = "1 bottle"
          end if
       else if quant = 1:
          io->print( "1 bottle of beer on the wall, 1 bottle of beer." )
          suffix = "no more beer on the wall!"
       end if
       io->print( "Take one down, pass it around, " & suffix & " bottles of beer on the wall." )
       io->print( "--" )
    end i