Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found