Searching for the best scripting language,

Ryan Paul segphault at sbcglobal.net
Mon Jun 14 02:20:26 CEST 2004


On Sun, 13 Jun 2004 13:34:43 -0700, Richard James wrote:
> "Folks at the Scriptometer conducted a practical survey of which
> scripting language is the best. While question like that is bound to
> generate flamewars between the usual Perl vs PHP, Python vs Perl,
> VBScript vs everything crowds, the Scriptometer survey is practical:
> if I have to write a script, I have to write it fast, it has to be
> small (less typing), it should allow me to either debug itself via a
> debugger or just verbose output mode. sh, Perl and Ruby won the
> competition, and with the difference of 1-2 points they were
> essentially tied for first place... Interesting that ICFP contests
> lately pronounced OCaml as the winner for rapid development."
>  

> What points are the Scriptometer survey missing, in regards to the
> ease of use and beauty of the Python language?
>
> Or should I convert my code base to Ruby and or OCaml? :)


I recently learned ruby, merely out of curiosity. Now that I know it, I
dont write ANY shell utilities with python anymore. Ruby is a much better
choice for almost all simple administrative tasks. For larger programs,
there are times when python seems like a better choice. Python enforces
consistency and readability. In an environment where many people will be
working on the same code for an extended period of time, the benefits of
python become apparent. That isnt to say that ruby *cant* be used in
situations like that. If ruby programmers layout strict guidelines for a
project regarding style and methodology, it would be just as effective.

The proof is in the source. This is part of a ruby program I wrote. This
snippet is actually a single 'line'. I broke it into several lines for
slightly improved readability. This single line would probably take at
least 15 lines to do in python, probably more if you wanted to do it
intelligently. 

["*.rar.*", "*.r[0-9][0-9].*"].each {|fn|
  Dir[$prefix+fn].collect {|x|
  x.gsub(/\.\d+[\d.-]*$/,"")}.uniq.each {|x|
  `cat #{sesc x}.* > #{sesc x}`} }

One of my other favorite features of ruby, is the ability to globally add
methods to base types. While I strongly feel that the ability to extend
base types is a powerful feature, I'm sure many python programmers would
disagree.

> Or should I convert my code base to Ruby and or OCaml? :)

Ruby and Python really have a lot in common. The one you use should
ultimately be based on your style and how you feel about programming. If
you like lots of mutability, lots of functional idioms, and inline regular
expressions, switch to ruby! If not, stick with python.

I'm an ardent OCaml advocate. Anyone who uses c++ should have their head
examined. OCaml is a fast, statically typed, object oriented language with
type inference, pattern matching, automatic memory management, and
inherent parametric polymorphism (you dont need templates!). Native
compilers AND dynamic interpreters are available. It even comes with an
interactive top-level like python does. OCaml programs typically run
faster than comparable c++ programs, and they take significantly less time
to write. OCaml has a built-in list type, and it comes with all the usual
list manipulation functions (map and filter). OCaml is somewhat difficult
to learn however. If you have the intellectual capacity and the time
required to learn a challenging language, learn OCaml. Additionally, I
should mention that OCaml libraries can easily be integrated with python
programs via pycaml. I use OCaml instead of C to write python extensions.

--SegPhault



More information about the Python-list mailing list