Live data from Hacker News

PHP: A fractal of bad design

me.veekun.com

21–30 of 514 posts

Re: PHP: A fractal of bad design

#21
I enjoy Eevee's posts. I was first introduced to him through a handful of Pokémon sites where users would reverse-engineer the Pokémon games and protocols. He writes good code and knows his stuff. He even offered some assistance when I was writing a .pkm file manipulation package.

I completely agree with most everything in this post, too. It can all be summarized in this sentence later down the page:

> PHP is a minefield.

You can measure a language's design by how often you shake your head at something. I've run in to pretty much every problem he outlines in the Operators section alone. Too often, a problem I'm having is due to a quirk in the language itself and not in my logic. Too often, I find myself needing to check the docs to see which order I need to supply arguments to core functions.

It's hard to imagine the pain of working in PHP without working in it. All those little things you take for granted in Python, Lisp, Ruby, etc. are gone. The only consistent thing about PHP is its inconsistence.

If you don't mind, I'd like to save this for future reference when someone tells me, "PHP isn't that bad." Yes, as others have said, it was beating a dead horse, but we shouldn't forget just how bad a language can be and still become wildly popular.

Re: PHP: A fractal of bad design

#22
post #12

> PHP ... bad design PHP wasn't "designed" ... it evolved. Pieces were added, here and there, re-factored, deprecated, etc. etc. PHP is a natural language. It wasn't fabricated at some university, nor in the lab of some billion dollar company. It evolved. That is its strength. It is the most adaptable language around. It can be used for anything and it has been used for everything. And that is why it is the most popu…

PHP is a natural language. It wasn't fabricated at some university, nor in the lab of some billion dollar company. It evolved. That is its strength. It is the most adaptable language around. It can be used for anything and it has been used for everything. Programming languages are not human languages. Programming languages are engineering tools. Would you cross a dangerous river on a shaky, lashed together bridge tha…

Well, if you take the engineering analogy in a somewhat different direction, you end up with all the structures we ever created before we mastered statics and material sciences. Those bridges the Romans built were evolved patterns based on trial and error of previous designs, where the last design was the testing.

Anyhow, just something to ponder about.

Re: PHP: A fractal of bad design

#23
post #19

"(And strictly speaking, Facebook isn’t written in PHP; it’s written in a C++ macro language with a striking resemblance.)" I'm a Facebook engineer who works on the HipHop compiler and HipHop virtual machine. It's in PHP, absolutely full stop. It's amazing how much the fact that g++ is involved somewhere in the toolchain confuses people in this matter. C++ is just an intermediate representation; the source language r…

He's using poetic license, if that's not obvious.

Re: PHP: A fractal of bad design

#24
post #3

A nice long list of things all concisely put into one blog - I'm sure this took some time to write. Can we move on though? Seriously - no one's forcing you to use PHP, so in your own worlds "It has paltry few redeeming qualities and I would prefer to forget it exists at all." do just that - forget it exists and wake up tomorrow a bit less grumpy. Trust me, you'll feel better!

There are those of us who have been forced to use PHP, and quite honestly, we could use a few good round-up posts of why there are better choices for a project these days than PHP.

Sometimes we can't forget that it exists, so we try to educate people so that with a little luck, they won't pick PHP for their next project.

Re: PHP: A fractal of bad design

#25
post #3

A nice long list of things all concisely put into one blog - I'm sure this took some time to write. Can we move on though? Seriously - no one's forcing you to use PHP, so in your own worlds "It has paltry few redeeming qualities and I would prefer to forget it exists at all." do just that - forget it exists and wake up tomorrow a bit less grumpy. Trust me, you'll feel better!

My boss is. Forcing me, that is. I don't really have a choice. I can't afford to move (no, seriously, I can't), and there is no other work that I'm able to do. I dislike PHP. I wish my boss would let me explore alternatives. :(

You may be able to do some fancy (i.e. useful and profitable) stuff in another language and show it to your boss. Maybe do this in your spare time while learning another language for fun. It may impress them!

Re: PHP: A fractal of bad design

#26
post #12

> PHP ... bad design PHP wasn't "designed" ... it evolved. Pieces were added, here and there, re-factored, deprecated, etc. etc. PHP is a natural language. It wasn't fabricated at some university, nor in the lab of some billion dollar company. It evolved. That is its strength. It is the most adaptable language around. It can be used for anything and it has been used for everything. And that is why it is the most popu…

> That is its strength. No. That's it's weakness. Programming languages are not like natural languages. PHP did not emerge spontaneously from conversations amongst PHP programmers -- people actually sat down and wrote code . When that happened, they had the choice to exercise some degree of higher thought. They did not do so. PHP is a perfect example of how local optimality -- slap on the first thing that "works" --…

This. +1000 if I could.

Re: PHP: A fractal of bad design

#27
post #7

Earlier quoted context omitted.

For someone coming from other language background, including C#, JavaScript, Ruby, I find PHP absolutely unconventional, odd, unexpected, and inconsistent. This is not a language, where you expect intuitively on what method to call unless you do a StackOverFlow search on existing problems, raised by others like me. Yet, I currently develop a web app on PHP. Certainly, I can't wait to move over to Ruby or other langua…

I'm not defending PHP, and I'm not claiming the author "has no right" to make their post. What I am saying is that this post has no value, as it's simply a summary of the same posts we see here week after week. This isn't just stating the obvious, this is literally rehashing the posts (he even cites the sources, which I do commend him on) that have already been made. The point is the PHP circle jerk is getting old. I…

Yeah, I'm tired of PHP bashing too -- BUT! -- this is probably the best written article on what's wrong with PHP that I've ever seen. So... kudos to the author for a good argument.

Re: PHP: A fractal of bad design

#28
post #19

"(And strictly speaking, Facebook isn’t written in PHP; it’s written in a C++ macro language with a striking resemblance.)" I'm a Facebook engineer who works on the HipHop compiler and HipHop virtual machine. It's in PHP, absolutely full stop. It's amazing how much the fact that g++ is involved somewhere in the toolchain confuses people in this matter. C++ is just an intermediate representation; the source language r…

He's using poetic license, if that's not obvious.

"Prosaic license"? If the essay was written in iambic pentameter, it certainly escaped me. Anyway, "C++ macro language with striking similarities" has a pretty precise technical meaning, which sane, literate people might actually mistake.

Re: PHP: A fractal of bad design

#29
My goal is to move away from PHP completely by 2013 for my websites.

I've recently been toying around with various methods of tying C++ to a web frontend, with varying degrees of success. My current favorite method is to use mongoose to create a very simple HTTP interface for any C(++) project (mongoose is great!) and then use AJAX and JSON for any and all communication to and fro client and server. However, this leaves people that have JS disabled out of the loop.

My problems with PHP aren't so much the language as much as it is the environment. It's such a mess with so many dependencies that keep breaking any time you want to do a security update. I'm running PHP-FPM w/ nginx on Ubuntu LTS (Lucid), with the suhosin patch, xcache, memcached, and libcurl (I try to keep the external dependencies down to a minimum. PHP's 3rd party libs are so poorly developed and leak memory like crazy. They're also strictly non-TS builds, and will segfault like there's no tomorrow if used in a TS environment.). Trying to keep up with all the security patches means rebuilding a zillion different packages and applying a few dozen patches each time. It's not a piece of cake.

As soon as I've found a nice, convenient, and lightweight C++ web interface (wt is nice, but it's very intrusive and all your code becomes wt-specific), I'm planning a series of tutorials and open-sourced projects that can help anyone else interested in dumping PHP.

Honestly, it's not so much moving towards C++ as it is away from dynamically typed languages. I've had it with subtle bugs that appear only during run time and only when a certain codepath is taken with languages that let you implicitly define variables. I've come to the conclusion that implicitly defined variables and structures are of the devil himself, and no developer should ever end up working in a language where the compiler doesn't alert you at compile time that your codepath uses previously undefined values. ugh.

Re: PHP: A fractal of bad design

#30
I got into the web space through WordPress and naturally progressed into learning PHP. There are times that I wish I could work with another language just as well as I can in PHP.

I've attempted to learn Ruby. I know C++/C#/Java/Objective C. Yet I still come back to PHP. I can't explain it. I like PHP. I understand PHP. There are nice people willing to help me with PHP. PHP does what I ask.

It's not the greatest. It's no MIT Graduate. But I like working with it. PHP works hard and fast, plus it's a little fun.

I feel there is more important stuff for me to do with my life than worry about the structure of a common language.

I don't know, if anyone can help me understand my attraction it would be most appreciated.

Post reply on HN