Live data from Hacker News

Ask HN: Should I learn Awk or Perl? Or is that a bad question?

news.ycombinator.com

31–37 of 37 posts

Re: Ask HN: Should I learn Awk or Perl? Or is that a bad question?

#31
post #21
post #14

Earlier quoted context omitted.

This is good insight. Limits are often built into programming languages. Java is all about the limits. TS's selling point is literally the limits. As well as every opinionated language. I wonder if AI will make limitless languages easier to work with and maintain.

I'm not against limits in programming languages. They help to reduce the complexity that have to be managed. Limited languages are suitable for those that are willing to manage only so much. That's why Java has no "goto". But Perl does offer "goto". Why? Because Larry Wall built Perl for himself, and he wanted the most powerful tool that he could conceive. That's exactly what Perl is. And I accept that, and I really…

You can also break from a loop from a subroutine.

  sub test() {last unless $_}
  for (1, 2, 0, 3) {
    print "$_\n";
    test;
  }
  // 1 2 0
I miss it :(

Re: Ask HN: Should I learn Awk or Perl? Or is that a bad question?

#32
post #30
post #13

The case for Perl is just that it has no limits. You will never run out of tool if you go with Perl. That is what, I believe, makes the investment worthwhile. Why Perl gets such a bad rap, then? I'll tell you. I've used Perl for almost 30 years now, and I've never found any limits in the tool. This means every limit I found was _mine_. Many programmers feel bad when they find their own limits, but it doesn't have to…

My reason to break up with Perl was the lack of garbage collection and then later the lack of types and then later 6. I don’t think investing in it is wise when you can invest in something more relevant. Although there’s barely anything that covers the subj as much as Perl, which is a shame on us all. A programming language that requires an import or two to dig through a file is degenerate. Old languages understood w…

There are two types of programming, and each has its own definition of "relevant": new programming, with its preference for ready-made components to reduce complexity, and old-time creative programming, which usually was about the creation of new things.

The "creation" part is key. Perl is a tool for "easy creation", for creators that want to be more productive. This is what Larry Wall wanted.

This is why Perl is good for prototyping. You "create" the prototype, and then you "translate" it to something else.

Perl is quite relevant for me, but I say this as a creator.

Re: Ask HN: Should I learn Awk or Perl? Or is that a bad question?

#33
post #30

Earlier quoted context omitted.

My reason to break up with Perl was the lack of garbage collection and then later the lack of types and then later 6. I don’t think investing in it is wise when you can invest in something more relevant. Although there’s barely anything that covers the subj as much as Perl, which is a shame on us all. A programming language that requires an import or two to dig through a file is degenerate. Old languages understood w…

There are two types of programming, and each has its own definition of "relevant": new programming, with its preference for ready-made components to reduce complexity, and old-time creative programming, which usually was about the creation of new things. The "creation" part is key. Perl is a tool for "easy creation", for creators that want to be more productive. This is what Larry Wall wanted. This is why Perl is goo…

To know more about creators and their tools, I recommend:

- "Programming is (should be) fun!", by Gerald Jay Sussman. https://m.youtube.com/watch?v=2MYzvQ1v8Ww

- "On Writing", by Stephen King. Just the chapter "Toolbox".

Re: Ask HN: Should I learn Awk or Perl? Or is that a bad question?

#34
post #30

Earlier quoted context omitted.

My reason to break up with Perl was the lack of garbage collection and then later the lack of types and then later 6. I don’t think investing in it is wise when you can invest in something more relevant. Although there’s barely anything that covers the subj as much as Perl, which is a shame on us all. A programming language that requires an import or two to dig through a file is degenerate. Old languages understood w…

There are two types of programming, and each has its own definition of "relevant": new programming, with its preference for ready-made components to reduce complexity, and old-time creative programming, which usually was about the creation of new things. The "creation" part is key. Perl is a tool for "easy creation", for creators that want to be more productive. This is what Larry Wall wanted. This is why Perl is goo…

I'm a practical man, for me it's just n_loc difference and more useful imlicitness (and the listed downsides). Not sure if I can understand this "creation" part, even as a former Perl-ist. I think you can turn any language into Perl, it just happens that their core beliefs are incompatible with its ways.

For example, I can easily imagine something like this:

  import 'use-perl'

  while (await ls_lr('./*.txt')) {
    while (await read_lines($filename)) {
      print($ln, $line)
But it's not idiomatic as it uses awful implicit iterators and hideous globals. This conflict is purely dogmatic and doesn't need special syntax, for the most part.

Re: Ask HN: Should I learn Awk or Perl? Or is that a bad question?

#35
post #9

How much time do you want to invest ? Perl is more powerful but learning and remembering all (or a sufficiently more powerful superset of awk's capabilities) of it is going to take time. The peculiarities of its syntax is certainly not a small set. All of awk on the other hand needs about 2 hours, if you have done some programming before.

>> Perl is more powerful but learning and remembering all (or a sufficiently more powerful superset of awk's capabilities) of it is going to take time. The peculiarities of its syntax is certainly not a small set. I disagree. Perl's syntax is easy to learn for anyone who has used C-style syntax as found in C, C++, Java, Javascript, or C#: https://perldoc.perl.org/perlintro Perl's syntax is more similar to AWK and C-s…

Its OK to disagree.

I am quite comfortable with C and C++ and still find it hard to hold all of Perl and its operators and naming rules in my head, to keep $s, @, % and .(dot) and quotes etc straight. Granted it makes types more obvious than say Python.

AWK is smaller. There are fewer things to remember.

Perhaps a good comparison would be the size of a Perl pocket guide and a AWK pocket guide. Perl and Python are much bigger subsets of AWK.

Re: Ask HN: Should I learn Awk or Perl? Or is that a bad question?

#36

Perl is far more capable than awk and more portable. The issue with awk is that there are multiple non-interoperable implementations: https://en.wikipedia.org/wiki/AWK#Versions_and_implementatio... https://stackoverflow.com/questions/40409632/what-is-the-dif... This makes awk scripts less portable than other text processing tools. awk is also not extensible--it can be awkward (heh) to adapt it to some problems and bi…

> but there is a reason why it was installed on all Unix and Linux systems by default

AWK has that one covered fair and square, even BusyBox has AWk.

Re: Ask HN: Should I learn Awk or Perl? Or is that a bad question?

#37
post #34

Earlier quoted context omitted.

There are two types of programming, and each has its own definition of "relevant": new programming, with its preference for ready-made components to reduce complexity, and old-time creative programming, which usually was about the creation of new things. The "creation" part is key. Perl is a tool for "easy creation", for creators that want to be more productive. This is what Larry Wall wanted. This is why Perl is goo…

I'm a practical man, for me it's just n_loc difference and more useful imlicitness (and the listed downsides). Not sure if I can understand this "creation" part, even as a former Perl-ist. I think you can turn any language into Perl, it just happens that their core beliefs are incompatible with its ways. For example, I can easily imagine something like this: import 'use-perl' while (await ls_lr('./*.txt')) { while (a…

The "creative" part is all decisions to be made before coding: architecture, design, modularization, algorithms, APIs, etc.

If I am in charge of those decisions, I can use Perl to build a prototype, to validate the solution I am creating.

But if I don't decide anything, my job is to code whatever. No chance for me to be creative.

Most quirks of Perl are there to make the construction of prototypes easier and faster.

Post reply on HN