[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sed:awk:perl::rock:paper:chainsaw [was Re: Using .XCompose]



On 2020-07-18 02:59, davidson wrote:
On Thu, 16 Jul 2020 Ajith R wrote:
On Thursday 16 July 2020 4:54:09 AM IST davidson wrote:

[snip]
   $ sed 'y/\xc2\xa0/%/' somefile

An off topic question: of sed, awk and perl, if I am to chose one to
learn, which would you suggest. I wanted to do some substitutions. I
read about them and decided on PERL because from what I understood,
it has better support for regular expressions and do almost
everything that sed and awk could do. Have I made the right
decision?

If your focus is regular expressions, then you should read "Mastering Regular Expressions", 3rd Edition:

https://www.oreilly.com/library/view/mastering-regular-expressions/0596528124/


The author compares and contrasts regular expression capabilities in various tools. I seem to recall that he puts Perl at the top of the heap, and notes that Perl compatible regular expressions (PCRE) are available via libraries in other programming languages.


I will also say that I have used Perl for 20+ years, and Perl has allowed me to expand my knowledge and skills tremendously. I have accomplished a lot of useful work with Perl.


As the Perl slogan goes, "There is more than one way to do it". Perl delivers.


Another slogan starts with "Perl makes easy things easy", but I have my doubts about the second half "makes hard things possible".


20 years ago, Moore's Law ruled. You bought a new Pentium computer every year and a half, and your Perl script ran faster.


Today, Amdahl's Law rules. You buy a new Core or Ryzen chip every year and a half and your Perl script runs at the same speed.


Perl is fundamentally a sequential programming language. Concurrent programming was bolted on with a library, and that library has a huge disclaimer:

    https://metacpan.org/pod/threads

    "WARNING

    The "interpreter-based threads" provided by Perl are not the fast,
    lightweight system for multitasking that one might expect or hope
    for. Threads are implemented in a way that make them easy to misuse.
    Few people know how to use them correctly or will be able to provide
    help.

    The use of interpreter-based threads in perl is officially
    discouraged."


Being the lazy, impatient, and over-proud Perl programmer that I am, I disregarded the above and have been working on a Perl library for multi-threaded flow-based programming. OMG. I don't know if I can or will succeed. It is the most difficult Perl code I have ever worked on.


I have experimented with Go in the past. I plan to start learning Erlang shortly.


David


Reply to: