Perl not suitable for beginners? |
Written by Nikos Vaggalis | |||
Monday, 14 November 2011 | |||
Page 2 of 2
Perl task $x = &z(1, 100, 3); Perl possible solution $x = 175.3; The sample Perl code for this task presented to the candidates is not the best that one could expect. Who, for example, is still, using the $_[0], $_[1]… notation to accept a subroutine’s parameters? my ($a,$b,$c)=@_ would be a better and more clear alternative while of course there are other even more clean cut options such as using named arguments. Furthermore, the if-else block that lies underneath the for loop could be replaced with a given-when switch to make the purpose more apparent. Turning to the possible solution in Perl, the six-line if block could be replaced with a single line by using the ternary operator: given ($i % $c ){ The bottom line is that the Perl code could have been presented in a more friendly way to make it more easily understood by the students. However, the fact that I can present this alternative shows where Perl’s power actually is; that it has something for everyone and everyone is entitled to his own personal style, bad or good, with the language not placing restrictions or getting into the way. On the other hand, this syntactic versatility can be abused to the degree that makes the need for an automatic obfuscator redundant! That is the reason that books like Perl Best Practices exist; to present uniform guidelines and attempt to channel and standardize Perl code writing. For example the aforementioned book suggests to use the return keyword to exit a subroutine, which could be very well be used in this example, with Quorum already demonstrating its use. So again Perl suffers in that it is not like other languages that place constraints in writing code and follow a linear path which subsequently leaves not much room for experimentation and imagination. Perl provides unprecedented freedom; you can mix and match the language’s constructs and building blocks, throw in the notion of contexts, stir the mix, and each time get a different outcome, with the compiler not complaining at all! This property could, again, be considered bad by some and good by others, but in the end it goes to show that choosing a different language for that comparison made in this research project, such as Java or VB, with a more familiar and mainstream syntax, could have led to different outcome. Perl is rich in intuitivenessIn seeking to explain why the students found Quorum an easier language to use, the researchers point to its intuitiveness: “But why was it that Quorum, just another general-purpose, object-oriented, programming language afforded better accuracy while programming for novices? We think the most plausible explanation is that we were very careful to use empirical evidence for the design of our language. In previous work, we carefully studied what we called “intuitiveness” metrics for a large selection of word choices in the language. As an example, consider the use of the word for, as is commonly used to represent the concept of looping in a programming language. The word repeat is rated by novices as being nearly seven times more intuitive” And what is the difference between repeat and Perl's while, which could have been used as a more intuitive keyword in place of the the for loop in the task? While on the topic of keyword-choosing for intuitiveness, Perl has foreach, each, unless, defined, map, join and with a bit of imagination you can even make a very valid construct in the form of : next unless defined $cat This also contradicts the notion that there is not much usability research done when creating a language. Larry Wall is not only Perl's creator but also a linguist and that property is evident in the language's design. Was Perl a good choice for this study?
The fact that students performed particularly poorly with Perl, doing no better with it than with a language designed largely by chance, surprised the researchers and made them question their choice of language for the study, commenting: we chose to test only the syntax in Perl that is relatively common across a number of languages (e.g., if statements, loops, functions, parameters). Considering that Java syntax, which many would arguably consider to be easier to understand than Perl, uses similar syntax, we are curious how it would perform. One factor overlooked in this study is that Perl offers More Than One Way To Do It as well the support for the notion of contexts, not found in Java. Bottom line, although I think that Perl was not a good choice for this experiment the results might have been different if the code samples where written in a more succinct and helpful way. The authors also acknowledge that to a certain extent they may not have been entirely fair towards Perl: it could very well be the case that, for either Randomo or Perl, we did not test a feature of Randomo or Perl in which novices would have performed well.While this is true, we generally tried to test the features that My suggestion for further research would be to repeat the experiment after the users have some familiarity with the language. I think that new data from this second stage might come as a big surprise. In the end, I have formed an alternative interpretation of the study's result, one that was surely not intended by this team of researchers.... That Perl is unique amongst others. Love it or hate it, nothing in between! ReferencesResearch paper by Stefik et al Another response to this articlePerl tutorials suck (and cause serious damage) Mithaldu of Perl Tutorial Hub reviews the resources that beginner's might find online and finds them to be lacking. Perl Tutorial Hub is now building a list of Recommended Tutorials with Gabor Szabo's Perl Tutorial the top link. Perl tutorial on I-ProgrammerPerl says "Hello I-Programmer" by Gábor Szabó In Praise of Perl and the Llama by Nikos Vaggalis Beginning Perl 3rd Edition (Book Review) Learning Perl, 6th Edition (Book Review)
<ASIN:0596001738> <ASIN:1430227931> <ASIN:0321496949> <ASIN:1558607013> <ASIN:0596102062> <ASIN:1449303587> |
|||
Last Updated ( Friday, 18 November 2011 ) |