9 ms·
PHP: the quiet powerhouse
- mgkimsal 14y ago"Dozens of new language-specific communities have now entered the fray and brought along their legions of devotees with them, and many of those devotees see PHP as being passé. I even had the following happen to me, and this is absolutely a true story and can be verified by our VP of Operations, Richard Kotulski: I was in an elevator with O’Reilly’s very good “PHP Cookbook” in hand and an older gentleman scoffed at me and said, “PHP? What is this, 1920?” This really, actually happened. I doubt it would’ve have happened if I had had a Python or Ruby book in my hand." Which... is even odder because some evangelists like to point out that python and ruby are older than PHP, as if that means much. While I generally agree with the points, many PHP strengths are also weaknesses. For example - "Direct HTML embedding." It's nice and easy, but because it's so easy, it leads to unescaped output, and xss exploits and such. PHP does let you as productive as you want to be on the web, either with raw PHP or with one of the myriad frameworks. The author's point that no other language gives you that is, I think, another one of PHP's strengths (but yes, is essentially a weakness in the wrong hands as well). EDIT - have been using PHP since early 1996 - almost since its inception, and have watched the criticism (and occasional hate) ebb and flow over the years. That seems to be the only constant to PHP. :)
- EternalFury 14y agoWith regards to "Direct HTML embedding."... PHP is a Web scripting language (which I consider to be very different from a general-purpose programming language or even a scripting language), designed and developed to generate markup. I have seen a lot of "templating" libraries (Smarty among them) and all they do is mimic the basic syntax of PHP using something else that is not PHP. I know the theory ("designers don't know how or want to program"), but learning PHP conditional statements or loops is as difficult or simple as any "templating" library that asks you to learn its exotic syntax. Now, MVC is good and one should avoid blending presentation code with models and controllers, but most MVC frameworks fail when they require you to instantiate a gazillion extra objects, just to render a Web page.
- deleted 14y ago[deleted]
- mgkimsal 14y agoagreed on templating systems...
- lucperkins 14y ago1. The gentleman's comment was indeed quite curious, and I wish that I could have used this info as a comeback. Thanks! 2. Direct HTML embedding could be seen as a weakness, yes, but that all depends on the kind of project. That's why I describe it as a good language for beginners and don't make any claims for or against it beyond that (beyond its demonstrated scalability, which I can only imagine being quite difficult in light of the security and other concerns that you voice).
- dansingerman 14y agoI have a few nits with this post, but am mostly irked by the comparisons between PHP (a language) and Rails (a framework)
- lucperkins 14y agoYou're quite right that the analogy isn't perfect. The point I was trying to make, though, is precisely that PHP development can proceed without any recourse whatsoever to a framework. Jumping straight into web dev without an accompanying framework like Rails or Sinatra is a complete non-starter if you're a Rubyist. So you're quite right, but I hope you would agree that the Rails/PHP comparison, in spite of its imperfections, is compatible with the point I was trying to make.
- dansingerman 14y agoYes, I agree. You make the point a lot better here than in your linked post - i.e. with PHP, you can 'just start'. With Ruby you need to choose a framework, understand enough about how it works, and where things go before you can even start to do "hello world" Although that is not necessarily a bad thing.
- djur 14y agoI got my start with Ruby web development using ERB in a CGI script. Same with Perl before and Python after. The option to do that has not been taken away.
- zaptheimpaler 14y agoI'm just mad about the title. The post was about how PHP is quick and dirty for simple stuff. The reason all of the other web frameworks exist is because once you get past the learning curve, you can accomplish a lot in a very short span of time. If anything, they are the powerhouses, not PHP.
- debacle 14y agoPHP has some of the most robust and modern frameworks available today. Symfony draws on the best of almost every modern framework, and leaves a lot of the crap behind.
- fleitz 14y agoThe issue with PHP isn't that you can't make it do a whole bunch of things that are wonderful... It's why PHP would be the best tool for the job once you have a specific objective in mind. When you have a specific problem to solve other than 'supported by millions of cheap webhosts' PHP is rarely the best choice. It's like a swiss army knife, it's highly useful in many situations and a good tool to have in your pocket, but if you know you're going to need to unscrew something you should probably bring a screw driver.
- malachismith 14y agoWell... of course you should always determine Use Case first and then choose technology based on that.
- warmwaffles 14y agoI enjoyed PHP. I enjoyed Ruby. If I was to do a complex project that would require a lot of integration with external services, I would want a good OOP language like python or ruby. There are something PHP does nicely than Ruby does. Visa versa. However in all the PHP apps I have made / used, their structures started out with good intentions and then descended into pure chaos. There isn't a unified package manager for Python and PHP that is widely accepted. Ruby has rubygems and bundler. Maybe next time when I start building another PHP app with namespacing, I'll behave better and make my designs more decoupled so that components can be removed and added, provided their interfaces match.
- nickpresta 14y agoI would say that pip is regarded as the standard, unified package manager for Python. http://www.pip-installer.org/en/latest/index.html http://www.pip-installer.org/en/latest/index.html
- debacle 14y agoIf you come from a namespaced language, using PHP namespacing will only make you want to hunt down the PHP devs, point to PHP's namespacing implementation and say "Are you proud of what you've done?!?!?" over and over.
- deleted 14y ago[deleted]
- josegonzalez 14y agoComposer exists for PHP and most major frameworks are moving towards it: http://getcomposer.org/ http://getcomposer.org/
- guard-of-terra 14y agoYou're killing kittens by using PHP. PHP could be a wonderful thing if not for its original sins. It is easy and fast, but it is also bad. It is "good enough", and for many years it prevented just "good" from arising and gaining adoption. I would pick "good" over "good enough" even if it costs me a bit because I think this is fundamentally right.
- deleted 14y ago[deleted]
- lucperkins 14y agoBut how often does trying-to-be-better-and-failing come along and torpedo good-enough-for-the-job?
- guard-of-terra 14y agoWould you listen to "good enough" music or watch "good enough" movies? When I ask this, I think, many do. But I don't. Do you?
- lucperkins 14y agoNo. Sometimes I spend a lot of time and effort seeking out niche genres and digging through blogs and news sites to find "good" music. But sometimes I don't want to put in all that effort, and then putting on "Kind of Blue" or the first Weezer album is "good enough." There is room for both approaches to music listening.
- testing12341234 14y agohttp://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de... 9600+ generally concise words on many, but not all, of the issues with PHP. As a summary, PHP isn't "out of fashion" as much as people are tired of continuously being misled and abused by their language of choice.
- duskwuff 14y agoOn that note, a physical metaphor for PHP which that post inspired: http://www.flickr.com/photos/raindrift/7095238893/in/set-72157629492908038/ http://www.flickr.com/photos/raindrift/7095238893/in/set-721...
- wvenable 14y agoThat is unfortunately a terrible article. It's probably 33% accurate, 33% the author being confused, and 33% just plain wrong. Continuously trotting it out on every discussion on PHP does everyone a disservice.
- mschalle 14y agoI agree that PHP is good for starting learning web development and for small sample apps, but from experience I really think that large-scale PHP applications are not easy to manage. The codebase becomes disorganized very quickly, and tracking down a piece of code's "hierarchy" (what it inherits from, what methods it has available, etc.) can be a whole new kind of hell. IMO, of course.
- gouranga 14y agoAll large apps are a pain regardless of the framework. It's called coupling. Building your application as a series of small applications that work with each other is a solution that has worked for me.
- hoopscity 14y agoI think people are comparing apples to oranges. Ruby on Rails is as some have stated, a framework, much like Zend or cake or CodeIgniter. I think the author is spot on in this post. PHP is not without its warts, but as a programming language for web development, it is scalabe, reliable and robust. Can you perhaps do things faster or more elegantly in other languages? Sure, but writing good clean code is really in the hands of the developer. I can do everything in python because its written in python doesn't mean that that code is going to be designed well or scale well.
- lucperkins 14y ago"Scalable, reliable and robust." Couldn't have said it better myself. Thanks.
- djur 14y ago"Scalable" and "reliable", perhaps. "Robust" actually means something, though, and PHP is not it. Its wretched approach to error handling prevents that.
- raquo 14y ago[off-topic] If PHP and Javascript are the only programming languages you know, you really should experiment with at least one or two others. It comes easier than expected. For example, check out http://www.diveintopython.net/toc/index.html http://www.diveintopython.net/toc/index.html. You can't know what you're missing out on until you try something new.
- jonathansizz 14y agoBut if you already know PHP and Javascript, why not try branching out a bit instead of learning Python, which is very similar overall? How about a lispy language like Racket, or a statically typed functional language like OCaml, or a 'big' mainstream applications language like Java?
- raquo 14y agoThat's the point. Python is similar to php/js (which is why it's easy to pick up), but in contrast to them it is extremely well designed (imho). You suddenly understand how many of the quirks you have to go through every day coding in php/js are in fact artifacts of these two inconsistent poorly designed (imho) languages rather than programming as a whole.
- techiferous 14y agoIf you are just starting out as a web developer and aren't planning on changing careers anytime soon, the #1 language you should learn is JavaScript. It, or languages that compile to it, will still be in fashion in 5 or even 10 years. That's because the web is shifting to thick clients, and JavaScript is the only choice in browsers. JavaScript is also finding its way into server-side code (Node.js). "I think PHP is the perfect language for beginning web development for two reasons: Direct HTML embedding." Server-side view rendering is on its way out. So this is not a real advantage. "I find it more than a little strange that PHP is simultaneously (a) out of fashion, and yet (b) absolutely everywhere." This is simply how technologies rise and fall. By the time a technology is ubiquitous, the original problems it solved have changed and new solutions are being created. Just because you have a bunch of legacy code running lots of web apps doesn't mean it's the future--it means it's the past. Also, why pick a language that pays poorly? Ruby is by no means inferior to PHP, and you will get paid more per hour to program in Ruby.
- gnaritas 14y ago> Server-side view rendering is on its way out. So this is not a real advantage. No it isn't, client side view rendering is just experiencing a faddish phase; it'll fade. It'll never overtake server side rendering on the web.
- techiferous 14y agoIt's not a fad. It's driven by the increasing growth of mobile devices ( see http://www.digitalbuzzblog.com/2011-mobile-statistics-stats-facts-marketing-infographic/ http://www.digitalbuzzblog.com/2011-mobile-statistics-stats-... ) The Internet is becoming more ubiquitous. Being "on the Internet" will mean less and less being in front of your computer. The proliferation of devices you can access a web app from is increasing (smartphones, tablets, more coming in the future) so it is becoming more useful for web apps to be like a "smart database in the cloud" and for the view logic and code to be on the client.
- techiferous 14y ago
- snorkel 14y agoI've lived Ruby land and Python world for quite some time and I must say it's good to be back in home in PHP where getting things done doesn't involve clever semantics and tying yourself up in layers of abstraction. Oh yeah, and it's nice to read code that has comments explaining what the hell is going on too (seems Rubyists and Pythonistas don't believe in comments, you know, because that'd make the code too obvious)
- gouranga 14y ago+1 for pragmatism. Despite the stigma attached to PHP, it's my go to language for web stuff because it gets shit done very very quickly. You can't beat drop file, edit, refresh and entire deployments which can be done with cp/scp and no process restarts.
- spahl 14y ago"gets shit done very very quickly" In what way does PHP help to get things up and running faster than other languages?
- dr42 14y agoHave you used PHP? Spend 5 minutes with it and you'll understand; a very expressive language, simple to learn, massive library of functions, massive number of examples to copy, no framework to learn, no syntactical overhead like in Java, practically everything works with, or has bindings for PHP. I prefer to work in python, but I don't much care anymore, each language has it's strengths and weakness' but PHP most definitely is good for getting things done "very very quickly"
- spahl 14y agoYes you can get up and running quickly with php, but my comment was mostly about the fact that it is not much slower in other languages (most of the time not slower at all). And yes I did a lot of PHP but that was 5-6 years ago. I know things have changed a lot since then but the language still has a lot of the same flaws.
- shuzchen 14y agoI don't think MediaWiki or Wordpress are good examples of how PHP scales. Those are the two examples of extremely bloated pieces of software that require a lot of hackage to get to scale. I've done deployments of those on mid sized VPS'es and it's always a pain getting it responsive while still able to hold a good number of concurrent connections. The only way anyone gets Wordpress to scale is to put caching in front of it. But now the heavy lifting is being done by memcache or varnish, not by anything engineered into Wordpress or PHP.
- owyn 14y agoThe only way to get mediawiki to scale is to do the same. :)
- jmathai 14y agoAny sort of scaling is a hack (not always bad). Good luck if you expect to scale to Wikipedia or Wordpress(.com) levels without using external tools such as Memcache and Varnish.
- ericingram 14y agoAny language or framework can be tough to scale. Didn't twitter find this out in the early days?
- drostie 14y ago"It’s been very interesting beginning my trajectory in web development in 2012... [PHP] might be the best language to use in gaining an understanding of the fundamentals of web development... No web development language outside of PHP grants you the kind of flexibility to both (a) produce genuine functionality from scratch, outside of an MVC framework, and also to (b) work within the bounds of MVC in deeply sophisticated ways if you wish." I believe you have overstated your case, perhaps due to inexperience with other languages. In particular, claiming that any modern scripting language is inflexible sounds a bit crazy. I have attempted explaining how to get a WAMP stack running, with EasyPHP, to an absolutely new-to-web-dev indiviual who was curious about creating a chat room. Let me just say that the situation is ten times better now than when I was the same age and was poring, lost, over Bruce Eckel's Thinking In Java trying to do the same thing, which must have been sometime around 1999/2000. These efforts to teach a newcomer reminded me that there's a lot I take for granted. There is a step where you are saying "okay, we've got to see where Apache is; what port is it listening on, how can we get you to phpMyAdmin; here's how you set up rows and columns in your tables and think about a database; no the reason it's not working is because you saved as '.html' and not '.php'; I know you've seen URLs that don't end in '.php' but that requires invoking the Rewrite Engine and teaching you about .htaccess files; oh the header modifications can't be the first thing you emit; here's the docs, you basically have to search them because there is no organizing principle and no way to find out what you can do..." I agree, Python+Django will make you learn a bunch of weird "modeling" stuff first. To me, setting up the data model at the beginning of an app is like inputting a character name at the beginning of an RPG: as some sources testify [1], you can easily waste several hours on purely aesthetic concerns before you even really start to play. Nonetheless, Python+Django comes with a lightweight dev server and an interactive console and a routing table, as well as a template language. The knowledge of the database is internalized to the language, so that I don't have to teach someone how to use phpMyAdmin but rather when to use a ForeignKey. If we talk purely about learning to develop on the Web then PHP has much, much more useless overhead. Sure, eventually we will have to get a production-ready web server communicating with the application, but that can be abstracted until later with Django: it occurs as an up-front teaching cost with PHP. I say this not even as a Python aficionado per se. If anything I like Node, and Node is nowhere near either of them in offering pleasant functionality. [1] http://www.cad-comic.com/cad/20030630 http://www.cad-comic.com/cad/20030630
- spahl 14y agoThis does not justify chosing PHP for a new project. There are hundreds of examples that show how bad PHP really is. Why make the choice of using a broken language when there are so many better alternatives? I strongly believe that using a complex, non consistent and hard to debug language actually slows down development and is even dangerous. Being "absolutly everywhere" is not an argument. COBOL, PASCAL and FORTRAN used to be everywhere too.
- lucperkins 14y agoNo, "absolutely everywhere" is not an argument by itself. But sometimes ubiquity is earned. If Facebook powered its front end using FORTRAN, I would call it a quiet powerhouse, too!
- spahl 14y agoYou can always build things with at scale, even with flawed languages (look at javascript). The thing is, why choose a flawded language when there are others less flawed (nothing is perfect) for new code?
- bryanbibat 14y ago> I think PHP is the perfect language for beginning web development for two reasons: "Direct HTML embedding" and "Straightforward file organization" After thinking about it a bit, it seems that your reasons for suggesting PHP for beginners are about the same as the reasons people gave three decades ago when suggesting BASIC as a language for beginners, namely the norm of having GOTO and global variables everywhere. Just as GOTO and global variables make it easy for a beginner to easily pick up programming, embedding raw code in your pages and having only one file organization makes it a lot easier to pick up web programming. And yet at the same time, all four are eventually shown to be "considered harmful" - the only ones who advance are those who are willing to abandon the first things they learn while the rest are doomed to mediocrity. Now don't get me wrong, I don't think PHP or even BASIC is inherently bad (well, they are, but at least they're not MUMPS or Brainfuck). I just don't think teaching bad practices to newbie developers is a good way to promote a language.
- ayi 14y agoPHP's problem is it's soul. I will make an analogy about this. My analogy will be local, but i will explain it so you can understand. PHP is my university, Gazi University. It first established in 1926 as a Teacher Training Institute. Nobody knew that there will be a medical school or faculty of fine arts or even a faculty of dentistry. 1926 was the third of our newly established Republic and we needed teachers. So, Teacher Training Institute was born. Our main campus is very small. Law School or dentistry school is not in the campus. Because, as i said, nobody knew we need them in 1926. Ruby, C# and many other languages are METU: Middle East Technical University. METU was designed as a university. So, they got a gigantic land in Ankara (capital city of Turkey). They build all their building in there. Back to the PHP: PHP was born to solve one problem. Just one problem. When they got another problem, they solved it and added the function or implementation in the language. PHP is not designed at desk, it was not "feature-complete" at version 1.0. It's still getting more mature as version numbers increase. For example we get "traits" in 5.4. PHP is also Windows too (both Microsoft and PHP in a HN comment :) The most un-loved things in this community). Remember the video which a guy installs Windows 1.0 and successfully upgrade it to every version of windows with all his data and programs up to Windows 7? even doom from 1993 works! (http://www.youtube.com/watch?v=vPnehDhGa14 http://www.youtube.com/watch?v=vPnehDhGa14) PHP is like Windows. I know the "parameter order inconsistency" problem too. But you can't solve it after this point of time. You just can't. Like windows, every program should work after the upgrade. There are millions of millions PHP sites. after a "apt-get update;apt-get upgrade" they should work. By the way, sorry for my bad english.
- Killswitch 14y agoHere's an idea.. If PHP is so bad.. Don't use it. Simple as that. Let the people who want to use it... There's absolutely very minimal things wrong with the language. Everyone's quick to compare it with Python or Rails or something else saying "PHP does this wrong that Python does right" well, if PHP did everything the same way as Python, Rails, or something else, when what makes it different? Who wants to use a language that doesn't have some severe difference? It's annoying seeing people waste their breath on arguing why PHP is so bad... Especially when many people/companies have proven PHP is good and can be scaled and used on high trafficked sites, yet 90% of the arguments are how it doesn't scale. Just because you have used Wordpress or built a quit todo app in PHP that took you 5 minutes and that's the extent of your usage with the language, doesn't make OR break the language. Quit complaining and let PHP users use PHP, and you continue using whatever the language you use is. Signed, A Python, PHP, and Node.js developer.
- lucperkins 14y agoNice to see PHP get some love from polyglots!
- Killswitch 14y agoThanks, I am also an App/PHPfog user too. ;)
- lucperkins 14y agoThen double freaking high five :)
- ralph 14y agoPHP has all the beauty of Perl with none of the power. I think part of the reason folks pillory PHP is their annoyance that people are using it as their first language and may never move beyond it to the better alternatives available.
- getsat 14y ago> There's absolutely very minimal things wrong with the language. I guess you missed this post that highlights a few of them: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de... I agree on using what you enjoy using, but implying PHP isn't riddled with flaws is absurd.
- davidlumley 14y agoIt's interesting seeing so many people defending PHP by suggesting that because Facebook use it, it's good enough for anyone. From what I understand, Facebook continue to use PHP because it's heavily embedded in all of their systems, and they continue to develop with it despite other languages being more attractive? ( see http://www.quora.com/Why-hasn-t-Facebook-migrated-away-from-PHP http://www.quora.com/Why-hasn-t-Facebook-migrated-away-from-... )
- chaostheory 14y agoBack when all you had for choices were Perl, Java, and C++ it was easy to see why PHP got big. However there are issues with starting out on PHP now: 1) It's really only meant for web development. 2) There are other languages now that are simple to learn, flexible (more than just for web apps), and powerful (Python, Ruby, and now even Javascript) Unless PHP has another major evolution, like its move to OO; (or unless I just missed something else big) I just don't see the point of using it unless you or your company been using it for years already. This article doesn't have any real compelling arguments. Maybe all of this will change once Facebook releases Hiphop VM AND people actually start using it. To this day, I'm not sure why no one started using Hiphop enmass and why people love using the inefficient eval method. O yeah there's also an issue with PHP and logic dealing with concurrency, in that there isn't a good way to distribute work within an app. Then again I could be completely wrong.
- jmathai 14y agoAgree with all your points except this one. >> Maybe all of this will change once Facebook releases Hiphop VM AND people actually start using it. The argument that PHP doesn't scale is a strawman. To scale anything to the likes of Facebook or Google you have to have serious architecture in place regardless of the language you choose.
- chaostheory 14y agoI wasn't thinking of scale. Correct me if I'm wrong, but wouldn't hiphop VM essentially expand PHP from just being a web language into something more?
- jmathai 14y agoI stand corrected. I hadn't thought of it really. But the thought of PHP for non-web kind of makes me cringe even if it's translated into another language by an intermediary. For sanity sake I'm going to assume NO :).
- mgkimsal 14y agoI've been working with PHP since 1996 and rarely see eval being used. I've worked with hundreds of companies training PHP developers, seen inside (and written) some very large codebases handling millions of dollars of transactions, and don't recall seeing eval in any of them. "it was easy to see why PHP got big" It's easy to see why it's staying big: 1. cheap shared hosting to get started 2. most hosts offer one-click installation of any sort of application people need on the web (blogs, shopping carts, calendars, social networking, file hosting, etc) 3. 15+ years of knowledge about what works and what doesn't when attempting to scale PHP to large needs. 4. ubiquity which keeps a large pool of reasonably priced talent available, which perpetuates the cycle. When there's a competitive language that can be placed in a directory as FOO.abc, I can hit it as /FOO.abc and have it execute, with html content type sent by default, it'll have a running jump at dethroning PHP. The barrier to entry is the lowest out there, but the heights it can scale to are facebook-level and beyond.
- narrator 14y agoPHP is the broken english of the Internet. Easy to learn, practical, inelligant, ad-hoc.
- brendoncrawford 14y ago> But I also think that it might be the best language to use in gaining an understanding of the fundamentals of web development OP admittedly has less than one year of web development experience. Perhaps it would be wise for OP to gain a more thorough understanding of web programming before coming to conclusions like this.
- lucperkins 14y agoI use words like "might" very intentionally! And yes, right you are that my conclusions about things might change radically. I'm already appalled at some of the things that I thought even weeks ago...
- cafard 14y agoI will simply point out that one can do a good deal with a little code using WSGI. As for templating, Python has for some time had very handing formatting.
- LnxPrgr3 14y agoThere's no denying PHP's popular, but that doesn't mean it's the best tool for the job. Most of the arguments I see against it though are really problems with the programmers using it. "Look at this horrible code I have to put up with! The comments are inane and useless, there's no structure at all, and I'm stuck in a chain of nested if statements 10 layers deep and I have no idea what's going on. PHP sucks!" As Jeff Atwood said, "sufficiently incompetent coders can write FORTRAN in any language." "But the converse is also true: sufficiently talented coders can write great applications in terrible languages, too." PHP wasn't exactly designed… it was formed, like a ball of mud picking up various debris as it grew. It shows, too, especially if you've had the pleasure of working with PHP 4. (I can only imagine what earlier versions were like.) I can't for the life of me think of a language with more brain-dead "reference" semantics. It's just bizarre. Their date functions miraculously manage to be worse than their C counterparts. I could go on and on. But in the end, using PHP doesn't doom your project to failure any more than using the current flavor of the week guarantees your success. Jeff Atwood, again: "The only conclusion I can draw is that building a compelling application is far more important than choice of language." So why are we still comparing programming languages instead of writing code?
- surrealize 14y agoBleh. Would you call McDonald's a culinary powerhouse?
- lucperkins 14y agoCulinary powerhouse? No. But it is undeniably a powerhouse in delivering food consistently and reliably.