Smash Company Splash Image

May 5th, 2020

In Technology

1 Comment











If you enjoy this article, see the other most popular articles




















If you enjoy this article, see the other most popular articles




















If you enjoy this article, see the other most popular articles

What does PHP offer now?

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.

I’m writing in response to something on Hacker News:

The thing is, when I started using PHP in 1999, PHP had real advantages that no other eco-system offered. Regarding functionality, it had an “all in one” philosophy, whereas Perl had exactly the opposite attitude. With Perl, the first thing you had to do was research which modules you would have to download and install, but with PHP you could just start writing code. This was in the era before modern package managers, so it was a very big deal. PHP was open source, so it was a good choice relative to classic ASP. Worst of all, other languages, such as Java, were engaging in an orgy of unnecessary complexity, especially when it came to frameworks, of which Struts was perhaps the most awful exemplar. PHP was the first language to make automatic adaptations to the world of the Web, including loading $_POST and $_GET variables automatically — some of these decisions were later seen to be huge security liabilities and so they were ended.

Above all else, circa 2000 we could still rely on Moore’s Law and therefore we could rely on a single CPU getting faster and faster every year. But once Moore’s Law came to an end, it became increasingly important to be able to leverage concurrency, and PHP had no real story around concurrency (except the course-grained method of starting a new process).

PHP 4 was a very easy language to learn. It did not have many Object Oriented features, instead it encouraged a simple style of simple functions. Ironically, when it came to objects, the default behavior was “pass by value” so PHP 4 was, in a sense, an immutable language, long before that became a popular development style (tragically, it was not optimized to manage memory in a manner that would allow ambitious use of its immutable qualities).

Later, PHP developed an intense envy of languages that were seen as “enterprise ready languages”. This lead to a lot of nonsense. First of all, PHP 4 was already good enough that it could be used in an enterprise, but this fact was ignored. Second of all, PHP 5 suddenly adopted a lot of Object Oriented features which added a lot of complexity to the language, but without offering the benefits that might have come from using a language like Java, such as compile time checks.

I used PHP from 1999 to 2011. I built my first and second startups using mostly PHP. However, in the year 2020, I can not imagine why anyone would use PHP. It no longer offers the simplicity that it offered in 2000. It no longer offers the straightforward procedural style that it allowed in 2000. It’s “all in one” philosophy is no longer an advantage because now every language has a modern package manager that makes it easy to include whatever is needed. Nowadays, with Javascript, you just type “npm install” and you get every module that you need. And yet PHP still doesn’t offer some of what a complex language like Java or C# might offer, especially regarding strict typing or compile time checks or run time efficiency, or a separate set of runtime flags for a compiled version. PHP has become a weird mutant, imitating the more complex languages but without offering their benefits.

And crucially, the other languages have not been stagnant. The community around Java eventually gave up on Struts and started developing light-weight frameworks that made development much easier. And there sprang up dozens of languages that run on the JVM and which offer a wealth of good ideas about how to do modern development. (I became a huge fan of Clojure.)

I seriously can not imagine why anyone would use PHP now. It no longer offers simplicity, but developers don’t gain much from all the extra complexity that’s been added. Source




Check out my book:





RECENT COMMENTS

August 28, 2020 6:37 pm

From Aleksandar on Why I hate Ruby On Rails

"I am in RoR about 7 years, but I don't like it (I do it on my primary job). In free time (freelance) I work mo..."

July 14, 2020 8:53 am

From lawrence on How I recovered from Lyme Disease: I fasted for two weeks, no food, just water

"In my experience, yes. I have made it common to do a 3 day fast a few times a year. Anecdotally, I would say i..."

July 13, 2020 3:07 pm

From Tes on How I recovered from Lyme Disease: I fasted for two weeks, no food, just water

"Thank you so much for sharing your story. I have recently been diagnosed with Lyme disease and want to treat i..."

May 31, 2020 9:03 am

From Gábor Hidvégi on What does PHP offer now?

"Dear Lawrence, I can agree with you partially, but not in the whole at all. I agree with you that even P..."

May 22, 2020 12:43 pm

From Frank Hileman on Object Oriented Programming is an expensive disaster which must end

"Good article. However I hate to see so called "SOLID Principles" conflated with OOD. SOLID is a form of cargo ..."

May 22, 2020 10:29 am

From ByterBit on Object Oriented Programming is an expensive disaster which must end

"The first time I looked closely at OOP I was astonished at the – idiocy, the absence of any usefulness, the ad..."

May 13, 2020 5:03 pm

From Just+An+Observer on His Girl Friday

"Closest match to the intensity of this is the movie "Twentieth Century" with John Barrymore and Carole Lombard..."

October 19, 2019 3:08 am

From Bernd Schatz on Object Oriented Programming is an expensive disaster which must end

"I really enjoyed your article. But i can't understand the example with the interface. The example is reall..."

October 17, 2019 4:50 pm

From Anderson Nascimento Nunes on The conventional wisdom among social media companies is that you can’t put too much of the onus on users to personalize their own feeds

"Can't speak for anyone else, but on my feed reader: 5K bookmarked feeds, 50K regex on the killfile to filter o..."

October 9, 2019 3:08 pm

From Dan Campbell on Object Oriented Programming is an expensive disaster which must end

"Object-Oriented Programming is Bad https://www.youtube.com/watch?v=QM1iUe6IofM..."

October 4, 2019 8:44 pm

From lawrence on My final post regarding the flaws of Docker / Kubernetes and their eco-system

"Gorgi Kosev, I am working to clean up some of my Packer/Terraform code so I can release it on Github, and then..."

October 4, 2019 5:14 pm

From Gorgi Kosev on My final post regarding the flaws of Docker / Kubernetes and their eco-system

"> Packer, sometimes with some Ansible. The combination of Packer and Terraform typically gives me what I ne..."

October 4, 2019 12:40 pm

From lawrence on My final post regarding the flaws of Docker / Kubernetes and their eco-system

"Gorgi Kosev, about this: "I would love if you could point out which VM based system makes it simpler and..."

October 4, 2019 7:31 am

From Gorgi Kosev on My final post regarding the flaws of Docker / Kubernetes and their eco-system

"I won't list anything concrete that you missed, because that will just give you ammunition to build the next a..."

October 4, 2019 1:39 am

From lawrence on My final post regarding the flaws of Docker / Kubernetes and their eco-system

"Gorgi Kosev, also, I don't think you understand what a "straw man argument" is. This is a definition from Wiki..."

1 COMMENT

May 31, 2020
9:03 am

By Gábor Hidvégi

Dear Lawrence,

I can agree with you partially, but not in the whole at all.

I agree with you that even PHP4 could be use in enterprise, that’s true. The newer versions have more features, but you don’t have to use those at all. PHP has always been a multi-paradigm language, you can program with it in procedural, OOP and functional style.

We, for example, program in procedural style, we’ve got only a few objects, but mostly we use integers, strings and indexed arrays for storing data. Theoretically our software could be written in PHP 4, we only use the new crypto functions of PHP 5.6 and 7.0 versions.

I think that the JS npm packages are rather disadvantage than advantage:
1, there are trillions of packages, it takes ages to find a good one
2, a package can be anytime abandoned by its maintainers
3, developers have an urge to always put new features into packages, growing it’s size and the possible number of bugs.

I’ve been professionally working with PHP from around 2000. My usual experience is that packages or libraries or frameworks are full of bugs, they are over-complicated and over-engineered. In the long run we reworked the external utilities with a few exception (PHPMailer and some SQL parser), so the code became much stable, much faster and does only what we need.

For example I wanted to run a websocket server. I started to download node.js packages by hand (I usually like to know, how they work, what they do), and I stopped when the packages’ overall size exceeded 512 kilobytes.

I started to search the web, first I found a PHP websocket server with 15k size, but it turned out to be defective. Later I found one with 25 kilobytes size, and it turns to be perfect. It’s at least 20 times smaller than the node.js one, and does the same job.

Right now I’m working on a Skype-like communication software; I checked out the online Skype source code, it’s size is 14 megabytes. With mine you can now chat and make calls, and it’s size is: websocket server 45 kilobytes, PHP server side framework plus application code 65 kilobytes, templates 14 kilobytes, javascript 27 kilobytes; overall 141 kilobytes, one thousandth of Skype’s size. Of the 141 kilobytes 68 kilobytes is own code, 73k is framework and library code (these latter we use in other projects too). What does it take to write 68 kilobytes of code?

I think PHP is fantastic, because it’s a multi-paradigm language, it has a very broad standard library, it’s fast, it’s synchronous (huge plus), and it’s portable.

Leave a Reply

Your email address will not be published. Required fields are marked *