Perl not suitable for beginners?
Written by Nikos Vaggalis   
Monday, 14 November 2011
Article Index
Perl not suitable for beginners?
Perl's weaknesses are strengths
In a recent study of how beginners perform when given the task of writing programs without any tutorial help, Perl came out worst among three languages. Is this a real reflection of Perl's suitability as a starting point for learning to program?

 

Three programming languages were included in a small scale study undertaken in the Department of Computer Science at the University of Southern Illinois.  The researchers wanted to discover how accurately novices who were programming for the first time would write programs that used common program constructs such as loops, conditionals, functions, variables, parameters.

Perl was the only "real-world" programming language in the line up while the other two were novel languages devised for research purposes.

According to the report of the study, Quorum is

an evidence-based programming language, where the syntax, semantics, and API designs change in correspondence to the latest academic research and literature on programming language usability.

and Randomo is

a Placebo-language, where some of the syntax was chosen with a random number generator and the ASCII table.

The study's results revealed:

Quorum users were afforded significantly greater accuracy compared to those using Perl and Randomo, Perl users were unable to write programs more accurately than those using a language designed by chance.

So the final outcome is that Perl scored lowest of all.

While the paper, An Empirical Comparison of the Accuracy Rates of Novices using the Quorum, Perl, and Randomo Programming Languages, is an interesting read about an interesting approach, I would like to raise some objections and discuss the idea of languages and their purpose.

Is Perl representative of general purpose programming languages?

The researchers note:

During the course of these studies, we have observed that novices learning to program at the university or younger levels, can have significant difficulty learning the syntax of general purpose programming languages, which may initially seem arbitrary (e.g., ||, ˆ, @ [0]). Given this observation, novices may think programming language syntax is rather arbitrary.

Out of all general programming languages that could be used, choosing Perl as a representative sample is a bit unfortunate. Perl is notorious for having a highly idiomatic syntax, which can furthermore assume alternative semantics depending on the context. Therefore it is unlike any syntax present in most mainstream programming languages

Better, more modern, Perl code could have been presented.

To understand this objection you need to see one of the  the code samples that were used in the study in the three versions plus the code of their sample solutions. The subjects were given the sample code and a description of what it does.

The description for each of the set read:

This code will count the number of values that are and are not divisible by c and lie between a and b. It then compares the number of values that are and are not divisible by c and makes the greater of them available to the user.

Using each of the samples as guides to how to write code the subjects were then asked to write a simple program that performed a simple task. The description of the simple task read:

Using the code sample given to you, try to write code
that defines a variable x that stores real values and is set to 175.3. The code should also define a variable y that stores a string of characters and saves the word false in it. The code should then check whether x is larger than 100. If so, y should save the word true. Otherwise, y should save the words still false.

The three sample programs and a possible solution can be seen below:

Quorum task

action Main
number x = z(1, 100, 3)
end
action z(integer a, integer b,
integer c) returns number
number d = 0.0
number e = 0.0
integer i = a
repeat b - a times
if i mod c = 0 then
d = d + 1
end
else then
e = e + 1
end
i = i + 1
end
if d > e then
return d
end
else then
return e
end
end

Quorum possible solution

number x = 175.3
text y = "false"
if x > 100 then
y = "true"
end
else then
y = "still false"
end

Randomo task

ˆ Main { 
˜ x \ z(1, 100, 3)
}
ˆ z(@ a % @ b % @ c) | ˜ {
˜ d \ 0.0
˜ e \ 0.0
@ i \ a
# (b - a) {
: i ; c ! 0 {
d \ d + 1
}
, {
e \ e + 1
}
i \ i + 1
}
: d ` e {
-d
}
, {
-e
}
}

Randomo possible solution

˜ x \ 175.3
?? y \ ?false?
: x ` 100 {
y \ ?true?
}
, {
y \ ?still false?
}

<ASIN:1449303587>

<ASIN:0596001738>

<ASIN:1430227931>



Last Updated ( Friday, 18 November 2011 )