4 ms·
I started using PHP in the late 90's, back when it was pretty useful in the sense of being able to embed code directly in web pages, so I liked it in a very gen
by michaelchisari 16y ago
I started using PHP in the late 90's, back when it was pretty useful in the sense of being able to embed code directly in web pages, so I liked it in a very general sense. Then I started building larger apps, and I started to get the kind of attitude about it that leads very many programmers to declare that "PHP sucks" or "I hate PHP." Then, I started building even larger apps, and I cursed PHP for every line of code I had to write.
Then, something happened. Yes, the language matured, but I also started using application frameworks in PHP, which addressed many of the issues I had with PHP, and then I built an MVC framework from scratch, based on what I'd learned.
Now, I just don't care. I'm not going to defend PHP as a good language, not even it's creator will do that, but when people go on about how terrible PHP is, my first thought is "well, then use it more, and eventually you'll stop caring."
I stick with PHP, specifically for open source, because of it's install density, because it is extremely flexible, and because I know all it's weird quirks and inconsistencies so well that they no longer bother me. I wouldn't mind switching to a more structured and consistent language if it came up, but I don't see PHP as a limitation for anything I want to accomplish, and haven't for a very long time.
And anyways, terrible code is terrible code, and when I think about having to delve into projects that are spaghetti, or procedural, or have no separation of concerns, I don't blame the language for my frustration.
- andrewjshults 16y agoCompletely agree - looking back at some of the code I wrote in PHP3 there were huge issues with the language but it was more that I had no idea what I was doing than an inherent problem in the language (granted, PHP5 is lightyears ahead of PHP3 and I'm certain that the improvements have made writing good code easier). Today, it has all the tools that if you learn better general coding practices (like MVC or at the very least separation of presentation from logic) it doesn't get in the way and you can just do what you want. I actually think the $$ syntax can be useful, but like anything it matters how you are using it.
- phr 16y agoI remember when "structured programming" was the new silver bullet all the guru's were talking about. This must have been the late 70's or early 80's. I was programming in DEC Basic-Plus on the RSTS/E operating system on a PDP-11. All variables were global, as I recall. We had subroutines and user defined functions with arguments but no local variable scope. We had if-then-else, but I think only a single statement was allowed for the "then" branch, so the cleanest way was often "if condition then gosub 1000 else gosub 2000" or something like that. A lot of the legacy code I had to work with was classic spaghetti-code with goto for flow control. Oh, I think we had only single-character variable names. Those were the days. But I worked out how to adopt the new structured style to the limitations of the language, and learned a lot. Better languages make better tools, of course, but it's the hacker's attitude that really matters.
- treeface 16y agoI'll even go so far as to say that coding in PHP is downright pleasant when you use a framework like CodeIgniter or Kohana. At the same time, I have to use Joomla at work and I sometimes catch myself with a partially-tied-off noose around my neck. It really comes down to what framework you choose.
- gaius 16y agoAny problem in computer science can be solved by adding a layer of abstraction, apart from the problem of too many layers of abstraction.
- caf 16y ago...and apart from the well-known two hard problems.
- panic 16y agoYou mean cache invalidation, naming things, and off-by-one errors?
- eru 16y agoIf you don't like naming variables, use Fourth. (You'll still have to name functions, though.) Against off-by-one errors, abstain from any from of loop. For the real hard problems, like deciding whether your program has crashed or just takes a long time, give up.
- iclelland 16y agoNaming things was even harder when filenames were restricted to five characters or less. That's why they had to name it Forth.
- joshu 16y agoThat would be solved if only we had a framework framework.
- Groxx 16y agoPHP seems to have a culture of poor abstraction / old libraries, which I think is largely responsible for the hatred. The language itself is... a language. There are better-for-X and worse-for-X, but languages are fairly inconsequential compared to what's already coded in the language (standard libraries, popular frameworks, your application, etc), which can be any degree of good or bad regardless of the language.