6 ms·
Why PHP really won
- th0ma5 18y agothis is accurate. this is how i felt. php was a statement, and asp and coldfusion at the time perhaps were right there, too, but each had their tie-ins and paradigms, and php seemed to be positioned in opposition to that. and i agree anymore it would be best if it is in java or python or something if at all possible, way more maintainable.
- wvenable 18y agoThis article includes the same false assumption of just about every other article on PHP: PHP is Easy I'm not sure how anyone can claim that a language which only exposes the underlying C API of all the included libraries could be considered easy. Does no one stop to think that the reason 99% of PHP code is bad is because the language is actually hard? It's the C of scripting languages; it doesn't include a lot of fancy constructs or high-level abstractions. And, like C, that's what makes it powerful. I think confusion exists because PHP is extremely accessible. It's intimately connected with the web environment (more so, and less securely, in the past) making it quick to get started. But that has never made it easy.
- jayair 18y agoI understand what you are saying but I think most of the articles that say PHP is easy, they mean easy to set up and get started. I guess the right term would be as you said PHP is accessible.
- wvenable 18y agoThis article says "I think PHP is a great language for anyone to learn how to program with." So he clearly thinks PHP is easy rather than just merely accessible and I couldn't disagree with him more.
- wyday 18y agoYou're making the assumption that C is hard. C was the second language I learned (after QBasic), and it was easy enough to make working rinky-dink applications even as an ignorant preteen.
- shader 18y agoCompared to many of the alternatives at the time, php was easy. Until you are trying to make a large application that needs lots of abstraction and careful architecture, it stays easy. It is very easy to get something to work quickly in php, it's just hard to maintain a large project in it. And it is much more accessible than almost anything else when it comes to web programming. Compared to rails even, php is a snap to set up and use. Rails has the disadvantage of being a framework, which means more learning up front. Php has the disadvantage of being (until v5) almost impossible to organize coherently, and so becomes hard to upgrade later. Php is easy; until you've gone too far to turn back. :( That's why it's dangerous.
- wvenable 18y agoYou can build projects that large and easy to maintain in PHP, but you won't find many examples of that in the community. You can organize your PHP5 code just like almost any project in Python, Java, or .NET. But you do have to write a lot of code that isn't necessary in those other languages because they already have it included (and it's the standard way to do it). I find most PHP code in the wild totally appalling. It's easy to blame the tool.
- anc2020 18y ago> I'm not sure how anyone can claim that ... could be considered easy. PHP is Easy, and it's easier than Perl, I'd be surprised if you argue with me on that. PHP has very little to trip you up mentally (or at least that was definitely the case when it started winning). No closures, "arrays" are just hashes etc. PHP is not hard. Actually the hardest thing about PHP could well be its dynamic variable names, like $$foo. Neither is PHP powerful, it is extremely un-expressive when compared with just about any other modern programming language. With PHP you _just_ use the clean wrappers on the C API, and that is also easy to do, no knowledge of C required at all. It's so easy you can pretty much write PHP apps without knowing that "4" is any different from 4. I don't know if I've convinced you, but honestly, I would have a hard time making a language that was any easier.
- wvenable 18y agoPHP is a simple language, but that doesn't make it easy. PHP does give you enough rope to hang yourself, and unlike most other languages with a similar property (like C, C++, and Perl) PHP gets too much blame for that. I think Python is a far easier language. No $'s, much greater consistency, more available abstractions. You can pretty much handle most of the common complaints of PHP and build very large complex code bases, however, you have to put in the work. Other languages have that work already included.
- anc2020 18y agoAh, well this is where we differ, I'd say PHP is easy, not simple, and that Python is simple not easy. My reason for feeling that way hinges upon Python having more available abstractions. Scheme is an exagerated example of this. Continuations are a very simple idea, you can describe call/cc to someone without much hassle. But the implications of call/cc can be very difficult to grasp. The closure is a lesser example of a simple, pure abstraction which allows complex code through this devious form of simplicity. So that is (pretty much) why it is very easy to reach expert level in PHP but very very hard in Scheme. At the end of the day, what's easier to learn: closures, or the fact that a callback (in PHP) is supplied by giving its name as a string? Its easier to not learn something than it is to learn it :)
- rbanffy 18y ago"It's the C of scripting" No. C is a very elegant, if somewhat minimalistic, language. PHP is a kludge made of all sort of functions cluttering the only namespace there is. While K&R clearly understood the value of separating language from library, PHP deliberately ignores this lesson. I heard the most recent version (or the next, maybe) will support namespaces. It started as a quick-and-dirty solution for writing dynamic pages and, sadly, it shows. I somewhat fail to see the power of a language as something derived from lack of fancy constructs or high-level abstractions. And, BTW, C has a lot of fancy constructs and high-level abstractions: you just have to point the right libraries to the compiler/linker. I am sorry to tell you, but the main reasons PHP is so popular are the low cost of labor and the lack of interest by a large group of self-appointed programmers in learning anything, as you say, fancy.
- wvenable 18y ago"PHP is a kludge made of all sort of functions cluttering the only namespace there is" Yeah, how many namespaces does C have again? If you were to write a web application in C with all the same open source C libraries as are available for PHP, your only namespace in C would look almost identical. "While K&R clearly understood the value of separating language from library, PHP deliberately ignores this lesson" Ironically, this is exactly what made PHP successful. Everything is included in the box. It wouldn't have been half as successful without including every useful library they could find. "C has a lot of fancy constructs and high-level abstractions: you just have to point the right libraries to the compiler/linker." You're not going to get closures, classes, meta programming, etc, etc, from libraries in C. And guess what, PHP has libraries too!
- rbanffy 18y ago"Ironically, this is exactly what made PHP successful. Everything is included in the box. It wouldn't have been half as successful without including every useful library they could find." I am all in for including interesting stuff, but not at the expense of forcing everything in at once and thus cluttering the only namespace people have to work. While C has only one namespace, you only include the libraries you need. "You're not going to get closures, classes, meta programming, etc, etc, from libraries in C. And guess what, PHP has libraries too!" While C has no syntactic support for closures and classes, C programmers learn how to build them from scratch (or use some other person's library to support that - after all, C++ stated as a preprocessor that generated C code). Are you sure you are familiar with C?
- deleted 18y ago[deleted]
- rbanffy 18y ago"It's the C of scripting languages" Really, it's the BASIC of scripting languages.
- bprater 18y agoMmm... Matt's Script Archive. Good ole days.
- jcl 18y agoPerl: the language of "geniuses and academics"... Was it ever actually perceived as such? Or was the author simply intimidated by other, more academic languages as well? I'm pretty sure Perl doesn't do tail-call optimization like the article implies. My impression of Perl was always as a practical, "get-'er-done" language, much like PHP -- and prone to the same legibility/maintainability problems if care was not taken.
- smoody 18y ago"why would I use PHP for anything more than toy projects?" Clearly PHP can, and is, being used for projects that go well beyond being toy projects. I doubt, for example, that anyone would call Flickr, Facebook, etc. 'toy projects.' "But at my current job, I’m in charge of adding features and debugging a massive functionally-written PHP codebase. It is horrifying." Ah...there it is. His real complaint is about maintaining bad code and not about a bad programming language. I would argue (and even wager) that equally difficult-to-maintain code could be written in Java, Prolog, C++, Lisp, Forth, and Logo (well, maybe not Logo). I've written commercial applications in perhaps a dozen programming languages (including Prolog) and I've had love affairs with them all and yet I'm using PHP for my current project. But then again, I'm writing some great code and I love maintaining it! :-)
- wooby 18y agoYou're right. By "current job," I meant the job I was supposed to be doing as I wrote that post. I was pissed off when I connected finger to key. And there are more than a few discrepancies in what I wrote. The "community" I bill as PHP's greatest asset also ironically produced the fellow whose code I'm maintaining. And, me. So it goes. The underlying reason for my frustration, and the reason I wrote what I did, go far beyond the scope of PHP.
- Retric 18y agoIt's OK to complain about language features that make it harder to maintain code. Most Programs I know would rather maintain old Pascal code than any other language, but they hate writing in it. PHP is the other end of the spectrum where it's easy to write and extend, but quickly hit's a wall where it's extremely difficult to maintain. You also have "full spectrum" languages like LISP where fixing minor bugs can be reasonably simple or mind bogglingly complex depending on who codded it an how it was maintained.
- natmaster 18y agoI interned at Facebook, and let me tell you, there weren't many people enthusiastic about being stuck in PHP. A lot of modern sites are in PHP, because that's what the best choice was when they started (as far as they could tell), and now are stuck with that decision.
- grandalf 18y agoDid PHP really win? I haven't used it in about 4 years.
- vaksel 18y agoI'm still waiting for a post to get frontpaged titled "Why PHP didn't win"
- kwamenum86 18y ago"Did PHP really win?" Yes, for now. It is probably the most widely used language for web apps right now. Anyone who calls PHP a toy language is not skilled enough to write anything better than a toy in PHP. It is not really a criticism, just an observation. Until you become skilled enough in any language you are pretty much doing fancy versions of Hello World. With many languages the skill of the programmer matters more. For example, I am still struggling to understand why I would ever use functional language for anything but that is a) because I haven't needed it yet and b) I haven't taken the time to acquire the knowledge and skill needed to write anything more functional than toys.
- owkaye 18y agoIf you want easy, quick and accessible all rolled into one, try WebDNA. Nah, on the other hand I think you 'real' programmers would not be interested in using such a simple tool.
- lallysingh 18y agoI'd submit that PHP is for this generation of programmers what BASIC was to a lot of the older generation (including me). I started on BASIC on a Trash-80. Actually you can probably substitute some of the terms in this blog post for my journey from BASIC to now.
- wenbert 18y agoI really do not understand people reacting violently on how "PHP sucks/horrifying". PHP is just a tool that people use. Blame the programmer not the tool. I have had encounters with horrifying code with a lot of times BUT most of my complaints were on bad design and how programmers badly handled their code. "Being mindful of best practices in software development fundamentals can be more effective than adopting every latest technology." - Bill Karwin