Friday, 18 February 2011

Teaching Perl to Undergraduates

Perl is an amazing programming language. And, with its growing worldwide re-popularization, it was an easy sell to the Computer Science Department of the Federal University of Rio de Janeiro, one of the best and most famous universities in Brazil, when I offered to give a free Perl summer class to the undergrads.

The idea was to give students the opportunity to learn a new language, presenting the concepts, structure, best practices and design patterns of modern Perl 5. It was also my response to seeing so many companies here complaining about the lack of Perl developers, forcing them to use other languages even when Perl would be the best alternative for them.

And what a huge success it was!

The course was given by Bruno Buss and myself, with me doing the talk and him preparing and giving exercises to the students and helping them with their code. At first we were hoping to get about 10 students interested, specially since we didn't have time to advertise the summer class at all. In fact, due to uncontrollable events, we could only confirm it and open registration two weeks before the class itself started. Even so, we decided to carry on with it. Later that night I got a message from Buss: "we're gonna need a bigger room".

Turns out that in less than 24 hours we already had over 25 undergrad students registered for the course! We kept registration open as a waiting list, since we couldn't find an available lab with more than 25 PCs in such a short timeframe. A day before the beginning of the class there were over 50 students applying for a spot, even though they already knew the class was full!

And this is Perl competing against student vacations, during summer, in Rio.

The course was one week long, from 1pm to 5pm (yes, we had to compensate $dayjob during nighttime, but it was well worth it). Slides for all 5 days are available. It's mostly Perl, with a little Portuguese here and there like variable names, values and complementary information whenever necessary. Here's what we covered:

  • Day 1 (slides) - What's Perl all about; how to use perldoc; the modern and safe header (use 5.12.3; use warnings); basic I/O; scalar variables; manipulating numbers and strings; conditionals; loops; and file I/O, with autodie to capture exceptions. We also spoke about the Perl community, showed off a bit of Padre, the Perl IDE, and encouraged students to use chromatic's brilliant "Modern Perl" book as reference material.
  • Day 2 (slides) - Running external programs; arrays (and how to manipulate them); hashes (and how to manipulate them); scalar x list x void context. That, and lots of exercises to fixate what they learned so far.
  • Day 3 (slides) - References; building complex data structures; functions (subroutines); stack traces with Carp and Carp::Always; and retrieving command line arguments with Getopt::Long. While explaining anonymous subs we also mentioned/demonstrated closures and state variables, but didn't really get into it as it was a beginners class. The day ended with an explanation of Perl's sweetheart, the CPAN. We showed students not only how to install modules (with local::lib), but included an explanation of the full CPAN stack, including web search, CPAN Testers, Deps, Ratings and Bug/Request Tracking. We also discussed how to exploit those features (and other common tips) to pick a good module (and, of course, Task::Kensho).

Students were mostly from Computer Science, with around 6 of them being from Biology/Biophysics/Bioinformatics, and one or two from Electric Engineering and Applied Mathematics. In the end, there were 27 undergrads. Yes, 27. It was very rewarding to see 2 booted students showing up anyway, with their laptops, asking if they could sit on the back and participate. Of course they could :)

13 comments:

  1. Wow! That's great and inspires me to think of trying the same in my city

    ReplyDelete
  2. @johnnapiorkowski: Thanks :) If you have the chance, I really think you should give it a go. It was an extremely rewarding experience for me, and I highly recommend it!

    @mantovani: thanks :)

    ReplyDelete
  3. Hi garu,

    I'm coming down for the São Paulo Perl Workshop and coming by Rio afterward. Let me know if you'd like me to stop by and maybe give a lunch time talk. :)

    ReplyDelete
  4. Thanks for sharing the slides. I have tried several times to learn perl (or at least a little perl), but have failed every time, not even getting to doing something useful.

    I hope this helps :)

    Cheers,

    Ruben

    ReplyDelete
  5. Very nice initiative from garu++
    I lectured a similar course in São Paulo's FEI Computer Science course last month, except I skipped a few of the perl details and taught them web development and git instead. The last day was a hackathon, then we integrated everyone's code and got an alpha-quality twitter clone running. No-one had any trouble picking up the basic perl syntax and they were able to do a lot with their very limited knowledge of the language.

    ReplyDelete
  6. Thanks for sharing ....I would use your material to learn Perl ... I would like to follow your blog posts, however there is no feed anywhere.

    Emeka

    ReplyDelete
  7. garu++

    How do you keep finding ways to keep us impressed? :)

    ReplyDelete
  8. @brian - we'd love that! I sent you an email, let's continue this talk over there :)

    @RBerenguel - thanks, I hope so, too! If you have questions or need extra pointers, there are several Perl Mongers groups scattered throughout the globe and ready to help all newcomers. There's even http://barcelona.pm.org/ if you still live there :)

    @Eden - thanks! And thanks for sharing your experience too - it's really nice to see the "prejudice generation" fading away and giving room to students eager to learn different ways of solving problems :)

    @Emeka - thanks! As for feeds, sure there are: http://onionstand.blogspot.com/feeds/posts/default
    There are even alternatives feeds as listed in http://www.google.com/support/blogger/bin/answer.py?hl=en&answer=97933
    But, if I may give a suggestion, you can simply follow the Planet Perl Ironman feeds at http://ironman.enlightenedperl.org - there are several enthusiasts and developers blogging about Perl, from beginner to advanced levels :)

    @nxadm - Thanks! I try :P

    ReplyDelete
  9. I got the below comments when I re-shared this post via Buzz.

    Bosah C - Sounds interesting, but I think Perl is somewhat of a high level programming language to teach "introduction" to programming. The students will eventually learn to write code for sure, but will they "really understand" the underlying complexity of programming that Perl abstracts away?Feb 20

    Michael P. Reilly - I'd never use Perl to teach anything except how to program badly. Python is a more logical choice than a language where extraneous sugar, habits for obfuscation, badly designed class syntax are the norm. For a compiled, static typed language, I would choose C to teach first, then Java. Granted this is in a college/university arena, not a hobbyist.Feb 21

    ReplyDelete
  10. @Emeka - Unfortunately, there are still some people who think badly of Perl because they either don't know it well enough or because it doesn't fit their way of thinking and approaching problems.

    One can program badly in *any* language, just as one can write nice, modern and elegant code in Perl, and putting its inherent flexibility to good use is exactly where Perl becomes so powerful, specially with the CPAN.

    It's also important to notice that it was not an "introduction to programming", but an "introduction to Perl". Most (if not all) of our students already had some experience with other languages and, just like Eden Cardim's experience, no one had any trouble picking up the basic Perl syntax, and everyone was able to do a lot, even with their very limited experience in the language.

    ReplyDelete
  11. Congratulations Garu!. Very good material. Such a good initiative!
    Thanks for sharing!

    ReplyDelete
  12. PERL Online Training, ONLINE TRAINING – IT SUPPORT – CORPORATE TRAINING http://www.21cssindia.com/courses/perl-online-training-36.html The 21st Century Software Solutions of India offers one of the Largest conglomerations of Software Training, IT Support, Corporate Training institute in India - +919000444287 - +917386622889 - Visakhapatnam,Hyderabad PERL Online Training, PERL Training, PERL, PERL Online Training| PERL Training| PERL| "Courses at 21st Century Software Solutions
    Talend Online Training -Hyperion Online Training - IBM Unica Online Training - Siteminder Online Training - SharePoint Online Training - Informatica Online Training - SalesForce Online Training - Many more… | Call Us +917386622889 - +919000444287 - contact@21cssindia.com
    Visit: http://www.21cssindia.com/courses.html"

    ReplyDelete