Hacker News new | ask | show | jobs
by _rrnv 2514 days ago
Consider this: Perl codebase is reaching perfection and no longer needs releases. After this, we get eternal Perl ;)
6 comments

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.

Autovivication 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.

FWIW, 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.

I 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.
It'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).
Out of interest, what do you feel is holding back Perl 6 from being a replacement for Perl 5 in your usecases?
Performance. 5 times slower than Ruby when parsing a log file with a simple regex is a non-starter.
> No autovivification?

Wow, thanks. I had been looking for this word to explain what happens in awk. Now I know what it's called!

>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.

I 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.
Or you could use functional persistent data structures for your stdlib types, like Erlang’s map. (Essentially, “reference on read, amortized copy on write.”)
Pretty sure if perl5 had only had multi-dimensional arrays it would still rule the world.
Didn't perl always have multi-dimensional arrays?

Just the syntax sugar for them is more recent.

Not 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.
hmm, 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.
This isn't as much of a joke as it sounds.

I've just written a utility I needed in Perl. I tend to think about some things in the long term, and this utility is something I want to be able to run 10 years from now.

[it's a concistency checker (hasher) for file archives, to find out if the bits in your copy are really the ones you put there, important for multi-GB photo archives — see https://github.com/jwr/ccheck]

I do most of my programming in Clojure, which has excellent backwards compatibility and takes a long-term perspective. I still run some unmodified Clojure code from 8 years ago. And yet for really long term stuff, I would much rather write it in Perl. It has been around for a very long time, is very mature, and can be expected to last, even if it isn't the latest fashionable trend.

Take a look at the various programming languages+environments around you: there will be very few where you can expect to be able to run your code even 2-3 years from now, much less decades later.

These are for third-party packages though, Perl might be perfect but the rest of the software world not so much... That dwindling number of submissions not only means that new libraries are not being integrated as fast as they should but also, and perhaps more importantly, existing libraries are not updated.

It's pretty sad too because I distinctly remember that one of the main selling points of Perl when I started using it in the early 2000's was that CPAN was more complete and diverse than any other scripting language out there.

aka Perl 6
Perl Nukem Forever?
Wait, what? Perl 6 is real, released and essentially stable. The ecosystem for the language is also evolving at a good pace.
>Perl 6 is real, released and essentially stable.

So is Duke Nukem Forever.

we waited for them since the very beginning of the millenium, i played with both and here is the difference: DNF is very desapointed and is not the revolution i expected. Perl6 is a game changer and push the idea of "scripting" way beyond i was imagining it (and i played with a lot of langages)
Perl 6 is more than a scripting language. It clearly has elements of a very general high level language that can scale to large program sizes.
It seems that the most advanced implementation doesn't yet have all the Perl 6 features in the spec..?
The written specification wasn't being kept in sync with the implementation and has been relegated to the status of 'design document'. The language is nowadays defined and versioned through its test suite, and there have been two releases (v6.c in Dec 2015 and v6.d in Nov 2018).
”Don’t have time to Perl with myself”
Even enternal security?
This is exactly the same reason that they stopped updating Microsoft DOS -- they achieved perfection. That or it become obsolete. I guess it depends on to what degree one is nostalgic and to what degree one needs to keep their skills up to date.