Dumb Reasons to Hate PHP – Stephen Coakley

PHP just recently celebrated its 25th anniversary since it was first introduced, which is quite the achievement, considering it still powers a large slice of the Internet today. I don’t write much PHP anymore myself as I’ve more or less moved on to new and different things, but I am incredibly grateful to PHP. It was one of the first “real” programming languages I really invested in to learn programming, and learn I did. I built real things, real websites with it, and also was involved in the community for a while. I saw the rise of Composer and Packagist replace the aging PEAR. I saw the release of PHP 7 and all the work that went into it the years prior leading up to it.

Now as expected whenever talking about PHP on the Internet, people are quick to grab their pitchforks and rehash the same classic criticisms of PHP over and over like a mantra. Is it to feel superior? Do they think they’re doing a public service? I don’t know. What I do know is that they’re right to some extent; PHP isn’t the best-designed language by any means, largely because it changed organically and incrementally over time. It certainly hasn’t stopped PHP from becoming as popular as it has.

There are plenty of good reasons why PHP isn’t the best language for many use-cases, and reasons why other languages are superior. I consider myself very experienced with it, so I speak from experience. Here are some examples just from memory:

  • The standard library, while fairly complete, doesn’t really follow modern PHP’s own best practices for API design, as it was largely created before PHP had things like namespaces and classes. This results in an odd disconnect with modern packages, and that weird mix of styles never really goes away.
  • The standard library also cares a lot about backwards compatibility, which is a good thing, but its also a double-edged sword. There are a lot of APIs and extensions that are soft-deprecated or generally not used in favor of higher-quality third-party packages.
  • The fact that every class file begins with <?php reminds you that PHP was originally just an html preprocessor and always runs inside the context of another file format. It makes sense, but its unusual and weird, especially since embedding PHP into html isn’t even done at all in many frameworks which have dedicated templating languages instead.

There are probably others, but these don’t keep me from remembering PHP with fondness as something that just works out of the box and has a lot of convenient features for web development.

What’s strange to me though is that instead of reasonable complaints like these, people like to present complaints that don’t make sense, aren’t true, or are just plain silly. Let’s take a look at just a couple that I’ve seen.

The syntax is strange and archaic!

This complaint doesn’t really make much sense to me. PHP’s syntax is very heavily inspired by C (which it is written in) and borrows many things from it. In fact, it fits right in with most of the languages in the C family of syntax. Just swap the dot operator for -> (which by the way is also lifted from C, its equivalent to (*struct_ptr).field), prepend all your variables with the $ sigil, and that’s just about it. It’s got your boring traditional class syntax that even JavaScript adopted, closures, and pretty much every modern convenience.

Granted, sigils probably remind you of Perl, but don’t worry, they don’t have crazy effects on data types like in Perl. Just think of it as part of the variable name and you’ll be fine.

There are a few PHP-specific oddities in its syntax, like the @ operator and using \ as a namespace separator, but these seem like really petty nitpicks to me.

It isn’t modular!

This sort of complaint is really nebulous, and could stand to have some clarifying questions asked. Usually people mean one of two things:

  1. Everything is in a global namespace with no modular separation.
  2. There is no modular way of packaging code.

Now both of these are just blatantly false. The first one is easy: PHP has namespaces, like Java, C#, or what-have-you. And they were added to the language in version 5.3, which was released in 2009! Now to be fair, there still exists a lot of codebases that were initially designed before then (like WordPress) that don’t leverage namespaces everywhere because of this, and this includes the standard library itself. But generally namespaces have been adopted for some time, and any modern PHP codebase uses them well.

The second

Truncated by Planet PHP, read more at the original (another 5391 bytes)

Black Lives Matter – Chris Shiflett

George Floyd. Breonna Taylor. Ahmaud Arbery. So many others. Their murders are tragic, and racism toward Black people is as pervasive as it is horrible. We must do everything we can to eradicate it.

I have been silent these past couple of weeks, listening and reading and watching and learning, but I am inclined to agree with the sentiment expressed so eloquently by Desmond Tutu:

If you are neutral in situations of injustice, you have chosen the side of the oppressor. If an elephant has its foot on the tail of a mouse, and you say that you are neutral, the mouse will not appreciate your neutrality.

Remaining silent makes room for other voices, but it also supports the status quo. Each of us has a voice, and that voice can be more powerful to our own circles of influence — however small — than the voices of others, even if theirs are more eloquent, more refined, and more important.

Here are my thoughts.

Violence

It’s important to understand why people are angry. This Twitter thread provides some insight into the injustices that Black people face in America. This Twitter thread simply asks, “how old were you when a cop first pulled a gun on you?”

If you want to speak out against violence, make sure you heed the advice of Randall Telfer and get your priorities straight:

You keep saying, “it’s horrible that an innocent black man was killed, but destroying property has to stop.”

Try saying, “it’s horrible that property is being destroyed, but killing innocent black men has to stop.”

Police brutality and the leaders who are encouraging and glorifying violence deserve nothing but our strongest condemnation.

In short, if you’re angry at protestors, I encourage you to educate yourself on what is really happening and why.

What can you do?

I am so inspired by all of those who are protesting, risking their safety against the dual threats of police violence and COVID-19, but you don’t have to protest to make a difference. Whether it’s speaking to friends and family, donating money to bail funds, or committing to anti-racism, there ar

Truncated by Planet PHP, read more at the original (another 2408 bytes)

PHP Internals News: Episode 56: Mixed Type v2 – Derick Rethans

PHP Internals News: Episode 56: Mixed Type v2

In this episode of “PHP Internals News” I chat with Dan Ackroyd (Twitter, GitHub) about the Mixed Type v2 RFC.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode’s MP3 file, and it’s available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news

Transcript

Derick Rethans 0:20

Weekly a podcast dedicated to demystifying the development of the PHP language. This is Episode 56. Today I’m talking with Dan Ackroyd about an RFC that he’s made together with Mate Kocsic it’s called the mixed type version two. Hello, Dan, would you please introduce yourself?

Dan Ackroyd 0:38

Hi Derick. So my name is Dan Ackroyd, also known as Dan Ack online. I maintain the PHP image extension. And I also contribute to PHP internals illegitimate by maintaining some documents that called the RFC codecs that are a set of notes of why certain ideas haven’t reached fruition in PHP core, and occasionally I help other people write RFCs.

Derick Rethans 1:04

Continuing with the improvement of PHP type system in the last few releases. And we’ve seen a few more things coming into PHP eight but union types. For a long time, there has been an issue with PHP’s internal functions that the type that a return cannot necessarily be represented in PHP type system because they do strange things. It is RFC building more on top of PHP’s type system. What is this is trying to solve?

Dan Ackroyd 1:29

There’s a couple of different problems that’s trying to solve. The one I care more about is userland code, I don’t actually contribute that much to internals code so I’m not that familiar with all the problems that has. The reason I got involved with doing the mixed RFC was: I had a library for validating parameters, and due to how that library needs to work the code passes user data around a lot internally, and then back out to whether libraries return the validators result. So I was upgrading that library to PHP 7.4, and that version introduced property types, which are very useful things. What I was finding was that I was going through the code, trying to add types everywhere occurred. And there’s a significant number of places where I just couldn’t add a type, because my code was holding user data that could be any other type. The mixed type had been discussed before, an idea that people kind of had been kicking around but it just never been really worked on. That was the motivation for me, I was having this problem where I couldn’t upgrade my library, as I wanted to, I kept forgetting has this bit of code here, been upgraded. And I just can’t add a type, or is it the case that I haven’t touched this bit of code yet. So coincidentally, I saw that Mate was also looking at picking up the RFC, and he had copied the version that Michael Moravec had been working on previously. I want as I mentioned earlier, I help people write RFCs is for a lot of people where English isn’t their first language, it’s a difficult thing to do writing technical documents in English. I also think that writing RCFs in general is slightly harder than people really anticipate. Each RFC needs to present clearly why something’s a problem, why the proposed solution would work, snd, at least to some extent why other solutions wouldn’t work. Looking at the text from the previous version I could see the tool though, I understood, all of the parts of that RFC, I don’t think that it made the case for why mixed was the right thing to do in a very clear way. So I spent some time working with Mate to redraft the RFC, discussing it between ourselves and going through a few of the smaller issues before presenting it to internals, for it to be officially discussed as an RFC.

Derick Rethans 3:51

Where does th

Truncated by Planet PHP, read more at the original (another 24663 bytes)

Kindo Acquired by MyHeritage – Demian Turner

I didn’t get a chance yet to blog about our last TechCrunching, but Kindo, the startup I co-founded in March 2007, today announced its sale to MyHeritage, the biggest player in the family tree space.

Kindo is a PHP social net app built on the Seagull framework and other open source software.  At peak popularity our users were building 38k profiles/day and we acquired more than 1m profiles in our first 10 weeks.

Hats off to the Kindo team and to the Kindo devs who don’t appear in the TC photo.