A More In-Depth Reasoning behind PHP as a good language

Yesterday, I wrote a post over lunch that people just absolutely hated. It was great, in sort of weird way, to see that many people didn’t see what I saw when I posted it. I think it was a somewhat-not-gentle reminder that I see the world differently.

The post was shared on Reddit and I personally shared it on Hacker News (which was flagged) just for giggles to see if there would be any interesting conversations. Indeedly, I got some “interesting” comments:

But wow, this is not a convincing article at all. It’s just an opinion with nothing to back it.

wccrawford on https://news.ycombinator.com/item?id=30700298

No substantive argument made here, except “PHP has changed in the past 10 years”.

krageon on https://news.ycombinator.com/item?id=30698957

When you’re this wrong about a topic, most people quit even trying to correct you.

spacemanmatt on https://news.ycombinator.com/item?id=30699677

There were similar things on Reddit. Truthfully, I didn’t expect people to see what I saw when I posted that post. However, I think it is probably worth digging a little deeper into the post, just to help anyone out who comes along later.

Like, look at this Merge Sort in C# (130 lines) and then look at it in PHP (31 lines). You can’t beat that kind of productivity, not to mention in PHP, you can even mix data types (like ints and floats) where in the C# version, it’d be much more difficult.


People took this to mean that LOC is what makes them productive(?). I totally get why people would think that because I didn’t spell it out. We learn algorithms like Merge Sort because we should never implement them ourselves. So, why do we learn something we shouldn’t use? Why do we test for it in interviews? The answer is obvious to me, but again, I see the world differently than most.

Think about it, “we should never implement them” which means you need to be able to recognize when you are, or code you’re reviewing is accidentally implementing them, which means you need to know what they look like so you can point it out.

PHP is a ridiculously concise language for being C-like, probably due to the huge amount of built-in functionality, where C# is much more verbose. You can spot the merge sort in PHP at a basic glance, where you have to tease apart the C# version to figure out it is a merge sort. That was my point, not that LOC is important to productivity, but the fact that PHP is so concise, that you can spot common algorithms from a mile away.

However, there are cases for custom implementations, as long as you know what you’re doing. WordPress and Beanstalkd both implement custom priority queues, and they’re faster than they should be because of it. Does that make it harder to maintain and change those pieces? You bet! But sometimes being fast is better than being easy to maintain — such as on critical paths.

So, how does this tie into productivity? If you can easily spot common algorithms/patterns, you have a wealth of information at your fingertips to help you optimize the code, make it easier to understand, and deliver more value to the end-user. If common algorithms are obfuscated, you’ll miss the forest for the trees and not realize the wealth of information you could have had.

When I learned Assembly, I think I broke my brain, permanently. New paradigms were learned, old ways to do things were suddenly way too long. I don’t really know how to explain it, but when I came back to C#, suddenly, I felt too constrained.


I was optimizing a bluetooth door lock I made myself for my front door. I basically had a very small amount of memory. It was tremendously fun, to figure out how to do everything I wanted to do and squeeze it into a very small amount of flash memory. I think we’d call it spaghetti code if it were written in a higher-level language. 🙂

Writing spaghetti on-purpose is truly harder than writing good code, and optimizing spaghetti is even harder. I highly recommend it, it’s similar to the paradigm shift required to learn languages like Haskell when all you know is procedural/OOP style code.

Anyway, lunchtime is over and I think I covered the big things I wanted to address. Enjoy your day!

Want an inside scoop?

Check out PHP Shenanigans for only €5/mo or €30/yr


One response to “A More In-Depth Reasoning behind PHP as a good language”

  1. Jake Pogorelec Avatar
    Jake Pogorelec

    Some people are sooo opinionated lol rolling my eyes I think your articles were great 🙂 Keep up the good work

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.