Live data from Hacker News

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

github.com

221–230 of 261 posts

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

#221

Earlier quoted context omitted.

POSIX, right. POSIX sucks. POSIX anything is stuck 30 years ago. Nobody in 2023 really uses POSIX awk on some commercial UNIX like IBM AIX, they use GNU awk, that's the modern one I'm talking about https://www.gnu.org/software/gawk/manual/html_node/index.htm...

Well, I look at the POSIX standards whenever I want to write shell scripts and Makefiles that work on both Linux and macOS. Which, in my current role, is often enough that I am driven crazy by how far POSIX is behind GNU tooling...

Yep. Funny enough, Linux is actually not POSIX certified

POSIX was initially a bunch of the Unix vendors getting together in the 80s seeing a rise of incompatibility saying "this shit is crazy let's find something we can agree on" and then the conflicts of trying to still have a differentiating But Also compatible product. They knew that if they cannibalized themselves, IBM Novell and DEC were there to snatch up the customers

As a result, POSIX was intentionally kneecapped by all the players but not enough to make it completely worthless.

By the 2010s I decided to simply ignore it and if something breaks on FreeBSD or whatever, make the decision then whether to support it or not. Mostly it's platform testing at the top and then subbing the gnu version of things and bailing out if it's not there.

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

#222
post #206

Earlier quoted context omitted.

>> what advantage does Perl retain? Ubiquity, speed, and conciseness. Perl is usually installed by default on Linux and Unix systems. Ruby might be there, it depends. Perl is faster than Ruby. Ruby has been one of the slower scripting languages. But Ruby has been working on performance improvements in the past few releases. I have not seen any benchmarks of the current Perl versus the current Ruby, so this may have c…

I don't know about conciseness. Ruby excels here. As for speed it's useful to distinguish between startup and runtime.

>> As for speed it's useful to distinguish between startup and runtime.

The JVM would like a word. (It has slow startup, but can be very fast at runtime due to JIT optimization and cacheing.)

Scripts should start and run quickly.

Ruby has historically been fairly slow which is why Ruby 3 focused heavily on performance. It has been improving a lot, but I have not seen any benchmarks against other programming languages.

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

#223
post #207
post #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 reali…

This sounds interesting! The main reason I moved to perl instead of sed or AWK is for better control. Shell scripts don’t differentiate between variables and data (anyone else still having nightmares from trying to escape quotes and meta chars in a shell?). Perl gives you all the simple features from sed or AWK and adds useful (maintainable) foreach iterators, arrays, hashes, etc. Recommend using Strict mode if you a…

> anyone else still having nightmares from trying to escape quotes and meta chars in a shell?

This was a major reason I downloaded Perl 1.0 off Usenet in 1987.[1]

[1]https://news.ycombinator.com/item?id=36657782

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

#224
post #215
post #177

Earlier quoted context omitted.

"Minimal Perl" by Tim Maher is unrivaled for this.

Thank you for mentioning that book - I'm very interested in how perl can replace awk and sed and even grep(!) - I use grep multiple times a day, awk maybe a few times a week, and sed very rarely. I think I'm in the target demographic for this :)

The book constains Perl one-liner-style equivalents of these UNIX utilities which you can just drop into your bin directory.

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

#225
post #213
post #207

Earlier quoted context omitted.

This sounds interesting! The main reason I moved to perl instead of sed or AWK is for better control. Shell scripts don’t differentiate between variables and data (anyone else still having nightmares from trying to escape quotes and meta chars in a shell?). Perl gives you all the simple features from sed or AWK and adds useful (maintainable) foreach iterators, arrays, hashes, etc. Recommend using Strict mode if you a…

Thank you for the tip re: strict! Escaping - that's definitely a sore point. I feel like I get tripped up by embedded double quotes way too often - does perl have a good way to handle them?

From 'man perlop':

           Customary  Generic        Meaning        Interpolates
               ''       q{}          Literal             no
               ""      qq{}          Literal             yes
--

where {} can be any bracket pair.

   my $string1 = q;
   my $string2 = qq;

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

#226
post #206

Earlier quoted context omitted.

I don't know about conciseness. Ruby excels here. As for speed it's useful to distinguish between startup and runtime.

>> As for speed it's useful to distinguish between startup and runtime. The JVM would like a word. (It has slow startup, but can be very fast at runtime due to JIT optimization and cacheing.) Scripts should start and run quickly. Ruby has historically been fairly slow which is why Ruby 3 focused heavily on performance. It has been improving a lot, but I have not seen any benchmarks against other programming languages…

The thing to remember here is that speed is relative. I haven't checked but Ruby 3 is probably faster than Perl 5.0. For most scripting purposes on modern hardware Ruby is plenty fast enough. Whilst there may may be marginal speed differences between Perl, Ruby and Python the differnce is insignificant.

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

#227

" Congratulations. You aren't running Eunice. " I still remember seeing this line from the configure script scroll by.. Made me curious what Eunice was, which was harder than it might seem, given that this was before the web and any search engines.. (and yes, it turns out Eunice was a unix-ish environment on VAX/VMS)

Yep, good times!

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

#228
post #162

Earlier quoted context omitted.

Memory and CPU efficiency, since most systems were memory constrained. My first server had 128MB of RAM...

> My first server had 128MB of RAM Whippersnappers! :D The first big iron I had the luck to work with was an IBM 3090 , essentially a gift from IBM, it handled the university entrance exams of the entire country of some ten million people and it had 64 MB of RAM. (It was also the first computer in Hungary permanently connected to the Internet via a leased line to Austria so it had an Austrian IP address. Hungary didn…

Shades of the Monty Python sketch here, but the following is true...

4MB?!?

My first encounter with IBM kit was a, er, darn I'm not sure cuz I'm getting old, but I think it was a 4300? Not big iron in some senses, but still with a box that was something like 6-8 feet long iirc and definitely several feet wide and high. (And a bank of about 6-8 tape decks, each as tall as me, and two disk units, each the size of a washing machine, and so on.)

Its RAM? A massive 1 MB.

That IBM kit was the heart of the super new expensive upgrade in 1980 that cost something like 5-10 million pounds iirc to build, including a brand new building to house it and a team of programmers.

The older setup, which is where I was until its last days, was an ICL system that was expanded at the end of its life to a whopping 48KB -- yes, KB -- of RAM.

And that kit ran all the systems, internal (payroll, accounting, etc., etc.) and external (sales etc.) for the largest car dealership in the UK.

128MB? 4MB? Even 1MB? That was an unimaginably insanely large amount of RAM!

(Yes, it was very weird to be working with this physically enormous setup, and dealing with keeping it all cool enough not to halt for a half hour or so, through super human efforts when the A/C broke down, when the likes of PETs, Sinclair Z80s, and Acorn Atoms were a thing...)

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

#229

Earlier quoted context omitted.

It also seems like the core perl developers did not want to acknowledge the importance of web/html. They did not add support for encoding/decoding html entities or URLs were added. No standard modules for this. No easy method of making html pages from a URL request besides running as CGI. This made perl lose to php which made it very easy to make a simple "Hello, world" page. php would never had any traction if perl…

Does Perl now support web development and if so, to what extent? Can you now do with Perl 5 what you can do with PHP?

Perl Mason does web templating similar to PHP:

http://www.masonhq.com/

For years Amazon.com used Perl Mason.

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

#230
post #224
post #215

Earlier quoted context omitted.

Thank you for mentioning that book - I'm very interested in how perl can replace awk and sed and even grep(!) - I use grep multiple times a day, awk maybe a few times a week, and sed very rarely. I think I'm in the target demographic for this :)

The book constains Perl one-liner-style equivalents of these UNIX utilities which you can just drop into your bin directory.

Cool, I'm in the market for that.
Post reply on HN