News for hackers. Stuff that matters.
Re:Finally, a Makefile formatter (50 years overdue) by pjmlp on Sunday June 22, 2025 @12:16PM (#44348102)
I will remember that the next time some voices an opinion at the sports bar.
Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Sunday June 22, 2025 @04:15PM (#44349918)
Remember, you cannot criticize (even though it was not it) unless you have something to show up! Next time someone provides a critique to an article, we have to make sure to let them know it is wrong to criticize unless they have written an article themselves on the same topic.

FWIW it really was just about his comment, and I made two statements: Perl is faster than Python, and that Perl is especially good for string manipulation.

Re:Finally, a Makefile formatter (50 years overdue) by exe34 on Sunday June 22, 2025 @05:25PM (#44350417)
For somebody who does not mind that the author chose python, you defended your opinions robustly.
Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Sunday June 22, 2025 @09:57PM (#44351864)
What opinions? Perl is faster than Python regardless of my opinion, and it is great for string manipulation, which again, is not a matter of opinion. It really is the case.

None of it has anything to do with the author choosing Python. How many times do I need to repeat myself?

You are the one who are being extremely defensive about it and making it seem like I give a damn about whether or not this project is written in Python. I told you I do not care. I was responding to your comment. No matter how much you insist on my reply (to you) being a criticism of the author or his project, it will not make it so.

I am done talking to you, you are seeing ghosts.

Re:Finally, a Makefile formatter (50 years overdue) by zahlman on Monday June 23, 2025 @07:06AM (#44354417)
> is faster than

This is incoherent no matter what two programming languages you are talking about. It's like trying to say the road is fast, as opposed to the car.

But in practice, for anything where performance matters, Perl and Python are effectively just convenient ways to wrap a C inner loop anyway. I don't just mean gluing to some third-party library, either. I mean something inside the interpreter. Once you've built the state machine for the regex, the language bytecode doesn't matter any more.

Which is why it's dozens of times slower in both Python and Perl to run a do-nothing for loop than to iterate through a string with a dummy regex, or to use built-ins to search for a character, etc. (Or to create the string in the first place.)

> it is great for string manipulation, which again, is not a matter of opinion

This is incoherent no matter what programming language you are talking about. Of course it's a matter of opinion. Other people aren't going to like the same syntax you do.

Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Monday June 23, 2025 @09:15AM (#44355509)
> This is incoherent no matter what two programming languages you are talking about.

Yet everyone talks about performance when it comes to programming languages. Why? And what does coherence have anything to do with it?

Plus I explained what I meant by that, there is a huge difference in the startup time of Perl and Python, for one, and you can check benchmarks. The implementation of the two languages are not identical. If they are not identical, there must be a difference in performance one way or another, I assume.

> This is incoherent no matter what programming language you are talking about. Of course it's a matter of opinion. Other people aren't going to like the same syntax you do.

I do not think anyone is going to argue that Brainfuck was made with easy string manipulation in mind, or Forth.

The point is that Perl helps you manipulate strings with relative ease. Assuming you know the language, yeah.

In fact, please read other comments, because I have already said this: "For the 100th time, I was responding to "[...] python and it is easy to do string manipulation with.".". It is easy to do so in Python, but even easier (and faster) to do on Perl. In both cases there is an assumption of knowing the language, and I thought that goes without saying.

I said nothing about liking the syntax or whatever you are trying to read into it. It is easy to do string manipulation, regardless of your like or dislike of the syntax. Thus, not an opinion.

Re:Finally, a Makefile formatter (50 years overdue) by zahlman on Monday June 23, 2025 @11:25AM (#44356753)
> Yet everyone talks about performance when it comes to programming languages. Why?

I know this may come as a shock to the average HN reader, but most people do not think very clearly. Even programmers. And among those who do, it is quite rare that people speak precisely without putting in considerable effort.

> but even easier (and faster) to do on Perl.

You have no objective way to substantiate this claim (because such cannot exist), therefore it is in fact a matter of opinion.

Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Monday June 23, 2025 @04:08PM (#44359539)
Oh but there is an objective way to substantiate this claim. How familiar are you with Perl? It will not work (to convince you) if you do not know the language, you need to be quite familiar with it. There are extremely short ways to do string manipulation, for one, think 3 characters short. So, assuming you know Perl, it is definitely easier AND faster, than say, Python.

Trivial example:

Replace all numbers in a string:

Perl:

  $string =~ s/\d+/NUM/g;
Python:

  import re
  string = re.sub(r'\d+', 'NUM', string)
Perl's design history is text processing as a first-class goal. It has syntax-level efficiency, and expressive power (e.g. s///e, tr///, inline regex flags, etc.). Do you want me to go on? These are all objective ways to substantiate the claims I made.

Perl is implemented in C with a runtime that aggressively optimizes text processing. The core primitives such as split, join, substr, index, s///, etc.) are tight wrappers around C functions with minimal object overhead. In Python, even simple string manipulations go through Python's object system, and in Python strings are immutable, so every manipulation creates a new string object, which incurs extra memory allocation and garbage collection.

Perl is typically 30-80% faster in similar regex-heavy workloads because there is no import overhead, internal opcode dispatch for regex, and no allocation of new strings until match is confirmed.

Shall I go on?

Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Tuesday June 24, 2025 @10:21AM (#44366580)
Using the down-vote button is such an absurd way to disagree. So whoever you may be, you should engage in a conversation. With what do you disagree, and why?
Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Wednesday June 25, 2025 @06:23PM (#44382327)
FYI:

  [johnisgood@arch regex]$ hyperfine 'perl regex_test.pl' 'python3 regex_test.py'
  Benchmark 1: perl regex_test.pl
    Time (mean ± σ):      1.807 s ±  0.028 s    [User: 1.752 s, System: 0.054 s]
    Range (min … max):    1.780 s …  1.857 s    10 runs

  Benchmark 2: python3 regex_test.py
    Time (mean ± σ):      3.316 s ±  0.230 s    [User: 3.246 s, System: 0.069 s]
    Range (min … max):    3.052 s …  3.858 s    10 runs

  Summary
    perl regex_test.pl ran
      1.84 ± 0.13 times faster than python3 regex_test.py
This is for a very simple script!

You know why?

Because Perl was practically designed for text processing and regex.

It has:

- A regex engine that's deeply integrated and highly optimized.

- Less overhead (no interpreter startup, minimal memory structures).

- Simpler string substitution and less abstraction.

Seriously, it is not a matter of opinion.

I hope you are convinced now.

In case you are not, let me know, I will let you in on a lot of great details. :)

Re:Finally, a Makefile formatter (50 years overdue) by exe34 on Monday June 23, 2025 @10:26AM (#44356134)
Oh you're still here, I thought you were done 5 times already. All I said was "it is easy to do string manipulation with", not it's the absolute best thing ever and the fastest at everything!
Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Monday June 23, 2025 @04:08PM (#44359536)
Yeah, you are everywhere, too. I am done talking to you, however, so this was the last response you have gotten from me.
Re:Finally, a Makefile formatter (50 years overdue) by exe34 on Tuesday June 24, 2025 @12:36PM (#44368032)
I don't come here for the essays about things I'm not interested in, thanks!
Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Wednesday June 25, 2025 @04:44AM (#44374991)
So you were not interested in it at all, all you wanted to express was a "You are wrong, I'm right, kthxbai"? Cool, another reason to avoid you. :D
Re:Finally, a Makefile formatter (50 years overdue) by exe34 on Wednesday June 25, 2025 @04:50AM (#44375022)
What exactly did I say that was wrong?
Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Wednesday June 25, 2025 @05:00AM (#44375085)
That quote was directed at me, by you. :P If you are interested in why I claimed what I claimed, you would read my reasoning. If you are not interested, that is fair enough, too. It does not matter much in particular.
Re:Finally, a Makefile formatter (50 years overdue) by exe34 on Wednesday June 25, 2025 @06:22AM (#44375607)
Yes, what I wrote was "Presumably because the author is comfortable with python and it is easy to do string manipulation with."

I'm still not sure why this got you so involved.

Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Wednesday June 25, 2025 @06:58AM (#44375813)
It is not that specific comment that got me involved.

As I have said a couple of times, it is fair enough that he is comfortable with Python or that he decided to use it for whatever reasons.

At any rate, I cannot come back to this thread anymore. :P

Re:Finally, a Makefile formatter (50 years overdue) by exe34 on Wednesday June 25, 2025 @08:15AM (#44376394)
That's a shame, this thread has been fascinating.
Re:Finally, a Makefile formatter (50 years overdue) by johnisgood on Wednesday June 25, 2025 @11:03AM (#44378168)
Sorry to disappoint! Next time. :D
Re:Finally, a Makefile formatter (50 years overdue) by exe34 on Wednesday June 25, 2025 @12:20PM (#44379016)
I'm sure you'll turn up again soon!