5 ms·
From a experienced linux sysadmin point of view perl5 is as good as it gets. I've been searching for alternatives for about 10 years now, at first because my n
by trabant00 7y ago
From a experienced linux sysadmin point of view perl5 is as good as it gets.
I've been searching for alternatives for about 10 years now, at first because my novice self was heaving headaches reading other people code and even my own. I hated perl but I hated everything else even more as I came to know them. No autovivification? Some assignments copy the data and some create references and you need to memorize the conventions of which does what? 3x to 10x lower performance? My program crashes because of white space? Fuck that! Back to perl5.
I'm sorry to say nothing can replace perl5 for me even now in 2019. I wish something would come along even if it takes years. We need alternatives and competition, perl5 will get too old at some point and 6 is... I don't even want to go there.
- mehrdadn 7y ago> No autovivification? Wow, thanks. I had been looking for this word to explain what happens in awk. Now I know what it's called!
- ajsnigrutin 7y agoIt's not perfect, but it does it job, and usually it's simpler/faster to write code than in some other langues (usually with the cost of worse readability).
- abacadaba 7y agoPretty sure if perl5 had only had multi-dimensional arrays it would still rule the world.
- VVertigo 7y agoDidn't perl always have multi-dimensional arrays? Just the syntax sugar for them is more recent.
- simcop2387 7y agoNot quite, references were introduced in perl 5, in perl 4 and earlier had a different method that wasn't quite multi-dimensional arrays but tried to behave that way. $hash{1,2,3} = 10; This actually ends up doing the following $hash{join($;, 1, 2, 3)} = 10; It builds up a single key from the list using the special variable $; as a separator to the elements. With perl 5 you gained the ability to make references which allow you to actually make multiple dimensions and to do it on arrays, not just hashes. $array[1][2][3] = 10; That also allows for more complicated data structures and much easier ways to iterate through the structures.
- abacadaba 7y agohmm, it's been 4-5 years since i really did any perl but i remember it being way more confusing than that. maybe i was just a noob.
- deleted 7y ago[deleted]
- jai_ 7y agoOut of interest, what do you feel is holding back Perl 6 from being a replacement for Perl 5 in your usecases?
- cutler 7y agoPerformance. 5 times slower than Ruby when parsing a log file with a simple regex is a non-starter.
- ImaCake 7y ago>Some assignments copy the data and some create references and you need to memorize the conventions of which does what? This is a nightmare for beginner coders trying to make sense of Pandas or R subsetting.
- bachmeier 7y agoI don't think there's any way to avoid that. You could always copy, but then you'd sacrifice performance. You could always make a reference, but then other parts of the language would become really complicated.
- derefr 7y agoOr you could use functional persistent data structures for your stdlib types, like Erlang’s map. (Essentially, “reference on read, amortized copy on write.”)
- SmirkingRevenge 7y agoAutovivication seemed like a great feature to me, back in the day, when I was getting started with Perl. Working with similar data structures in languages like Python always seemed like a chore. I had heard a few perl monks criticize it a bit, as an "end run around use strict", but I was kind of dismissive. It turns out, that's a really apt way to describe it. It basically tosses the niceties of use strict out the window, so long as its a hash. And sooo many things are hashes/hashrefs in Perl. The first time I wasted a day tracking down a bug that turned out to be a well hidden typo in a hash key assignment, changed my mind. Well... maybe the third time.
- joosters 7y agoFWIW, you can 'lock down' a hash so that reads or writes of non-existing keys will cause a fatal error. Not only does this stop autovivification on 'writes' to a hash, but it will also help catch typos in your code just reading from the hash: e.g. if you accidentally wrote $foo = $bar{Autovivication} instead of $foo = $bar{Autovivification} in your program, it will abort instead of returning an undefined value :) See Hash::Util for details.
- trabant00 7y agoI mention I am a linux sysadmin but I should have been clearer: I always use perl for <100 line scripts. Back when I started and in my peer group we made clear difference between programming and scripting. I never learned programming, I don't need to as that's not my job. I write small glue scripts and that's where perl shines and I see nothing else having any chance to replace it from what exists now.