in reply to Re^5: RFC: How to succeed with your Perl homework
in thread RFC: How to succeed with your Perl homework

If you want to write your own book where you tell novices "Include these three to seven magic lines at the start of every program you write, but don't worry if you don't understand them, they're really important, trust me, and yes I meant every program you write!"
You must misunderstand me.

If I say my boilerplate is:

#!/usr/bin/perl use strict; use warnings;
I don't intend to write that as:
#!/usr/bin/perl use strict ; use warnings ;
Three lines is just 3 lines. Not 7.

As for explaining, I rather explain the benefits of "use strict" and "use warnings" then "oh, just download this magical thingy from the internet, written by some dude, who will tell you just to trust him and use the magical thingy everywhere".

In my years as a trainer, I never explained things away with "oh, this is just a magical thing which I won't explain, just trust me, use it". I'm not that lousy.

Replies are listed 'Best First'.
Re^7: RFC: How to succeed with your Perl homework
by chromatic (Archbishop) on Nov 04, 2010 at 17:23 UTC
    You must misunderstand me.

    I counted the boilerplate I regularly use in my code. It's at least three lines and often as much as seven, after enabling strict, warnings, 5.10 syntax extensions, autodie, utf8, mro, and a couple of other pragmas.

    As for explaining, I rather explain the benefits of "use strict" and "use warnings"...

    As the first thing you do when teaching people how to write "Hello, world!" in Perl?

      You've hit the nail right where it should be hit!

      When explaining perl to beginners, I would not even consider explaining mro or why utf8 should or should not be used.

      I'm very sorry to see so many posts in this thread about why what editor would be perfect under Windows. Who The Fuck cares! Most good Unix editors have a Windows port, and most have the same advantages over the other (or disadvantages) as they have on Linux/Unix. Programmers will use what they have, and will not go into a search for an editor when confronted with the task to write their first perl script. They will use notepad proably, and that suffices for now.

      Does notepad support the typing of Unicode characters? Well that probably depends on what version of Windows they run, what their keyboard is set to (at the moment) and probable what service pack has been installed. All and all IMHO something you certainly do not want to address when telling beginners how to write a perl script.

      YOU are a seasoned programmer. I know that. I have met you and talked to you, and I am aware that you know why you want to include these pragma's in every script you write. And there is nothing wrong with that. It is a well-defined decision and makes your programming life easier.

      When I were to teach people perl from the start, I would include thee three basic lines from the start, and tell them that they will be explained later in the course, but that it is always a good idea to include them from the start. So, not the first thing. Certainly not.

      Once they iunderstand the meaning of these pragma's - later in the course - I might hint them to easier ways to deal with them, but I would certainly not recommend them in class.


      Enjoy, Have FUN! H.Merijn
      First thing? Probably not - as I will still be busy telling people how to actually run the program they just wrote. But then, I wouldn't start with use right after "Hello world" anyway. First day of the course? Certainly.
      I counted the boilerplate I regularly use in my code. It's at least three lines and often as much as seven,
      Exactly. Your boilerplate isn't mine. So, I shouldn't use your boilerplate. Or anyone elses whose boilerplate doesn't match mine. But then, if everyone uses his/her own boilerplate (say, a subset of 10 pragmas), I rather explain 10 pragmas, than having to memorize 1024 different boilerplates. Of course, someone may write a boilerplate pragma that allows you to do:
      use boilerplate qw(strict warnings autodie utf8 mro);
      but that doesn't gain us much, does it?