Live data from Hacker News

Perl first commit: a “replacement” for Awk and sed

github.com

51–60 of 261 posts

Re: Perl first commit: a “replacement” for Awk and sed

#51
post #2

The funny thing is Perl is now arguably more obsolete than sed and awk.

My first thought when I saw this was that I'd like to see some stats on use of the three. I personally use sed and awk regularly and never perl, but I have no idea what is typical. I have a feeling that most people (amongst those who may have a use case) don't use any of them.

Ditto - I use sed/awk daily, but I never write Perl any more (though I do use older bash scripts that call Perl under the hood).

I'm still comfortable recommending people learn sed/awk but I don't think I'd recommend learning Perl* now. It sits in an awkward spot between the simplicity of GNU utils and the expressivity of a scripting language, but doesn't do either of those things better than the equivalent sed/Python etc.

FWIW I still write Bash scripts on a daily basis, too.

* that's no comment on Raku, which I consider a separate beast.

Re: Perl first commit: a “replacement” for Awk and sed

#52

Earlier quoted context omitted.

My first thought when I saw this was that I'd like to see some stats on use of the three. I personally use sed and awk regularly and never perl, but I have no idea what is typical. I have a feeling that most people (amongst those who may have a use case) don't use any of them.

Yep I responded in another comment but I use sed and awk almost daily but I never learned Perl. It's actually something that could be useful in my current role though -- is there a particularly good intro to Perl in 2023 that I might want to look at?

The Perl man pages are really good! Start with "man perlintro" and then look at whatever sections in the "man perl" table of contents fit your needs.

A lot of the tutorials online in my opinion are overbaked and written for people writing large OO projects using a lot of scaffolding. But the man pages were originally targeted at sed and awk users in your position.

Re: Perl first commit: a “replacement” for Awk and sed

#53
post #42

Earlier quoted context omitted.

> Automation was glued together in one of these with a series of grep, awk, sed, ls, test, commands glued together. Anything more complicated was written in C and called from one of these things. This doesn't sound that horrific to me. It's the classic Unix approach of building small tools that do one thing well, and composing them in novel ways to solve problems. For any problem that can't be solved this way you wri…

I don’t think you’ve seen the kind of scripts the person you are responding to is talking about. I have, and mentioned one lower down in the comments. Unix philosophy was great but does not scale well in terms of maintainability or efficiency. Invoking processes over and over again loops is godawful slow. And the horror of complicated shell scripts is legendary.

I certainly have, and might have written a few of those myself.

But this doesn't make this approach inherently wrong or obsolete. The programmer is wrong for trying to use the tools beyond their capabilities. Where that line is drawn is subjective, as is the concept of maintainability, but if you feel that you're struggling to accomplish something, and that it's becoming a chore to maintain, the path forward is choosing a more capable tool, like a programming language.

Re: Perl first commit: a “replacement” for Awk and sed

#54
The next time I need awk or sed, whatever I end up writing I’ll submit to chat gpt and ask it to rewrite it in perl so I can compare. I’m curious because so many people (well, enough people anyway) speak so highly of perl’s text processing capabilities. If it’s such a great tool, then I want to use it too.

Edit: one plus is that perl is as ubiquitous as awk and sed. It was there the whole time and I didn’t even realize it!

Re: Perl first commit: a “replacement” for Awk and sed

#55
post #42

When perl came out we were living in horrific times. You had the choice of either Bourne, C or Korn shell. Automation was glued together in one of these with a series of grep, awk, sed, ls, test, commands glued together. Anything more complicated was written in C and called from one of these things. Perl in one stroke collapsed the programming of C, text manipulation, the capabilities of all of the Unix utilities, an…

> Automation was glued together in one of these with a series of grep, awk, sed, ls, test, commands glued together. Anything more complicated was written in C and called from one of these things. This doesn't sound that horrific to me. It's the classic Unix approach of building small tools that do one thing well, and composing them in novel ways to solve problems. For any problem that can't be solved this way you wri…

At the time, before everything became Linux, all these tools and the shells used to glue them together were an incoherent mess. Was your glue sh, ksh, csh, tcsh, bash or something uncommon like zsh? Did your grep, awk and sed use the same regexp syntax as your text editor? Single letter command line options, all meaning something different to each tool. Dozens of domain specific languages (shells, awk, sed etc.) meant dozens to learn and keep in your head. And you needed it in your head, because finding the information you needed in the massive single document man file reference was a pain because hypertext links had not been invented yet (well, probably in Emacs, which was another tool like Perl that people used to avoid the command line nightmare).

Re: Perl first commit: a “replacement” for Awk and sed

#56

I know people dump on Perl all the time, I know I do. But it was a critical part of computing history. Perl did a tremendous job of bridging the gap between shell commands and shell scripts and “big languages”. Way back in the early 90’s I took a complicated shell script that took about 2 hours to run this huge text processing job , rewrote it in Perl and it took about 20 seconds, and was more maintainable to boot. I…

>> What killed it were the never ending eccentricities you ran into, endless foot guns, and of course Perl 6 never being delivered.

>> But it really was the weird shit that did it in.

The current state of Perl 5 for Python fans: ----

Perl 5: I'm not dead!

TIOBE: 'Ere! 'E says 'e's not dead!

Internet: Yes he is.

Perl 5: I'm not!

TIOBE: 'E isn't?

Internet: Well... he will be soon-- he's very ill...

Perl 5: I'm getting better!

Internet: No you're not, you'll be stone dead in a moment.

TIOBE: I can't take 'im off like that! It's against regulations!

Perl 5: I don't want to go off the chart....

Internet: Oh, don't be such a baby.

TIOBE: I can't take 'im off....

Perl 5: I feel fine!

Internet: Well, do us a favor...

TIOBE: I can't!

Internet: Can you hang around a couple of minutes? He won't be long...

TIOBE: No, gotta get to Reddit, they lost nine today.

Internet: Well, when's your next round?

TIOBE: Next year.

Perl 5: I think I'll go for a walk....

Internet: You're not fooling anyone, you know-- (to TIOBE) Look, isn't there something you can do...?

Perl 5: I feel happy! I feel happy!

----

But seriously, Perl is not dead yet.

It is usually installed by default on most Unix and Linux systems.

It also rides along with most MinGW-based toolkits like Git for Windows. If you do software development, there is a good chance you might have Perl installed and not even know it.

If you are on a Linux or Unix system try running 'perl --version' to see what version you have installed. I would be very surprised if it is not there.

Some people like to make fun of it despite its wide-spread use and utility. Most of them probably know little to nothing about Perl and have not written or maintained any Perl code. There is a good chance that they are using Perl code without knowing it.

Re: Perl first commit: a “replacement” for Awk and sed

#57
post #53

Earlier quoted context omitted.

I don’t think you’ve seen the kind of scripts the person you are responding to is talking about. I have, and mentioned one lower down in the comments. Unix philosophy was great but does not scale well in terms of maintainability or efficiency. Invoking processes over and over again loops is godawful slow. And the horror of complicated shell scripts is legendary.

I certainly have, and might have written a few of those myself. But this doesn't make this approach inherently wrong or obsolete. The programmer is wrong for trying to use the tools beyond their capabilities. Where that line is drawn is subjective, as is the concept of maintainability, but if you feel that you're struggling to accomplish something, and that it's becoming a chore to maintain, the path forward is choos…

I think we are actually mostly in agreement there then.

Perl was invented because the gap from shell to more capable languages was (and is) really big. Languages like Python and Ruby didn’t exist yet, and Perl had a really, really strong sweet spot in text processing.

Re: Perl first commit: a “replacement” for Awk and sed

#58
Perl is/was fantastic and awful. An excellent alternative to grep, awk, sed, ls, test.

A lot of the greatness of Perl came from writings of Larry Wall, Mark Jason Dominus, Randal Schwartz, Tom Christiansen. There is so much wisdom to be gained from all their code and documentation.

Re: Perl first commit: a “replacement” for Awk and sed

#59

I know people dump on Perl all the time, I know I do. But it was a critical part of computing history. Perl did a tremendous job of bridging the gap between shell commands and shell scripts and “big languages”. Way back in the early 90’s I took a complicated shell script that took about 2 hours to run this huge text processing job , rewrote it in Perl and it took about 20 seconds, and was more maintainable to boot. I…

>> What killed it were the never ending eccentricities you ran into, endless foot guns, and of course Perl 6 never being delivered. >> But it really was the weird shit that did it in. The current state of Perl 5 for Python fans: ---- Perl 5: I'm not dead! TIOBE: 'Ere! 'E says 'e's not dead! Internet: Yes he is. Perl 5: I'm not! TIOBE: 'E isn't? Internet: Well... he will be soon-- he's very ill... Perl 5: I'm getting…

My version of “dead” here means rarely used for new development. I relied on it for years, and even I finally gave up and do script level work in Python instead. Particularly because the many CPAN dependencies are aging and starting to rot from neglect.

Re: Perl first commit: a “replacement” for Awk and sed

#60

Earlier quoted context omitted.

Yep I responded in another comment but I use sed and awk almost daily but I never learned Perl. It's actually something that could be useful in my current role though -- is there a particularly good intro to Perl in 2023 that I might want to look at?

The Perl man pages are really good! Start with "man perlintro" and then look at whatever sections in the "man perl" table of contents fit your needs. A lot of the tutorials online in my opinion are overbaked and written for people writing large OO projects using a lot of scaffolding. But the man pages were originally targeted at sed and awk users in your position.

Sounds perfect, thanks!
Post reply on HN