Live data from Hacker News

PHP: A fractal of bad design

me.veekun.com

221–230 of 514 posts

Re: PHP: A fractal of bad design

#221
post #163

Earlier quoted context omitted.

Only a couple of these things are outright wrong; I removed the offending bullet points earlier tonight. A few things I listed because they're weird, not outright wrong, and I stand by those. For the most part you've defended PHP's behavior as design decisions or offered workarounds. Workarounds just demonstrate that the language is Turing-complete. Design decisions are only okay if they actually make a useful tradeo…

So, do you want the PHP to be a clone of python? PHP works for some and python works for others. Do we really need a FUD to convert people? Hint: read python sucks articles from Ruby rockstars.

Oh come on dude! Nobody is really asking for PHP to be a clone of Python. Why can't PHP have a nice module system? It's not FUD to complain that it doesn't have one. It's commonsense!

Re: PHP: A fractal of bad design

#223
The one thing that really bothers me about these "PHP sucks" articles is that the author implies that it's inevitable that anything written in PHP will be complete junk. Yes, it has flaws, but PHP is associated with spaghetti code 100% of the time regardless of who's writing the code. I've seen some very well structured PHP; Yes, it does exist.

I'll admit that I am new to web app development and learned how to program(web apps) with PHP. The simplicity and forgiving environment is what made it so alluring. Sure my first bits of code may have been sloppy, but that sense of false confidence pushed me to learn more and improve my understanding. I gained experience and "real" confidence quickly. After seeing how easy it was to make simple apps with authentication features and whatnot, I moved onto Python. PHP quickly taught me the basics which then allowed me to jump into more advanced features and other languages, and that is why I appreciate it.

Before anyone uses my words against me where I mentioned a sense of false confidence, I think that's actually a positive thing. It pushes the user to learn more, or at least it did for me. Do you really think anyone with a complete lack of understanding of OOP, frameworks, or programming in general will be able to hack together a Facebook, ebay or Paypal?

Re: PHP: A fractal of bad design

#224
post #210
post #88

Meh, I've written a lot of PHP code. I also work in Ruby and Python. All three have problems, but I like all three. With PHP, you have to develop a coding style that naturally avoids PHP's weird areas. It's not really that hard to avoid the mines, but you do have to be aware of them. In exchange, you get a scalable web server and a language that requires minimal babysitting. Instead of automatically throwing a 500 on…

Instead of automatically throwing a 500 on a random, unimportant, uncaught exception, PHP makes a best effort, and most of the time the result is fine. And how precisely does PHP "know" which exceptions are important and which are not? In my experience of 6 years as a web developer, the faster and the more explicitly something fails the better. If the user gets a 500, that's a pretty clear sign of a problem, I get an…

Catching exceptions and returning a 200 OK blank page is about the worst thing that PHP is doing. A simple error can trash your google index (Oh, page replaced by blank content, fine!) or mess up API communication when the receiver does not explicitly check for the response content (POST to endpoint, 200 OK, ok, nice). And while you can catch and handle some of those errors with your own error handlers, there are error classes that you can not handle and which will always be handled internally. It's a pure mess.

Re: PHP: A fractal of bad design

#225
post #183

Earlier quoted context omitted.

You're right. This is a supply-and-demand problem : which choices does non-programmers or casual programmers have when they want to create an app ? How can someone who's working or studying 40+ hours a week find the time to learn the basics of MVC, inheritance etc ... There is a demand for easy to create template-based websites and PHP is the only kid in town for this kind of things.

This is no excuse. If you want to learn how to do something, effort is required. How much time will that person waste in the long run battling all of the problems and traps PHP brings with it? I contend that learning a proper language will be of greater benefit to a person just starting web-development, and putting in just a few extra hours at the beginning to get a solid foundation will in fact save them time in the…

>This is no excuse. If you want to learn how to do something, effort is required.

Some people doesn't want to learn web programming. They want to get things done. Think of PHP as an equivalent of Bootstrap on the server side. People don't use Bootstrap because it's beautiful but because they can't design and in fact don't need anything fancier.

Re: PHP: A fractal of bad design

#226
post #91

I admit, PHP sucks. But there is one thing it has going for it. It's simple to configure and secure a server that your general userbase can run applications on. I work at ITECS, the Engineering IT department at NC State University. ITECS is responsible for maintaining the server infrastructure for dozens upon dozens of university Web sites, most of which have dynamic content. Not to mention the people server, which a…

That's odd, because usually servers get owned from faulty wordpress/joomla instances. I rarely hear of web servers getting rooted via web apps run on python. I'm not really an experienced php dev myself, and when I installed joomla on my vm last year, it was rooted within the hour -- I was notified by a data center admin saying my vm was using an insane amount of bandwidth. I'm sure it was some script scanning for bo…

The PHP on our servers is also ridiculously locked down due to a combination of php.ini sandboxing settings including open_basedir (which AFAIK no other language has out of the box) and very strict AFS permissions (the server only has access to your specific Web locker, and it only has write permissions if you specifically enable them in the locker portal).

(I also haven't seen any Joomla installs.)

Re: PHP: A fractal of bad design

#227
I'm not qualified to refute many of the programming points in this article but I can say that this is wrong:

"Similarly, there is no easy way to “insulate” a PHP application and its dependencies from the rest of a system. Running two applications that require different versions of a library, or even PHP itself? Start by building a second copy of Apache."

If you're running PHP via fastcgi (e.g. mod_fcgid on Apache), you can build as many different versions of PHP as you want and then point the various websites/webapps to whichever version they need. It's trivially easy to do.

Re: PHP: A fractal of bad design

#228

All those words, and yet the word template only appears once. And that's to assert that PHP has: …no template system. There’s PHP itself, but nothing that acts as a big interpolator rather than a program. As if that was a bug and not a feature. PHP succeeds because there is one PHP templating syntax and it is called "PHP" . PHP started life as a templating language, and that's where its soul lies. Which is important,…

PHP is not a good tool for quickly getting a minimum viable product. Despite its flaws it is a good weapon for fighting 'the last war' - that is to say, it makes it quick and easy to make what are essentially the CGI pages of 1996 - but if you're doing anything more complex than that (for instance interacting in any way with a database), and I would suggest that even relatively non-technical people looking to use com…

Let us not forget that PHP was once PHP/FI which meant "personal home page form interpreter". And in the 90s, it did exactly what it said on the tin.

Re: PHP: A fractal of bad design

#229
post #83

Earlier quoted context omitted.

Whoa. Definitely don't run Python as CGI. Use WSGI, run your app as a devoted low-priv user, proxy to it. Then you have only one entry point; there IS no sandbox, and nothing to exploit.

I agree. Why not run the webapp as the user account the code belongs to. With virtualenv and pip, normal users can install modules into their own site-package in their home folder, and any runserver started as them will only have permission to access anything they have access to. The only thing that is possible to exploit is what they've allowed in their code, but that's pretty much the same issue you have with php.

Because (a) mod_wsgi is nowhere near as easy to sandbox as PHP (again, php.ini settings), (b) configuring proper production servers to run as specific users is a pain, and (c) this is a university where people have access to sensitive student information and research data in the AFS system. How bad do you think it would be if a random student could exploit their professor's site and change their exam grade?

Re: PHP: A fractal of bad design

#230
and yet it moves

PHP is a product of evolution. It's not nice but it's incredibly well adapted.

Instead of complaining about how ugly it is people should be researching why it flourished and make sure that they introduce the same qualities in their designed systems.

I have few guesses what might these qualities be.

- Script serves one request and dies. Problems are limited in time and range. They most likely won't bring your app down. - You have universal data structure, ordered dictionary with lots of functions that operate on it and some additional features for numeric keys. - you have php.net/name_of_the_function which gives you description of the function and it's parameters, return values with comments and examples of use from the users. - getting things sent by browser is extremely easy, sending stuff to browser is even easier. - if you want to do something, functions that will help you are there because someone needed that before you and just added them there. And it's not in some obscure package that you have to download from God knows where. It's in the core and it's most likely only one of it.

You can dissect a rat and complain how ugly it is but it will still eat your lunch.

All the elegance of other languages are not that important. 99% of software development is not architectonic cathedrals. It's telling your slave what you want from him.

Also 78% of the statistics are bogus including this one.

Post reply on HN