I had the pleasant opportunity to meet and talk with Dick Hardt of ActiveState on the Perl Geek Cruise. One of the points he made that I found interesting was that one of Perl5's failings was that it used a different syntax (->) for object method calls than other languages. He felt that since so many languages use a dot for this purpose, Perl was harder to use because you couldn't just copy example code and use it in your program. Of course, the code he was talking about was OLE Automation code under Windows, where you see examples for (for instance) Visual Basic. That is, assume you had the following VB example code:

Set WordObj = CreateObject("Word.Basic") WordObj.FileNew WordObj.EditClear

Perl5 requires you to write something like:

use OLE; my $wordObj = OLE->CreateObject("Word.Basic"); $wordObj->FileNew; $wordObj->EditClear;

This seemed to me at the time like a niche concern, and one that could be easily taken care of by a reasonable editor (I could make a "paste as Perl5" macro easily in Vim), or a bit of programming. After all, who's in such a hurry to make a program that they can't stop and think about what they just pasted in? But I thought it was an interesting point.

Then somewhat later, I was reading David Simmons' posts on comp.lang.smalltalk about the great work he was doing on the Smallscript product (essentially a version of Smalltalk, but with lots of language improvements). Smallscript runs on the Microsoft .NET platform.

David also mentioned that he'd added the dot syntax, for much the same reason (copying of example code). Recall that Smalltalk normally would use something like this:

| wordObj | wordObj := OLE createObject: 'Word.Basic'. wordObj fileNew; editClear.

Now I see that Perl6 wants to start using the dot instead of the arrow (and change concatenation to the tilde (~)).

Apparently, the idea that people have to be able to paste OLE example code into their programs directly has taken root among a fair number of smart people in the Perl community and elsewhere. While I have no particular preference one way or the other with respect to the proposed Perl6 syntax, I do think that it's curious that this belief is so prevalent. It may be something Microsoft is promoting, or it may have come from observation of users in the field.

What bothers me about the belief is that the language designers are attempting to facilitate cargo-cult programming by doing this. Perhaps they feel that their languages won't compete well with other languages that use dots (as I recall, Python, Java, C++ (refs), VB, and Ruby all use dots for method calls). Perhaps they want to extend the reach of their languages into the ranks of the VB macro/spreadsheet community. I don't know. But it seems to me that changing language syntax to match Visual Basic should be low on people's priority lists.


In reply to Dots and cargo-cult programming by bikeNomad

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.