Live data from Hacker News

PHP: A fractal of bad design

me.veekun.com

71–80 of 514 posts

Re: PHP: A fractal of bad design

#71
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…

PHP as a language is, at present, defined by the behaviour of the canonical PHP.net implementation. Change the implementation, and de facto you've changed the language; Perl 5 is similar in this respect. A claim that an alternate implementation or tool chain supports _that_ very same language is a curious statement. It is an alternate implementation, and surely it must differ behaviourally, even if only by having uni…

This was the same argument I was having in my head, and in the end I couldn't draw a clear enough line between something like Jython and something like HipHop.

Re: PHP: A fractal of bad design

#72
post #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'…

The day you learn Python and see the light, you will look back and wonder, "Oh, God. Why?"

I actually have to agree. I started out my programming experience with C# -> PowerPC (strangely) -> C++ -> touched upon PHP -> Java -> Python -> Objective-C. Out of all of these languages, Python was by far the easiest and most flexible language to learn.

I've never done any sort of web development at all (no HTML, CSS, JavaScript, etc.), but I set up a local Django server to do stuff with, and I absolutely love it. I learned Pyton for web development, but I can really see it coming a part of my future projects.

Re: PHP: A fractal of bad design

#73
I'll preface things with, I don't care about the cleanliness/consistency/correctness of languages, I really just care about tools to get a particular job done.

PHP isn't sexy, hell, it might be classified as a backwater these days. Fact is, it is a simple language, it works, and a whole lot of useful tools are built on top of it. I've done many bad things with PHP, some I will admit to, some I won't. Hell, I built a bunch of authentication services and prototyped a storage backup system using PHP because it was the most mature language at the time (this was years ago, and mod_php was light years ahead of mod_python, ruby wasn't even in the discussion). It worked, the security issues were known, and we knew how to scale the system.

The first post on http://anodejs.org a couple of weeks ago was pretty amazing. The title "We work at Microsoft and we use node.js". That statement in itself was amazing (you wouldn't have seen that 5+ years ago), but the use of Javascript in a large company/large team environment is an interesting exercise. My experience is that a team of 4-6 people working in the Javascript/Node server side have to put tools in place to ensure code quality and consistency that was never needed in PHP.

Each language has it's strengths and weaknesses. In the case of PHP, it isn't sexy, it is pretty homely, but a lot of people are still getting a lot of stuff built using it.

Re: PHP: A fractal of bad design

#74

I can't really fault anything that was said in the article. What left me wanting was the ending. I was expecting the equivalent of the main character happily walking into the sunset. In other words, something akin to: "And now that we have established why PHP sucks let me tell you what I use and why. I use . Here are all the reasons for making these choices:"... To me at least, an equally thorough treatment of what h…

Ha, I actually avoided doing this so as to not sound like a shill for better-thing-X :)

I namedropped Python a couple times, and I do enjoy it for webdev. I've been considering writing something about getting into Python webdev from a purely PHP background; might do that sooner rather than later.

Re: PHP: A fractal of bad design

#75
post #58

"preg_replace with the /e (eval) flag will do a string replace of the matches into the replacement string, then eval it." The mind reels.

You can blame Larry Wall (Perl) for that one. It's amazingly powerful but also the stuff of nightmares in the wrong hands.

Nope. This works as you'd expect in Perl: the replacement is treated as code and executed like an inline function, never eval'd.

Re: PHP: A fractal of bad design

#76

Earlier quoted context omitted.

> 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" --…

> They did so because in the late 1990s it was not possible to run multiple mod_perl applications on a single Apache process, but mod_php could do so. When it comes to single factors explaining its success in the 1990s, the one I've heard cited more often is that you could embed PHP into HTML documents with the kind of deal, and a lot of shared hosts enabled that by default, making it by far the easiest way to get se…

Plus the deployment model: "here's your FTP login".

Re: PHP: A fractal of bad design

#77
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. :(

>and there is no other work that I'm able to do.

No offense, but you should really find the time to learn. That's not a hit against PHP (which I don't care much about one way or another; anything good enough for Facebook but full of such a large number of gotchas can obviously be read either way) and it's not even a comment about the marketability of your particular skill set.

Instead, it's just intended as a friendly reminder that you, not your boss, are in charge of your life. :)

Re: PHP: A fractal of bad design

#78
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…

Spend some time on the PHP developers' mailing list and watch exactly how the language evolves. You will lose that feeling of awe and reverence pretty quickly.

And every language is designed. This one happens to be designed by committee, with all the attendant issues.

Also, nobody is arguing about whether it is popular. (Although, "most popular programming language"? What planet do you live on?) We are not arguing whether it can be useful. We are discussing whether it's a good language. Try to follow along.

Re: PHP: A fractal of bad design

#79
PHP was designed by people who neither knew, nor cared what the hell they were doing, but knew they wanted something to do what they wanted to do. In that sense you cannot blame PHP for being a huge wasteland of terrible design just as you cannot blame a blind man for not being a great painter.

That being said, thank you for documenting why nobody should ever seriously use this language unless it's absolutely necessary.

Re: PHP: A fractal of bad design

#80
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.

[deleted]
Post reply on HN