Programming by syntax doesn't scale.

Because Perl uses syntax and specialized operators to differentiate its types, Perl's type system is necessarily extremely limited. Furthermore there are things you sometimes would like to do which you either can't, or have to do a lot of extra work to do, because the type system gets in your way.

The language that convinced me of this is Ruby. There everything is an object, and the syntax that exists is just syntactic sugar around method calls. Provide the right methods, and the syntax will work for your objects.

The example that I give to illustrate why this is nice is tie. In Perl you can't directly make your objects into data types other than scalars. The solution is tie. (Which relies on magic, and because of how this is internally implemented it has been a common source of bugs.) But what if you want to create something that is almost a hash, but has a couple of extra methods? (For instance you have a dbm, and you want to expose some locking methods.) In Perl you either have to use a scalar and have people use -> often, or they have to resort to tied to get your extra methods.

By contrast in Ruby there is no need for something like tie. Just create an object with the right methods and it can be used like anything else with those methods. Want a hash that has locking methods? You can easily write one! The syntax is nicer than Perl. Conceptually it is simpler so people don't get so confused. Furthermore because this isn't implemented with if statements everywhere in the code, it isn't buggy.

What does Ruby give up for this? Autovivification can't be made to work. So Perl gets some convenience in return for a barrier to scaling in complexity.


In reply to Re: Perl 5's greatest limitation is...? by tilly
in thread Perl 5's greatest limitation is...? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.