Welcome to the Monastery | |
PerlMonks |
Re: Re: Perl as a teaching aidby Vynce (Friar) |
on Jun 25, 2001 at 12:02 UTC ( [id://91209]=note: print w/replies, xml ) | Need Help?? |
If this script is intended to teach perl, or programming in general, then i agree that there are things here the students should not learn. I also think that, in that case, the for(;;) loop should be made legible. However, i got the idea that this perl was for something else; he did, after all, say it was a teaching aid, not an aid for teaching perl. Spacewarp's script is much more readable for a student, i think. As such, it is better for making a point that can be easily followed about the nature of binary mathematics. If the algorithm was, in fact, presented in class as he coded it, then it is an accurate representation of the algorithm the teacher picked; since representing that algorithm was one of the stated goals, that's a good thing, even if the algorithm was bad. After all, you don't teach someone the french for "I went to the store" is "J'irai au cinéma" just because they should go to a movie instead. (This may seem like a nitpick, but i was given a few such programs to "learn" from and they drove me up a wall, because they did things totally unlike what they were said to do.) And, really, if we're talking about a better algorithm, you should start with whatever power of two is the first one under the target number IMO. (int (log($n)/log(2))) But to return to my point, i think his perl was not to teach perl, but to introduce them to the basic idea of programming. Actually, it might be a neat recurring theme for the class; take this bit of code and change it as they learn more code concepts, to include subroutines and be able to split things into different bases (ord(A) in trinary looks very different than ord(A )in binary...) just my take. thanks to OeufMayo for the french snippet. .
In Section
Cool Uses for Perl
|
|