The Perl Learning Environment

For YAPC::NA, I'm creating a new course called "From Zero to Perl" (although I'll probably actually call it "0..Perl"). JT Smith wants to create not only new Perlers, but new programmers, and he wants to start them with Perl. I'm up for the challenge. However, there are some things that you might have opinions and suggestions on.

The Learning Perl course I teach assumes that you already know how to program, just not in Perl. Some non-programmers do alright, many struggle, and a few outright fail. Most of those have nothing to do with Perl as a language. Programming as a way of thinking is hard, especially for the complex things people what to do right away with Perl. It's easy to make a turtle draw geometric shapes, it's not conceptually easy to design a blogging platform.

  1. The first problem is that this sort of audience has never seen a command line before, and the ideas of the default file handles are completely new concepts.
  2. Text editors are often foreign, and the idea of putting text in one program then switching to another program to use it is also new.
  3. The Unix universe and its shell, with permissions, environment variables, and other external forces, requires a lot of extra knowledge.
  4. The computer that many students have is often not the one they actually use for work.

As part of this, I think I want to build this class around a particular IDE. I'm not an IDE person, but I think featuring it in the class will help people get started. People don't have to use it, and I'll briefly show some alternatives.

The second part, I think, will be some sort of Oracle VirtualBox machine (it's free, although I like VMWare), configured with several different perls, all of the extra modules (especially tricky ones like the ones that require external libraries), cpanminus, and so on. Part of the class will have them install their own perl by hand, then by perlbrew perhaps. I'm going back before you can even do "Hello World". The trick is choosing which free operating system to use.

From there, I'm not sure what else I want to do with it.

12 Comments

You hit the nail on the head with comments about the text editor and the "write here use there" problems. I taught a zero to LaTeX class and that was a major hurdle. I would def recommend an IDE to start because then it at least looks like the editing and compiling/running happen in the same place.

The problem I see is that most of our use of Perl revolves around STDIN/OUT which - even if you don't want to teach @ARGV - will require some kind of a shell.
Any reasonable IDE would provide you a way to run your code from inside the IDE (e.g. using F5) and the output will go in one of the windows of the IDE or in a shell window that pops up.

I am afraid that's still foreign to people who are not familiar with a shell or cmd window.

To avoid that one can start building a web application. You can arrange to launch it from the IDE but you will need to switch to a browser to check it.

Other than that you can start by building a desktop GUI which is complex in itself.

Very good!

Virtual machine sounds good. You could freeze its state before delivery with a simple text editor and a terminal open. Then entering some "hello world", saving, switching to terminal and saying "perl helloworld.pl" should be easy enough.
IDE is fine, too.
The next logical step would perhaps be to learn some commands and cool things: "Hey, you can print an array with foreach (@array).." :-)

To me installing own Perls by hand before working with shell & editor sounds like a little bit too much magic. I believe it would rather confuse me. As for Windows users, they might be used to downloading something (strawberry) and installing and then launching a program. Perhaps you could teach them how to obtain and run a Perl on their preferred OS?

When I'm a beginner, things can never be simple enough. Few new things only - about 3-4 :-) - will most certainly need some training from my part to get accustomed to.

I believe that web and GUI applications are rather complicated for beginners because they imply too many new concepts.

All the best with this course and keep us posted on how it went!

I think it is good to teach the use of tools to install CPAN modules. May I suggest that when doing this you set it up so that an install fails due to some missing pre-requisite, explain how to decode the error message, and then go through the steps to fix it. This was certainly a stumbling block for me.

The only IDE I have experience with is BBEdit which I recommend because there is no switching - you can run code with a click of the 'Run' button, check syntax, get output and errors in separate windows, etc. Perhaps even more useful, if your output is HTML you can preview it without going to a browser. And of course you can also use it as a command line editor. It is Mac OS only though.

May I suggest a separate (pre-requisite) course that teaches the first few (maybe 5?) chapters of The UNIX Programming Environment (http://en.wikipedia.org/wiki/The_Unix_Programming_Environment) or similar?

It is a good grounding that will help them in any future endeavors to use Perl and other open source software in a *nix like environment.

Exposure to the shell, sed and awk (and even C!) leads to a natural 'evolutionary' discovery of Perl as a welcome relief that will hopefully answer the question "Why Perl?" in their minds too.

This is a great initiative!

For newcomers, I agree IDEs are the way to go.

One way to minimize issue #4, as you have taught me, is to ask students beforehand to bring laptops with similar operating systems to where they plan to do their Perl hacking.

If this is not possible (they might be required to deploy their code in a Unix box and their laptop is Windows-only, for example) then a VM should do just fine. I'd try to steer away from them, though, since students might not be familiarized with the concept, in which case handling the VM - not to mention the underlying system and the whole "will it mess up my native OS?" set of questions - will be yet another thing to learn.

As for building their own perl by hand, took me a few years before even trying, and might scare newcomers off. How about just showing them perlbrew and skimming over what it does behind the scenes, or skipping it altogether? It's a beginner's class, after all. Depending on time constraints and the pieces of Perl you want to teach, anything other than how to install modules without administrative privileges might be overdoing it.

To me, the best way to avoid a problem is to not create it in the first place :)

First, congratulations on your bravery. Teaching non-programmers how to write even the most basic programs can be a maddening process. However, you like doing things the hard way!

Forget virtual machines. If you don't shutdown your virtual machine before you shutdown Windows, you can hose your virtual machine. And, forget rolling their own Perl. Or the Unix way of thinking. Keep it simple. If these people are as non-technical as you say, you're going to have to keep things as simple as possible.

I've done my time teaching beginners from zero. They have enough problems with writing a simple "Hello, world!" program. The semicolon on the end of the line. The "\n". What are those? You can spend an hour just explaining those two points.

On Windows, have them install ActivePerl. It's easy to install since it's an MSI, and comes with built in HTML documentation (which can be a bit scary for beginners). ActiveState also comes with a whole array of non-standard CPAN modules which should be more than enough to get you started. Believe it or not, CPAN works fine with ActiveState, so if you decide this is something to cover in later classes, you can.

I'm not sure a full blown IDE is the way to go. I've found that students are confused by the complexity of the IDE. For Windows, I've used Notepad++. It's simple (you can copy and paste via the edit menu) and does syntax highlighting. Students understand it.

If you want an IDE, try Eclipse with Epic. It does everything an IDE should: Syntax hinting, syntax highlighting, the ability to execute a program without leaving the IDE, etc. The only problem is that the debugger doesn't work. However, using a debugger is a skill that's too complex for most beginning developers. I'm happy if they know how to add "print" statements in their program to help with debugging.

I find Perl to be an excellent beginner's language in many ways. Perl's variables are obvious (They start with a sigil), and your syntax can be nice and loose (no declaring variables or worrying whether they're integers, floating points, or strings). And, you can move all the way into object oriented programming.

I'm very happy to see you doing this. As someone who had no background in programming prior to starting out in Perl, I can tell you I would have LOVED this opportunity.

Please record the workshop and post it to Vimeo/YouTube afterwards along with the presentation slides. It would be fantastic if others would follow this at other conferences and local meetings.

Best of luck!
Luis

Since web is "the new black" exposing beginners to Mojolicious Lite apps might prove the point of the usefulness of perl-programming in a few lines of code.

... of course Mojo is also a kind of "rabbit-hole".

I think you will have 2 types of audiences.

- Beginners ( not familiar with unix shell )
- Intermediate - master ( those who have programmed in Perl or other languages and already have a idea what an IDE/editor is and how to use it )


For Beginners you will have those who are familiar with using the Mac OS and those who prefer Windows.I believe it will be great to teach beginners to install Perl on the OS of their preference because this will allow them to take home a Perl installation to play with.

Sometimes the biggest problem with starting to learn a given language/framework is the fact that it may be difficult to install it. Not able to easily install Perl will be an obstacle for any beginning Perl developer.

For Windows I suggest DWIM Perl which includes the Padre Editor. I am not sure what to recommend for Mac OS users.

As for the Intermediate audience, you pretty much have it squared away.

Have you considered running a tutorial session in the browser with
client-side Perlito5?

(This is a work in progress, I apologize for the bugs.)

There are a bunch of Perl REPLs, from perl -de0 to things requiring lots of Moose silliness. Have you tried using one of them?

Leave a comment

About brian d foy

user-pic I'm the author of Mastering Perl, and the co-author of Learning Perl (6th Edition), Intermediate Perl, Programming Perl (4th Edition) and Effective Perl Programming (2nd Edition).