http://www.perlmonks.org?node_id=991595


in reply to Teaching Perl

I do hope his printed material is better readable than his blog. Of course it most is about taste, but I had to add some style changes before being able to read that without being ultimately annoyed by the layout and chosen fonts.

<style type="text/css"> body { font-family: DejaVu Sans; } pre, code, tt, kbd { font-family: DejaVu Sans Mono; } .wrapper { max-width: 80%; } p { text-align: justify; } </style>

added to head did it for me. YMMV.

I have to (not really voluntary) do a lot of Java lately, and though I do not really dislike the language as such, I really hate the need of an IDE to be able to cooperate with others when using things like maven and jIndent.

What bothers me about Java is the way some (basic) classes are set up with missing functionality (but still about 20 methods I'd never use). What I *love* about Perl - compared to Java - it autovivivication. Building a short-living cashing construct in Perl is maybe about 4 lines. In Java it is likely to be 4 files of 100 lines each.

Development in Perl is way faster, and with some constructs being extremely long in Java, I sincerely doubt if what people applaud in Java as being maintainable and scalable holds in all/most cases.

All and all it is a nice read. I agree with quite a few points he makes, but (TIMTOWTDI) of course also not to all. Like e.g nested data structures difficult in Perl? I don't think so. Personally I see it way more easy in Perl than in Java. Autovivivication and pack/unpack are powertools missing in Java.


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: Teaching Perl
by Corion (Patriarch) on Sep 04, 2012 at 11:09 UTC

    IMO nested data structures are always difficult, but Perl adds more difficulty early on. The only easy data structure you can pass around is the flat list, or some scalars in front of a flat list. Creating a complex data structure is "just some syntax", but accessing data in it requires learning about references and dereferencing.

    Python for example makes accessing complex data structures easier, because it does not flatten argument lists. There is the nasty surprise later on, when you realize that you need the equivalent of Storable::dclone, because in Python just like in Perl, all complex elements of hashes and arrays are still references. But you don't need to know that just to pass parameters more complex than a list to a function, and retrieve them in that function.

      Personally, I just pass around a reference to the complex data structure. And to keep it all dead simple, I declare the complex data structure as a reference to start with. That way there are no extra copies being made passing around the data structure is exactly the same as using it, and I don't fall out of practice with dereferencing.

      It is indeed a bit of a climb, but once you get around to figuring out references, everything becomes easier :)