7 ms·
Perl seems to be fading away, but for a long time it was the obvious tool to use when your program got too big for a shell script. > Python, Go and so on need
by klodolph 5y ago
Perl seems to be fading away, but for a long time it was the obvious tool to use when your program got too big for a shell script.
> Python, Go and so on need more structure and often don't have quite as simple and convenient methods of doing various shell like things.
This is Perl's niche, or at least it was Perl's first niche before it started getting used for CGI. The things you'd do in a shell script are generally convenient in Perl too, the main inconvenient part is selecting from the many different ways to invoke a program in Perl, like system(), backticks, qx//, open(), etc.
Perl is also more commonly installed and has faster startup time than Python, in my experience.
- contingencies 5y agoperl 5 was great but it broke down as soon as you needed a depth or complexity of data structure. The number of times you had to man perldsc ... every single one had a different syntax for declaration and dereferencing ... AoAoHoHoAARGH!
- zengargoyle 5y ago$ perl -E 'my $f=[[{X=>{Y=>["FOO"]}}]]; say $f->[0][0]{X}{Y}[0];my $g=$f->[0][0]{X}{Y}; say $g->[0]' FOO FOO Seems pretty trivial.
- contingencies 5y agoYeah now try iterating. What used to get me is for some types $ is used only when de-referencing. It was terrible trying to track those errors down. Basically I loved perl but the language has a terrible design, inexcusable really. There was essentially no point in having types, it took all the worst parts of C and then reinvented them slightly differently with new syntax, twice per datatype. Glad to be rid of it.
- ryl00 5y agoI have the opposite problem... I find perl's data structures so ridiculously easy to write that I can quickly build up arrays of hashes of arrays of (ad infinitum) while in the "flow". Throw in the ability to actually get references to things, and control de-referencing of things, and I've never felt perl has stopped me (for better or worse!) from doing anything with data structures.
- lightbulbjim 5y agoRuby makes for a good “super shell” script too.
- boesboes 5y agoDefinitly. I've been replacing some of my more janky & complex bash scripts with ruby and it becomes a lot cleaner imo. Also, I recently 'discovered' Pathname, it takes away a lot of the pain of dealing with files and directories in ruby and allows for pretty clean code imo.
- viraptor 5y agoAnd if you're conflicted between thinking both this and "but go is nice and static and free of runtime", you can look at https://crystal-lang.org/ https://crystal-lang.org/ Ruby syntax with static compilation for your tools.
- VariableStar 5y agoYes, Perl is still used and it is fast and excellent for anything that becomes too big or complicated for a shell or awk script. As you write it is installed in the vast majority of *NIXes as default.
- ilyash 5y agoIt is now the niche of Next Generation Shell. Totally not humble and biased opinion... maybe. I'm the author. You are very welcome to make your own judgement - https://ngs-lang.org/ https://ngs-lang.org/