----- Original Message ----
From: Michael Mathews <[EMAIL PROTECTED]>

> So my question to the list is, in simple terms even an IT manager
> could grasp, explain what problems Perl 5 has that Perl 6 fixes, such
> that they would want to undergo the pain of ever switching.




Hi Michael,

Many companies eventually switch to new languages.  The switch is painful, but 
when they see their current technologies aren't working, they reach for 
something else.  The question is, why Perl6?

Perl6, for those who have been paying attention, is revolutionary.  Not only 
will the language run much faster, but programmers will be more productive, 
they'll be able to seamlessly interact with code written in other languages and 
they'll be able to easily do things that is hard to do in other languages.

That's the short answer, but it sounds like a marketroid.  Here's (some of) the 
beef, though I'd be happy for corrections on any misconceptions below.

Perl5 is a very powerful language, but it does have plenty of cruft and is 
showing its age.  Perl6 not only fixes a lot of that cruft but also adds new, 
powerful features which makes programmers more productive and thus can churn 
out apps quicker.  Further, because it will be running on top of Parrot, it 
will be far faster than Perl5.  So you gain both programmer and runtime 
performance.

The most serious problems I have with Perl5 tend to center around its flexible 
but limited OO model.  Right now there's not a clear distinction between class 
and instance data.  This means that it's very easy to create class data which 
makes subclassing difficult at times.  Further, Perl5's poor argument handling 
is a constant source of bugs:

  sub some_value {
      my ($self, $value) = @_;
      return $self->{value} unless $value; # whoops!  Is "0" OK?
      $self->{value} = $value;
      return $self;
  }

Also, Perl6 will offer much strong encapsulation than one can "naturally" do in 
Perl5 (without resorting to inside-out objects, but I tend to recommend that 
folks not use those).

Perl6 offers optional strong typing, meaning that you can declare the above 
argument to some_value to be an integer and have less worries that someone will 
pass a string.  The strong typing means you can also do this:

  my int @array;

That will allow optimizations that are currently not possible, but since it's 
optional, you can choose the flexibility of late binding or the comfort of 
early binding (a bit of hand waving there).  

Multimethods are also very powerful, but difficult to do with Perl5 without 
extra (and slow) modules.  The can alleviate many bugs associated with methods 
(feel free to correct my syntax):

  method name () { return $.name }
  method name ( $name ) { $.name = $name; return $self }
 
Being able to overload methods and subroutines based on signatures is going to 
be a huge win.

Further, when other languages target Parrot, Perl6 will be able to comunicate 
with them *without* extra scaffolding code or you having to rewrite them!

Or how about the power of junctions?  Want to verify that none of the elements 
in one list are present in another?

  if all(@numbers) == none(@disallowed) {
     ...
  }

Ordinarily, writing code to do that is complicated and can be buggy and slow.  
This makes it much easier to read and can be run in parallel if your system 
supports it (is this correct?  I *think* it is).

And to multiple all items in an array by some value?

  @items = @items >>*<< 1.05; # add 5% sales tax

Anyone who's programmed OO code long enough knows the problems inherent in 
multiple inheritance.  These problems are so serious that some language simply 
forbid MI.  Java uses interfaces and Ruby uses mixins.  Both have problems 
limiting their use in large-scale code.  Perl6 will be the first mainstream 
language to incorporate traits (known as "roles" in Perl6) to eliminate these 
problems.  Traits are easy to use, very flexible and I found them more natural 
to use once I understood them (they've saved me major headaches in some of my 
code.  See Class::Traits for a fairly full-featured Perl5 implementation).

The list goes on and on.  Perl6 will run on Parrot and Parrot will the the CLR 
(common language runtime) for dynamic languages.  C# advocates *love* having 
the CLR available.  Now we'll have one too, but it will be geared towards 
dynamic languages.

Oh, and did I mention Perl6 rules?  That's probably one of the single most 
important things about Perl6.  Regular expressions have needed updating for a 
long time and @Larry has had the guts to bite the bullet.

All of these things (and many more) mean a language that's more productive for 
the programmer, runs much faster and is more flexible.  Further, the easy 
things are even easier than Perl5.  All of this translates to more $$ for 
companies.

Personally, I want to thank Larry, Damian, Luke, chromatic, Allison, Audrey and 
many more for their fine work in designing and implementing Perl6 (gush, gush, 
gush). I was leaning away from Perl5 due to its limitations, but now I'm here 
to stay.  I am supremely confident that Perl6 will be a hugely popular language 
simply based on its merits, not marketing.

Cheers,
Ovid


Reply via email to