3 ms·
> 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 a
by 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){ ... }