by TekMol · 5y ago · 0 comments
Whatever PHP does (I am not a language expert), they are doing it right. Whenever I write projects in PHP and think "If this approach is too slow, I will optimize it later", I get surprised like "WOW... it takes just a few milliseconds!".
Whenever I write projects in Python and think "This should not result in a noticeable workload", I get surprised like "Uhmm.. this takes seconds?".
Python the language is so much better than PHP. But the low performance of CPython is hard to swallow. In the context of answering web requests, there is no room for execution times of more than a few milliseconds. So as things are, Python development is way more costly because you constantly have to optimize performance bottlenecks.
It makes reasoning about the system much easier.
Personally, i think that PHP's request-response workflow is infinitely easier to deal with than that of servlets in Java or whatever abstractions other technologies out there have, even if only when scaling isn't a concern (which is perfectly passable for some systems out there).
My ideal language for getting things out the door would be something a bit like PHP, but with the standard library of .NET/Java (LINQ or Streams in particular), the wider ecosystem of Python, simplicity of Go and a decent type system on the top of it all, that'd process requests much like PHP does (or at least would only make you think it does, though abstractions that are leaky are arguably worse than none at all).
Also I don't think that you can have a simple language like Go and a decent type system like Typescript, to me those properties are in opposition.
Try the PeachPie compiler then ;)
I develop professionally in PHP but use Python for most of my personal projects, and for scripting text files. Sometimes I'll feel a few hundred miliseconds' delay and be surprised, but unless we're talking about a loop that probably should not loop seconds is a long time.
If you could share more of your workflow I'll be happy to advise.
My guess is that CPython is something like 4x slower for typical code and even slower if most of the code is control structures like branching, loops, function calls etc.
There's a small set of benchmarks between php8 and python 3.9. Your 'guess' isn't too far off.
Personally, I find very little attractive or easy or 'good' about Python. I've used it on a few occasions, and can get by, but pretty much nothing that people find attractive about it resonates with me. Couple that with answers to "why do you like python?" answered with "php sucks!" or "ruby is slow" or similar, and nothing much makes me want to dip my toes in that particular pool.
African or european swallow?