Live data from Hacker News

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

github.com

201–210 of 261 posts

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

#202
The body of the op.crypt test is pretty neat. He is clearly excited about the perf optimization:

  # this evaluates entirely at compile time!
  if (crypt('uh','oh') eq 'ohPnjpYtoi1NU') {print "ok 1\n";} else {print "not ok 1\n";}

  # this doesn't.
  $uh = 'uh';
  if (crypt($uh,'oh') eq 'ohPnjpYtoi1NU') {print "ok 2\n";} else {print "not ok 2\n";}

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

#203

Earlier quoted context omitted.

Yes. It's comparative. The absolute value of Perl's readability, maintainability, and general intuitiveness is massively better than all comparable tools that existed when Perl came out. Perl is a massive improvement over those tools. If you have doubts, try writing a complicated production software stack in awk. Then hand it off to a coworker. One need not be irreplaceably good, if one is already beating the current…

Moreover, as often as people joke about the readability of Perl code, that's entirely a function of the developer. I've easily written tens of thousands of lines of Perl, and not a single person has complained about difficulty reading or maintaining that code. Why? Because I apply all the usual best practices for code hygiene that apply to any language. Frankly, I think most people are just repeating a meme they hear…

> that's entirely a function of the developer.

I would argue the same of sed/awk; you can write an unmaintainable mess, but you don't have to.

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

#204
post #174
post #35

Earlier quoted context omitted.

I make money off "old" systems; I'm spending time with Perl too. Lots of legacy systems out there.

Which languages are most common in these systems?

Well, I'm not sure about everywhere but, the work I'm finding is ASP3.0 (IIS6.0) and VB6 (more rare) also Perl and PHP. Many of these projects were started in the late 90s. They are internal systems (billing automation, internal work-tracking, custom "ERP"). Nothing exciting, just old shit that makes money in a non-tech business. I find the work on LI, and I show up when folk search for these olds skills. But I know a few others in this "maintenance" space. One just does legacy Java, one just does old Windows (NT4, 2000), etc. Generally we find work from each other.

Additionally, I think it's hard to enter the "Legacy" space. You have to un-learn some patterns, lots of: oh yea, we used to do this the hard way. The other bump is the documentation - the 1999 docs are buried under the 2009 docs which are decaying under the 2019 docs. The thing called ActiveRecord for example means like 99 things.

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

#205
post #165

Earlier quoted context omitted.

As a self-taught coder, I've experienced many times how highly skilled software engineers groan and sweat when they encounter shell scripts. I don't understand why, but it seems like people with a CS background are never really taught shell scripts and have come to irrationally fear them. It's sort of taboo. This results in weird behavior, such as writing a groovy (Java?) script for Jenkins to execute bazel in order…

> I've experienced many times how highly skilled software engineers groan and sweat when they encounter shell scripts. I don't understand why, but it seems like people with a CS background are never really taught shell scripts and have come to irrationally fear them. It's sort of taboo. It's not a lack of being "taught" shell scripts. It's the fact that shell programming constructs aren't well documented, your "stand…

Yea... "Well the script works fine in MY SYSTEM" was the most common issue with said scripts. Running across different versions of Linux was fraught with issues, much less any other operating system that could execute a shell script.

Of course this can happen with any language, especially as it ages and adds complexity.

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

#206
post #164

Earlier quoted context omitted.

Since Ruby took the best bits of Perl what advantage does Perl retain?

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

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

#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 are new to Perl. It gives good guardrails against silly mistakes like not declaring or misspelling a variables, or accessing strings or numbers that aren’t the correct datatype.

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

#208
post #164

Earlier quoted context omitted.

Since Ruby took the best bits of Perl what advantage does Perl retain?

I used Perl then Ruby as my main language for almost a decade each. These days, I don't really write Ruby anymore; I moved on to Elixir and never looked back. But I still find myself using Perl on the command line, in contexts where Awk or Sed would also make sense. Ruby never optimized for the one-liner case IMO.

I don't understand your last point. `ruby -e` has excellent parity with `perl -e`.

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

#209
post #173
post #167

Earlier quoted context omitted.

Unfortunately. Ruby should have been Perl's natural successor. Python is the VHS of scripting languages. For a start it doesn't have a decent answer to Perl or Ruby's one-liners. Then there's the crippled lambda implementation. Python is a sad case of worse is better.

> For a start it doesn't have a decent answer to Perl or Ruby's one-liners. This is by design. Readability is core to the design and philosophy of python. One liners are cool and fun to write, but trying to decipher someone else's incredibly dense bash or perl one-liner is absolutely awful.

The readability complaint usually comes from people who never took the time to grok the language and its idioms. At least give the user the option. Advocating a language based on what it denies you doesn't make sense. Why use a scriptig language at all if belt and braces is what you're looking for?

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

#210
post #77

Earlier quoted context omitted.

During a later period (early 2000's) Perl was the only scripting language with good Unicode support, including inside regular expressions, which was revolutionary at the time. There was so much cool stuff you could only do in Perl, and then like you say it all ran into the brick wall of Perl 6.

The brick wall of Perl 6 was itself a solution to an internal nightmare inside of core Perl development. Particularly around conflicts involving Tom Christensen, which caused no progress to be made on Perl 5.6.1 despite major bugs in 5.6.0. For example: my $x = 5 + 6; $x .= "0"; print $x + 5; # 16, not 115. The result in the year 2000 was a famous cup throwing incident by Jon Orwant. And Perl 6 was a plan to separate…

On the "cup throwing incident":

https://en.wikibooks.org/wiki/Raku_Programming/Perl_History#...

Post reply on HN