4 ms·
A consideration to you: You spent 4 years of learning Perl, 4 years in which you likely also massively improved your skills as a programmer, regardless of the
by Mithaldu 12y ago
A consideration to you:
You spent 4 years of learning Perl, 4 years in which you likely also massively improved your skills as a programmer, regardless of the Perl angle. Then you went to Python, bringing in your programmer experience, probably started off with a good book and had a much happier time.
So, do challenge yourself and ponder how much of that come from having spent 4 years programming, and how much from actual differences in the languages?
- ghshephard 12y agoIt's an interesting perspective, but, seriously - for the life of me, I struggled every time I wanted to declare/parse/initialize an AoH or HoA on perl. And I'm not engaging in hyperbole when I said that my code was basically completely foreign to me a week after writing it. Obviously developers (which I am not), and people with more discipline and structure, and write eminently readable and maintainable perl code - but as my day job was network engineering, I was just looking for the lowest cost path to get the job done. I really did love CPAN though.
- kbenson 12y agoThat's interesting, because defining an AoH or HoA in Perl is almost identical to how you would do it in Javascript, which is to say it looks a lot like JSON. If it was the access and assignment semantics, the normal case is also fairly straightforward; use curly braces for hash/dict keys, square brackets for array indices. E.g. my %data = ( foo => [ { bar => 10, baz => 12 }, { bar => 20, baz => 13 }, { bar => 30, baz => 14 }, ], ); print $data{foo}[2]{bar}; # 30 push $data{foo}, { bar => 40, baz => 15 }; Given, using array and hash references with the built-in push,pop,shift,unshift,keys,values and each used to require some annoying dereferencing that could be confusing. Do you still find that confusing?
- ghshephard 12y agoI'll admit to not having looked at it for about 12 years, and, of course, I'm not saying I couldn't figure out after 2-3 minutes over looking over the pattern, but it just never flowed the way it did with Python for me. data ={} data['foo']= [ {'bar':10,'baz':12}, {'bar':20,'baz':13}, {'bar':30,'baz':14} ] print data['foo'][2]['bar'] data['foo'].append({'bar':40,'baz':15}) for x in data['foo']: print x['bar'] Maybe it had something to do with indices always being [] brackets and {} only being used to define the dict structure. Or maybe it got easier sometime in the last 12 years? Or, maybe you could onto something, and having come pre-primed with knowledge hashes/arrays, I just picked up python more quickly. Anyways, it was just a personal story told as well as I could remember it.