LWN.net Logo

On the future of Perl 5

On the future of Perl 5

Posted Dec 4, 2008 8:55 UTC (Thu) by job (guest, #670)
In reply to: On the future of Perl 5 by drag
Parent article: On the future of Perl 5

I don't think the number of files with a particular extension is the question.

A better metric may be:
$ file /usr/bin/* | grep perl | wc -l
97
$ file /usr/bin/* | grep python | wc -l
80

(Repeat through $PATH.) At least on Ubuntu Intrepid this shows them on roughly equal footing.


(Log in to post comments)

On the future of Perl 5

Posted Dec 4, 2008 15:19 UTC (Thu) by hummassa (subscriber, #307) [Link]

Solving the dispute with a little Perl script :-)
#!/usr/bin/perl

use strict;

my %languages;
for( grep !m{^/home}, split /:/, $ENV{PATH} ) {
  for( <$_/*> ) {
    $_ = do { <F> if open F, '<', $_ };
    next unless /^#!/;
    $languages{$1}++ if /\b(perl|php|python|ruby)\d*\b/
  }
}
printf "%-20.20s  %6d\n", $_, $languages{$_} for sort keys %languages

__END__
Output (on my Kubuntu 8.04):

perl                     891
php                        2
python                   242
ruby                      40

On the future of Perl 5

Posted Dec 5, 2008 21:59 UTC (Fri) by cdmiller (subscriber, #2813) [Link]

I'm still waiting for the "equivalent" Python script to appear :)

On the future of Perl 5

Posted Dec 6, 2008 5:47 UTC (Sat) by dmag (subscriber, #17775) [Link]

Oh, please, let's not have a language flame war on LWN.

Besides, Ruby is much better :)

#!/usr/bin/ruby

is_home = lambda {|path| path =~ /^\/home/ }

languages = Hash.new(0) # Default value is zero

ENV['PATH'].split(/:/).reject(&is_home).each do |one_path|
  Dir[one_path + "/*"].each do |binfile|
    File.open(binfile,"r") do |data|
      first_line = data.gets
      languages[$1] += 1 if first_line =~ /\b(perl|php|python|ruby)\d*\b/
    end rescue puts "#{binfile} unhappy"
  end
end

languages.each_pair do |language, count|
  puts "%-20.20s  %6d" % [language, count]
end

__END__
Output from Slackware 12.0 (with lots of rubygems installed):
php                        1
python                    62
ruby                      79
perl                     203

For comparison: (sh|bash|tcsh|csh|ash|ksh|zsh|fish)
sh                       488
bash                      22
ksh                        1
csh                        1

Of course, we're not really measuring anything useful here. For example, git used to install tons of commands in /usr/bin. This could tilt the scales (if it were written in one language).

Seriously, I doubt that Ruby (or even Python) will unseat Perl from it's sysadmin tool niche, which is what we seem to be measuring here. Since every distro has bash and perl, that's what people tend to use.

On the other hand, I think Ruby (and perhaps Python) has already unseated Perl from web scripting, where the client doesn't care what language the server is written in.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds