4 ms·
Most of my hate is not directed at PHP but rather the code of the projects I run across written in PHP. It's not uncommon for there to be random whitespace and
by overshard 12y ago
Most of my hate is not directed at PHP but rather the code of the projects I run across written in PHP. It's not uncommon for there to be random whitespace and code thrown everywhere with no heed to a sensible MVC or other software architectural pattern.
I do occasionally run into well written and maintained software written in PHP and, while it's not my prefered language, it's quite readable and I can work with it.
PHP does have it's issues but they are exacerbated by the general community that uses it.
- skrebbel 12y ago> Most of my hate is not directed at PHP but rather the code of the projects I run across written in PHP. This is pure selection bias. There's great PHP code and there's horrible $YOUR_FAVOURITE_LANGUAGE code. If you hate PHP because of this, you must also hate Java (since Android, at least, which at least halved the average competency of the community) Ruby (since Rails became too popular), JavaScript (see the jquery thread on the HN front page right now), Haskell (big ball of 2000 unorganized functions with two-letter argument names, anyone?), C# (This Is How Microsoft Does It So We Must Too) and Python (at least since Codecademy/Treehouse started unloading thousands of well-meaning but inexperienced Python programmers on the world). Don't even get me started about Perl and C++. I'm not sure what's left. Clojure, Elixir, Turbo Pascal?
- overshard 12y agoI said that there is great PHP code, I've run into many projects in PHP that are extremely well written. However, I run into more PHP projects that are not. PHP is fantastically easy to get started using, it's probably the simplest way to start doing website development, and Wordpress runs many of the small websites we see today. I recommend it to anyone getting started in web development. But what this leads to in website development is me running into more code in PHP that is bad than good. You are correct in saying that there's horrible $YOUR_FAVORITE_LANGUAGE code, I do run into it all the time, but I just tend to run into this problem more with PHP due to how amazingly low the barrier to entry is. Since you brought up my favorite language, Python, I will go to say that at least Python forces people who write it to use sensible whitespace more or less. I can read most Python projects, even if they are really bad. In PHP I've seen whitespace and lines that stretch over 500 characters and combinations of tabs and spaces that make my brain hurt. This goes for any language that doesn't have strict whitespace rules but specifically PHP and even JavaScript, with their ability to inline code in HTML, have lead to some nightmare codebases that I've had to work on. That is not to say that Python doesn't have some silly long lines with people who try to get too creative with lambda functions but that's a rare occurrence. Also the fact that you cannot inline Python (without some silly libraries that do exist) you do get at least some separation of templates and model/views. This goes for Java and C# and whatever other web dev language you want to put in. PHP's ability to inline code is both incredible for new coders and a nightmare for readability if not done properly.
- tormeh 12y agoI think it's a bit silly that less-than-four-letter arguments/values/objects/functions are allowed in modern languages. I mean, what are the odds that the programmer is not writing horrible code in that scenario?
- oneeyedpigeon 12y agoThat's very subjective. Yes, one-letter variable names are usually a pain, but throwaway loop increments can be an exception. Three letter variable names are often perfectly acceptable, and optimal - what would you suggest I use instead of age, day, or max? Long variable names are often a massive pain, particularly those with multiple words separated by differing case or non-alpha characters.
- deleted 12y ago[deleted]
- ubertaco 12y agoSome trivial counterexamples (in ES6 for convenience): someArray.sort((a, b) => a - b); var odd = (x) => x % 2 == 0; highlightRows = rows.filter(odd); function isLegalAdult(age, locality){ ... }
- berntb 12y agoAgreed. Every programming language/library/framework/etc will have ugly warts. You shouldn't primarily evaluate a product based on the number/severity of ugly warts -- but rather on how much problems you will have from the warts, if you follow your coding standards and best practices. (That said, I've never used PHP. E.g. the naming in the standard lib seems hard to not suffer from, but it ought not to be a major problem.)
- soneil 12y agoI'd agree with this, but from an unusual perspective - I write some really, really bad PHP. So I thought I'd offer some perspective on where this actually comes from (from a sample set of 1). PHP's documentation is almost too good. It's fantastic. My primary frustration dabbling with other languages is that no-one else has not only the language itself, but a huge subset of the core library documented to the standard that I've come to rely on from PHP. But here also lays a huge problem. I'm not a programmer. I have next to no idea what MVC is, let alone what would qualify it as sensible. When it comes to architecture, I could give you a much more convincing description of flying buttresses than anything you'd hope to find in a codebase. But what I can do, is break what I want to do down into small enough component tasks that I can find very workable examples within the PHP documentation, and then duct-tape these all together until I've accomplished my goal. Now, the good news is that I know this is a terrible approach with terrible results, so I wouldn't dream of inflicting my results upon anyone else. But I thought I could offer a little insight onto how PHP enables such atrocities. It's similar to the popular backlash against Bootstrap. Where Bootstrap enables me to kludge together a frontend with near no idea what I'm doing, PHP's documentation does the same for the backend. But I still find it difficult to blame the products themselves - I'm more than aware that this is my failing.
- lmm 12y agoIs it really that much better? I've found e.g. the Python documentation for the core library is very good. It seems to me that it should be possible to slap together some Django approximately as easily as PHP, and you'd end up with something a little bit better. Is it just that something like Django requires a bit of up-front install, whereas PHP you can write <?php in a file on your shared webhost and be rolling? Am I wrong about the documentation being up to the same standards? Or is there something else going on?
- mtbcoder 12y agoLaravel (or any other PHP framework) also requires an "up-front install", but you don't need a framework like Django to "slap" together a Python program for web purposes either. What you need is an understanding of what a CGI application does and how to deploy one with your favorite web server. Deploying a Python application with Apache/mod_wsgi (or nginx/uwsgi) is really no more difficult than deploying a PHP application with Apache/PHP-FPM or FastCGI.