Line Noise (was Punctuation as noise)

J

Jim Weirich

I cranked out a quick bit of ugly code (see
below). Obviously it's crude -- e.g., it doesn't
take note of strings or comments (and it's not
clear what it should do if it did).

I did something like this a while back when a Java programmer complained
about all that "line noise" in Ruby. I pointed out that Java used much
more puncuation than the typical Ruby program and wrote the following
program to demonstrate...

#!/usr/bin/env ruby
ARGV.each { |fn|
noise = open(fn) { |file| file.read }.gsub(/[A-Za-z0-9_ \t\n]/m, "")
puts "#{fn} (#{noise.size}): #{noise}"
}

Runnnig this over a set of programs written in different languages
gives...

animal.cc (83):
#<>{:()=;};:{:();};::(){::<<"\";}:{:();};::(){::<<"\";}(){*[]={,};(=;<;++)[]->();;}
Animal.java (67):
{{();}{(){..("");}}{(){..("");}}([]){[]=[]{(),()};(=;<.;++)[].();}}
animal.pl (41): ;{{};}{"\";};{{};}{"\";};$(->,->){$->();}
animal.py (23): :():"":():""[(),()]:.()
animal.rb (10): """"[.,.].

Onestepback.org is down at the moment, but I'll post the code for all
the animal programs there when it comes back online.
 

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top