11 ms·
PHP is much better than what you think
- modarts 14y agoOh, not this shit again. This article shows everything that is so wrong about people who continue to defend PHP /PHP developer for 6 years
- skrebbel 14y agoI think you forgot to back up an argument there.
- johnwards 14y agoComposer has been a game changer for me in the last couple of months. Getting setup on a big framework (Symfony2), or even a small framework (Silex) always felt like a bit of a pain.
- webmonkeyuk 14y agoGreat post. The grammar in the post title has a bit to be desired though. "than what"?
- j_col 14y agoEnglish is not his first language.
- deleted 14y ago[deleted]
- antihero 14y ago> PHP must have done something right, no? Shitloads of people also believe in organised religion or naturopathy, doesn't mean that's a good thing. > PHP is the best web platform... ever. So because it's nearly caught up with other languages and you can install stuff easily if you have the prerequisite of knowing about composer? Bullshit. I'm sure composer is great, but if your main argument is that PHP requires zero previous knowledge you can't really use that.
- eitland 14y agoHonest question: Do you have more than a months professional experience writing modern PHP? While I love appreciate the Java ecosystem with amazing stuff like Play framework, Scala, Camel (several apache sub projects actually), Python micro frameworks etc there still is something magic about PHP. I still haven't made up my mind but there is something about really fast turnaround time, transparency, and shared nothing from the ground up. Maybe "Just Works" is the word. (Cheap hosting and next to zero installation just to be an argument but I guess Play is even better in this regard.) (background: I am allowed to be opinionated on this (programming since I was a kid) professionally mostly Java but also PHP (greenfield, maintenance), and since this is also my hobby I have also scripted non-trivial python, tried rails back at 1.0 etc.)
- talkingquickly 14y agoI'd argue PHP is, for any project of reasonable size, harder to get up and running than say Rails. For any serious development a PHP developer (some experience, did several years of PHP dev) will have to setup a local instance of Apache/ MySQL/ PHP and deal with making sure libraries installed on this dev server match libraries on the production server. When it comes to deployment for both Rails (in this case) and PHP you can choose between pretty automated providers like Heroku/ PHPFog which make git deployment trivial or you have to deal with server set up and configuration. So I'm not really sure these days that for anything except the smallest projects PHP just works any more than any other reasonably popular web language?
- philjohn 14y agoPHP 5.4 has a local development server, so even that point is moot. But how hard is setting up apache, mysql and PHP? sudo yum install apache php mysql done. And anyway, for a serious project you need a local dev environment that somewhat mirrors live, and then staging (which exactly mirrors live).
- talkingquickly 14y ago
- FrameCluster 14y agoAm i the only one that begin to get tired of all this Pro an Con PHP threads ?
- drivebyacct2 14y ago"PHP is the best web platform ever", because it (finally) has a decent package manager. And don't mind that far fetched statement, the author will surely delete any rude comments. Congrats, PHP has a package manager. This does nothing to shake my feeling that PHP's most ardent advocates have little hands-on experience with the more full-featured alternatives. You know, like the ones that also have decent package management without PHP's baggage and limitations. edit: hell, calling PHP a "web platform" at all is insulting. Maybe if "web platform" is constrained to JSP/PHP/ASP style pages with no more complexity. Don't mind anything that requires websockets or anything other than... PHP style page rendering. Can we stop with the "PHP is everywhere so it must be good meme"? PHP's availability makes it convenient; it doesn't make it good. I said it before and I'll say it again despite its painful obviousness. If you want to write a random script and upload it to some $2/month hosting, PHP is great. If you're going to build a real webapp that is going to have developers working on it and real users hitting it, you're going to be on a VPS or colo or on your own metal and have all sorts of choices that... have package management and aren't PHP. And if we're talking about throwaway quickie scripts, who really cares anyway?
- illumen 14y agoFacebook.
- drivebyacct2 14y agoI very specifically didn't say that PHP couldn't be used to build real products, but that still doesn't (at least on it's own) make it good or make it the best.
- illumen 14y agoI guess the worlds most popular websites, and the vast millions of PHP programmers must all not really exist. They can't exist, and can't be making good stuff, because PHP is just doesn't work. Here is a list of template languages people on 'real' platforms use: Python. Airspeed, Castalian, Chameleon, Cheetah, CubicTemp, Django template system, Elements, EmPy, Evoque, HRL Powerful macro preprocessor for HTML, Genshi, Jinja 2, Mako, moody-templates, Myghty, Qpy, PML, pyratemp, Spyce, SUIT, Tempita, Tenjin, Template Toolkit, Templite+, thrases, ClearSilver, HTMLTemplate, JonsPythonModules, meld3, PyMeld, Pyxer, pso, Sprite, teng, webstring, XSLTools, PyPa, Genshi, kajiki, htmltmpl, Kid, SimpleTAL, CherryTemplate, AsciiDoc, Markdown, PyTextile, ReStructuredText, txt2tags, PottyMouth, Creole, Ruby. Radius. HAML. cs/Template. ERB, eRuby, Erubis, Galena, Tenjin, Liquid Markup. Ruty, PageTemplate, Amrita, Amrita2, Kwartz, Markaby. Maline. Builder::XmlMarkup, RedCloth, BlueCloth, RSmarty, Tempura, TAL, Curtis / Punk, Erby, RBML, RTALS, Tie, RVelocity, RailTags, Java. FreeMarker, SiteMesh, StringTemplate, Tea, Better Templates for Everybody, jxp, LSP, JCopist, Dynamator, RTFTemplate, Velocity, JByte, Jamon, JDynamiTe, WebMacro, Viento, IKAT, Bluprints, Transformica, Hapax, MiniTemplator, Xtempore, _Not a complete list._ PHP is a pretty good template language, with pretty amazing documentation. To deploy, you just upload a file. You could walk outside now, and start yelling "I NEED A PHP PROGRAMMER!" and you'd probably find someone pretty quickly. There are millions of hosts to choose from at tiny prices, who can provide support because they know the platform.
- jknupp 14y agoNo, it's exactly as bad _of a language_ as everyone is saying it is. In addition, it filled a void that is no longer a void (dynamic HTML generation in a programmer-friendly way) and has rightfully been supplanted as the go-to language for new projects by a number of superior languages.
- captain_spanner 14y agoGranted, there has been a lot of PHP bashing lately and by and large, those who bash PHP the most - whether they are right or not - generally have little to no meaningful experience with it and are re-iterating whatever they've read about it. Fact. However, this is just stockholm syndrome, plain and simple. Fabien is the author of Symfony.
- halayli 14y agoI'd stay away from a language that has function names like array_keys or allows you to write array("a" => "green", "red", "blue");
- TazeTSchnitzel 14y agoI find PHP's arrays amusing. It's as if Rasmus couldn't decide whether they should be associative or indexed, so he made them both. Although I suppose, strictly speaking, JavaScript has the same thing. (not intentionally, but you can make an array that is both if you really want to)
- 10098 14y agoIt's not a bad thing itself to make "arrays" work like that, except, you can't call them arrays then. For example, Lua uses a similar approach ("tables") and works just fine. AFAIK, it does certain optimizations under the hood to make sure numerically indexed tables behave efficiently (like arrays). Maybe PHP does the same thing, but its terminology is confusing. P.S.: I dream of a future where Lua is the primary tool for web development. It's perfect for that purpose as a language, but unfortunately, lacks the necessary ecosystem :(
- rorrr 14y agoWhat's wrong with array_keys? It's extremely useful. Java has keySet(), Ruby has hash.keys, etc. Your second argument is even dumber. Yes, PHP lets you do lots of things, which improve the speed of development. If you don't like it, don't write it that way.
- slurgfest 14y agoI wouldn't pick on the example, but you've made me curious: how does it improve the speed of development to have array("a" => "green", "red", "blue") ?
- rorrr 14y agoThis is just a side-effect of the fact that arrays in PHP are also hash-maps. That improves the speed of development, not your example.
- cheald 14y agoPHP is easy to deploy on. That's it. That's why it's popular. It's braindead easy to go from text editor to web URL, it's braindead easy to unzip someone else's project and run it. It requires virtually zero sysops experience to be able to use. You don't even have to worry about setting those +x bits like you used to in the good old cgi-bin days. For those of us who aren't afraid of a little ops work, there are far better options, and I say that as developer that's been using PHP regularly for going on 13 years.
- subigo 14y ago"PHP is easy to deploy on. That's it. That's why it's popular. It's braindead easy to go from text editor to web URL, it's braindead easy to unzip someone else's project and run it. It requires virtually zero sysops experience to be able to use. You don't even have to worry about setting those +x bits like you used to in the good old cgi-bin days." And that's exactly why PHP is the better choice for those of us who distribute software to non-technical users.
- gouranga 14y agoSpot on - you nailed it. The end user counts here, big time. A lot of the products out there would have precisely zero traction if they required literally hours of piddling around. If you compare it to JVM based commercial offerings, and I'll pick Crucible as an example here, it requires: 1. Find a working JVM that matches it. 2. Piddle around with PATH settings and JAVA_HOMEW. 3. Unzip it. 4. Lots of database configuration. 5. Frig around with ACLs.on disk so it can actually write to its home directory. 6. Frigging around getting it to run as a service using a JVM service wrapper or init script that you have to write yourself. 7. Extensive backup/restore scripting. 8. Hours of dredging through Atlassian's shitty web site. 9. Fuck around with Tomcat to persuade it to work behind a proxy. 10. Set up an IIS ARR or apache AJP/HTTP proxy in front so you can serve it on a decent URL or port. This applies to anything with stateful that requires any intevention other than copying files. That includes Python, Ruby, .Net (which is less painful I will say), Java, Scala, Clojure, common LISP. You name it. The only things that it doesn't occur on are: ASP, PHP. Most stuff in PHP is: 1. Unzip. 2. SFTP it up 3. Change the connection info in config.php 4. Run install.php and follow instructions. 5. Done. People don't care about nginx vs fastcgi vs apache vs this vs that. They just want it to work and PHP gives a viable and simple solution to that.
- mytrile 14y agoClaiming that "PHP has a better dependency manager than any other languages." is as funny as "PHP is the best web platform... ever".
- iamgopal 14y ago"homeopathy" arguments.
- skrebbel 14y agoFor reference's sake, this article is written by Fabien Potencier, the creator of the symfony framework. This guy's probably single-handedly responsible for lifting the PHP community to a higher level, by making great software (which, when he started, was pretty unique, with horrible hacks-upon-hacks like CakePHP being the norm), and by showing people how to do so.
- code4pay 14y agoyeah he has done an amazing job.
- risratorn 14y agoIndeed a good point, fabien is the catalyst in the current generation of PHP projects, just take a look at Symfony2, Symfony CMF, Silex, Composer, Doctrine, ... they all spawned in the trail of his work. I actually wonder how he gets so much work done.
- old_sound 14y agoI think Doctrine is not related to his work. The Symfony CMF, while part of the Symfony community, has been mainly pushed by companies like Liip AG
- rhspeer 14y agoProjects like Doctrine & swift mailer for email have been adopted and had development funded by Sensio @fabpot's dev shop. So while not a tightly coupled part of Symfony they are related through developers, community, and funding
- agumonkey 14y agoThe recent PHP releases are nice, but is there any plans about .. pardon me .. rewriting the core libs ? I guess they're close to zero. Even with a nice Object model, traits, closures and literals .. whenever I see old core functions poke it hurts. At the same time the world has moved: Scala, Go .. PHP still looks odd to me, even with his new found maturity.
- kapowaz 14y agoIt's like he didn't actually read Jeff Atwood's article, or if he did, he entirely missed the point. It wasn't a rant about PHP; it was a rant about people ranting about PHP! So much heat; so little light.
- jasonlotito 14y agoThis wasn't a response to Jeff Atwood's article. It was a response to all the articles, with Atwood's being the "straw."
- kapowaz 14y agoReally? > Rants about PHP are everywhere, and they even come from smart guys. When Jeff Atwood wrote yet another rant about PHP… That's not how it reads to me.
- shuzchen 14y agoI disagree, just because PHP has recently obtained features long available in other languages doesn't bring it close to being on the same level. All the other ecosystems are still light years ahead in terms of features, and contain fewer gotchas.
- freshhawk 14y agoWhat? You mean that while PHP figured out library management the other language ecosystems weren't just sitting on their hands?
- clown 14y agoYeah, PHP isn't perfect, we all know it has its quirks and oddities, but isn't that part of learning a language? What separates a hobbyist and professional PHP dev is experience, and knowing the correct method around such quirks. In the end, PHP gets the job done. I've yet to come across a problem in my 11 years that was due to a bug or a quirk that I couldn't overcome. Whether you defend PHP or rant about it, I still think PHP deserves respect within the programming community. It would be nice to see the end of rants and defensive posts, and for everyone to agree it's down to personal taste and experience. If we (defenders) are doing it wrong, then let us find out for ourselves.
- slurgfest 14y agoWhat doesn't "get the job done"?
- alexatkeplar 14y agoIf Fabpot seriously believes Composer is better than Bundler/apt/Maven, then he's crazy.
- Seldaek 14y agoHave you used it at all? I'm not going to pretend it's better than Bundler, we took a lot of inspiration from it and we may have a few unique features compared to it, but that's it. apt is pretty different anyway since it does system level stuff. Maven I think is insane, it does way more than a package manager should do. That said when you look at Python for example, the package management landscape is a scattered mess, and there is a new "greater better" solution every couple years. I wouldn't call that a better situation than what we now have with Composer.
- edwinnathaniel 14y agoMaven is actually pretty sweet and good. I know people have their own "perspective" when it comes to Maven: some said it's too big, too complicated, yadda-yadda. Some said it's the best tool out there. The thing here is that you don't need to know Maven that much to use it. Especially if you were to use it with IDEs. People typically use IDE to generate the absolute minimum Maven pom.xml file initially when they set up the project. From that point onward, if you're using mostly open-source library, the OSL website will give you snippet on how to add the JAR in Maven. All you have to do is to copy paste that snippet and you're done. People who said that Maven is overly complicated typically tried to learn Maven from Zero to Expert rather than to "just use it". It didn't take very long for me or many of my co-workers to become familiar and use Maven effectively from not-knowing to "yes, we can have Rails-like project structure/automation , deployment and packaging for multiple environment in place". Sometime I'd argue that there's no point separating Bundler, Rake, and Gems. You need all 3 of them and that's what Maven does (and more but you don't have to know until you do...)
- wilmoore 14y ago> Some said [Maven] it's the best tool out there. Generally these are people that haven't tried anything better. BTW, as someone who uses Composer and Bundler almost daily now (npm occasionally), I must say, Composer is right up there and it does offer some unique features that neither of the other two have. Let me say this. Composer is probably one of the best things to happen to PHP in a LONG time. I'm not saying I prefer PHP over Ruby, but given I am frequently tasked with providing PHP solutions, Composer is the way to go.
- alanbyrne 14y agoI am so sick of this kind of talk. What language do you like to code in? Really? That's great. Now shut up and go code in it. What difference does it make to you that I use PHP, Ruby or original ASP? My website achieves the result I desire. I chose the programming language I use because of reasons that made sense to me and my project, not because I want the approval of a bunch of hipster start-up kids.
- clown 14y agoMate, nail on the head. The way I see it, is if the final item is as you've envisioned it, what difference does it make what it's written in?
- freshhawk 14y ago> what difference does it make what it's written in Tell me you believe that after you've both maintained a project for years as it evolves and had to hire a team to maintain and extend it. And done this multiple times with different languages. Damn, the language ecosystem and surrounding community are in the top 3 things that matter most.
- cranklin 14y agoagreed. Language is nothing but a tool. A good programmer will get the job done with any tool.
- waxjar 14y agoEven good craftsmen prefer top-notch tools over tools in bad shape. I don't know if PHP is in a particularly bad shape nowadays, since I haven't touched it since 2005, but I do know that tools are just as important as the end result.
- debacle 14y agoTo be fair, this has been a while coming. There's so much PHP bashing that takes place now it's ridiculous. People take inefficiencies of the language from 5 years ago, tart them up as crimes against humanity, and then pretend that the only reason PHP is more popular than their language is because most people aren't smart enough to code in their language. Fabien, though I sometimes disagree with his technical choices, is one of the brightest stars in PHP right now and he's just putting forward a somewhat modest defense of PHP.
- cabirum 14y agoEvery blog post about PHP mentions its 'easy to set up for non-technical people'. I can't disagree more. PHP is as easy as any language should be. As if everyone implies the harder a language to use, the cooler it is. In my understanding a smooth set up experience is a sign community cares about the thing. Extensive and up-to-date documentation means the community is large and not stagnating. A language easy to learn and use is a properly designed language. If the language is hard to understand and write code in, it should not exist at all.
- tikhonj 14y agoLearning how to use a language is, essentially, an O(1) operation. The constant factor may be high, but it's just that--a constant. Moreover, it should not take you more than a couple of weeks to learn any language (save obviously impractical ones like Malbolge) well enough to use it for a web project. The policy at my school is that you should be able to pick up a new language well enough to use in a class over the weekend; I agree with this. Picking up a language to use for a web project should not take much longer. A language that's more productive gives you an O(n) benefit where n is the amount of work you do. Assuming you do a nontrivial amount of work, this is always going to outweigh the amount of time it takes to learn even the most difficult of languages. Now, in a perfect world, a language would be both easy to learn and productive. Unfortunately, in practice, the most productive languages are also the most difficult to learn. However, this doesn't mean they shouldn't exist--quite the contrary even; I think they are more important than languages easy to learn but less productive. Assuming you'll be spending any significant amount of time programming, don't pick a language exclusively because it is easy to learn!
- TillE 14y ago> Moreover, it should not take you more than a couple of weeks to learn any language This is why I find the "you can't find Ruby/Python/whatever developers" argument unconvincing. If you're a good software developer, you can learn new languages. You like learning new languages. It's only the crap developers who typecast themselves in one role throughout their career. And while I don't believe in all the nonsense about ninja coders and only hiring the best of the best, really, the ability to learn a new imperative language is not a very high bar to clear.
- piggity 14y agoYou can't polish a turd, but you can roll it in glitter.
- tikhonj 14y agoNamespaces, closures and traits are "all the bells and whistles you might dream of in a modern web language"? Really? Now I understand why Lisp users are smug. And that's ignoring the basic syntax touted as a feature. What I actually dream of in a web language (or any language, for that matter) is quite a bit more. I want to be able to get event-driven IO without writing event-driven code. I want to get parallelism for free or as easily as possible. I want to encourage smaller functions and reduced coupling. I want good, or at least decent, performance with no especial effort. I want a consistent and elegant underlying design rather than an ad-hoc collection of features somebody thought were useful. Ultimately, I want a high-level, modern language that's concise, fast to write, easy to maintain and reasonably performant. And PHP is none of those things. Which is why it's no good.
- notinfinland 14y agoWell, we can all dream, but what are you using now do get things done and make a living? I'm pretty sure Python and Ruby fail your criteria. Using the "perfect language" is a luxury that I for one can't afford. I need something that I can use reasonably easy and that is sought by employers. The fact that is has event-driven IO and parallelism (what kind of parallelism do you need for web sites?) is nearly irrelevant.
- tikhonj 14y agoYes, Python and Ruby do fail my criteria. Which is why I don't advocate them either. I'm currently using OCaml, but I would probably prefer to use Haskell. They are both far ahead of PHP. Assuming your website is doing anything non-trivial, parallelism would certainly be useful. Just because it's a web project does not mean you're not doing something computationally intensive, after all. But even if you don't need it, it certainly doesn't hurt to have the option! Event-driven IO allows you to maintain more connections on the same resources than a thread-based model. There is just less overhead per connection. That's going to be relevant for most web projects. If you could get this for free (that is, without having to rewrite your code like in Node.js), why wouldn't you want it? Just because employers seek PHP does not make it a good language, or even not a bad language. It just becomes a necessary evil. Besides, that depends entirely on the job market in your area. Where I am (near SF), PHP is not in very high demand where Java, JavaScript, Python, Ruby and Objective-C are. I've also seen jobs using Haskell, Scala and (obviously) OCaml. This is obviously going to be different elsewhere, but my point is that it's all relative and not a function of any particular language's quality.
- eren_bali 14y agoThey have maid a decent progress in 5.4 http://php.net/releases/5_4_0.php http://php.net/releases/5_4_0.php http://net.tutsplus.com/tutorials/php/php-5-4-is-here-what-you-must-know/ http://net.tutsplus.com/tutorials/php/php-5-4-is-here-what-y...
- Shish2k 14y ago"Has made great progress and will continue making great progress" is another way of saying "got it wrong first time and is still getting it wrong now" :P It took more than 10 years and almost 6 major versions of a supposedly quick and easy scripting language to have short array notation? Or binary numbers? Seriously? And this improves your faith that they know what they're doing?
- diamondhead 14y agovar_dump("gotta be kidding dude!")
- JonnieCache 14y agoThis post reminds me of the infamous Chris Rock routine: http://www.youtube.com/watch?v=f3PJF0YE-x4#t=130s http://www.youtube.com/watch?v=f3PJF0YE-x4#t=130s "I take care of my kids! I ain't never been to jail!"
- tomelders 14y agoHacker News really doesn't like PHP. There's a whole lot of blind prejudice in this thread Arguments against PHP are as futile as arguments in support of PHP. It's a programming language. The only thing that matters is the person using it. I'm sure Ruby, Node and Go are super duper awesome in a lot of academic ways, but unless we're talking about awesome things that have been made with them, it's just blah blah blah boring opinions no one should care about.
- hobin 14y ago"The only thing that matters is the person using it." Well, sure, I guess if you're really strange, you can be as efficient with Brainfuck as you can be with Python.
- rplnt 14y agoI don't think not liking language so broken as php is a blind prejudice. That language is garbage. His creator said so many times. You don't have to care about that, but don't act like it's not true.
- revdinosaur 14y agoIt would be easier to "act like it's ... true" if that statement weren't so damn objectivist. It's a non-ideal language that runs most of the web. There's an incredible nuance to that truth that makes it difficult to say that it's "garbage" (useless? no. unworthy of your time, maybe. I don't know what that means) I just don't get how people have time to be such puritans about things that don't immediately pertain to them and need so badly to make a binary judgement. Disclaimer: never touch the stuff myself.
- scotty79 14y ago> Hacker News really doesn't like PHP. But Y? function Y($F) { $func = function ($f) { return $f($f); }; return $func(function ($f) use($F) { return $F(function ($x) use($f) { $ff = $f($f); return $ff($x); }); }); }
- gingerjoos 14y agoIMO, more important than the language itself are the frameworks built on the language. Ruby might be _the best_ language ever, but without Rails it wouldn't have gotten famous. It wouldn't have mattered so much that Python is a beautiful language if Django sucked. If a good framework came out of the PHP community, we could forget that "PHP sucks". A good framework which prevented you from doing stupid things would be really great. Not sure if PHP has anything like that, at this moment. I use PHP and Python(Django) - work and play.
- einhverfr 14y agoI am not convinced. My argument is not that PHP sucks or that anything else. It is rather that PHP is lexically tied to corner-case development. In that case PHP is very good at some things but not really all that great for others. PHP started out as being a pre-processor for SGML documents. All PHP code is contained inside SGML program instruction tags. PHP has never changed this, so however it has developed it is still, in essence an SGML preprocessor because even today, all PHP code is contained in SGML PI tags. This means that your class files, etc. all begin with opening a PI tag.... Now that doesn't mean there aren't some really cool niches for PHP. Using something like PL/PHP and the native XML support in PostgreSQL, you could do some pretty cool stuff. Similarly for lightweight web development there is simply not a better language. But when you are building a framework where logic may have to be used in non-SGML environments, PHP is a very poor choice. This means when you choose PHP you are limiting yourself to web environments only. Better choices where there is any possibility of escape from the web include Perl, Python, and Ruby.
- dangrossman 14y agoI don't follow this argument at all. PHP cannot be used outside the web because each source file starts with <?php ? If I wrote a preprocessor for you so that your files wouldn't start with <?php, what would your argument be?
- einhverfr 14y agoIt would be a lot less of an argument then, and I would be willing to bet that the language would evolve into a far less web-centric area. But in part because of this, if you actually try to do anything outside the web (I have) in PHP, it's not all that pleasant. Also on the PI tag issue, I would rather keep my PI tags limited to the view or template. it leads to a lot better clarity. and your object classes are no longer technically SGML fragments ;-) This has some nasty side effects if you have a leading space before your opening PI tag and you aren't outputting SGML.... Oh, as a side note, by 'escape from the web' I guess what I really mean is 'escape from SGML-world.' There's a lot of the web that's not SGML-driven and there's a lot of the non-web that is (XML, DocBook SGML, etc). Bottom line, PHP is a decent tool for working with SGML but it is highly specialized for this. You run into weird things working in SGML mode but not in non-SGML output with things like leading spaces before opening PI tags if you move out of that. Since this is lexically part of the language, I just don't see it changing.
- belorn 14y agoEasiest language to learn for non-technical people? I do not believe that comment was made by someone who has tried to teach a non-technical person on how to program PhP. To get started to write a simple thing like a blog, you need to explain concepts like: classes, inheritance, public/private members, global/local decelerations, and context to name a few. Add that with the X number of ways each thing can be done, and the what ways are "right", and what ways are "wrong", and it becomes a huge information load for the student even before getting started writing something simple.
- josteink 14y agoPeople who argue for PHP as a language always brings up this one argument: "PHP gets things done". Great. It get things done. Quick and dirty, but it gets things done. That is all fine and dandy, but what when you need things done proper? How does it stack up then? Oh. You mean you have to consider input-data as actual text, not as some byte-streams which incidentally maps to the same character-set you used to write your code with? Oh. You mean I need to have locale-ware date, time and number-format handling? Oh. You mean I need to actually validate these input-data and sanitize them for SQL injections and all that before sending off to the database? Etc etc. When you need things not just "done", but done proper, how well does PHP stack up then? It is my opinion (as in opposed to fact) that when you add that one tiny, but oh so important clause, all arguments for PHP being the one language which gets things done falls apart. Or am I being too simplistic?
- InclinedPlane 14y agoI'll play devil's advocate here. Define "proper"? Does meeting a business need, bringing in money, putting food on the table, and paying the rent mean "proper"? If not, why not? PHP has a plethora of flaws, but it's still a serious tool and used to build creations of significant value, that can't be ignored. As far as quality, what platform do you use to guarantee quality? I've heard many stories about terribly broken code bases in every language that's out there, from C to Ruby and Python to Java.
- josteink 14y agoBy "proper" I mean building a piece of software which has a clean and maintainable implementation, logical semantics, proper encapsulation, and last but not least, which is solid. That is, should be able to withstand real world challenges and input-data without crashing, failing, silently failing, creating corrupted data or any combination of those things. Granted, it's been quite a while since I've done PHP, and it that sense the initial point of the article stand true, but when I need something done in PHP, I always find myself spending more time ensuring basic truths which a proper language should guarantee for me are actually true, than I spend writing code doing something. I find PHP silently failing all the time making debugging code hard. And it makes it hard to do things proper, because you may have failure-modes which you should have been able to catch, but which PHP "kindly" shields you from. Hope that clears things up.
- cmelbye 14y agoI'll admit, the new-ish built-in web server in PHP is fantastic and it definitely makes me want to use PHP more often. Configuring Apache, setting up virtual hosts, fixing directory permissions, etc. was horrible. Composer also looks cool, and I'm going to give it a try. I never understood PEAR/PECL/etc and was never quite able to get them to work properly.
- tysons 14y agoPHP is ugly? So are knives and forks but i still prefer to eat with them.
- robryan 14y agoI think at this stage it would be tempting to give some kind of penalty to PHP good/bad posts. Pretty much everyone who cares one way or the other has taken a position and there is a minimal amount of people actually moving one way or the other. Anyone who frequents Hacker News is well aware of the options out there for web development. If some people decide that they like PHP for any number of reasons and produce awesome stuff in it great. If some decide they hate PHP and go produce awesome stuff in another language then that is great to. One thing is for sure we have seen a lot more of "this is all the reasons that PHP is bad" than "PHP killed my startup" posts.
- slurgfest 14y agoThere are almost no "X killed my startup posts" at all. Indeed, there are very few "killed my startup posts" of any kind. So that means nothing about PHP. It means that people don't see a lot of benefit in publicly advertising failure and then flagellating themselves for their own choice of tools. People don't do that, they just quietly switch. People do hear about the problems with PHP, when they are mentioned. It's good to have specifics available rather than just delivering some general subjective statement, which is why we get one article after another highlighting various screwups in the project itself. You can use any Turing complete language to write programs. That sets an upper bound on how difficult it can be to do virtually anything. But this is hardly a defense of PHP. There are also principles of good engineering beyond "write something which seems to work for now in any way possible".
- LnxPrgr3 14y agoIf all your friends jumped off a bridge while programming in COBOL, would you follow them? If Visual Basic was a popular language, did that make it good? Maybe PHP Addiction is real: http://www.marco.org/2012/06/29/php-addiction http://www.marco.org/2012/06/29/php-addiction. It does seem like its users will go out of their way to defend their choice, as if it really matters what anyone else thinks. Jeff Atwood didn't really rant on PHP so much as link to another rant and lament that there aren't any decent alternatives that are as easy for the rest of the world to deploy. He even called for us to quit whining about PHP's shortcomings and do something about it. Why is that suggestion so offensive? What's wrong with trying to advance the state of the art of Web development? Did anyone attacking this "rant" actually read the whole thing first?
- conradfr 14y agoYeah we know, weak typing and function parameters inconstancies sucks. Move along :)
- shadowmint 14y agoTo be honest I don't like PHP for exactly the reasons I don't like javascript. It's easy to write in a way which is stupid. You can write good php and you can write cool stuff with it. It is easy to non-technical folk to pickup and write a little bit of. It's also amazingly easy to: 1) Write code which is broken and stupid (woops, left error_reporting(E_ALL) on! silly me. dumped all the passwords out into the website. woops. stabs designer) 2) Write code which is clever, but different from the coding style of every other piece of code in the project (>_> look, my js is so clever, its using closures for everything and events and... oh, you guys weren't doing that? um... ok. Well, now we have some piece of code that only one person knows how to understand stabs self important javascript ninja with spoon). 3) Introduce bugs. Managing your developers is really the key. If you can keep your php programmers in line, and keep bad code out of your project, php isn't that bad. ...but its that much harder to do when twice as many people are working on the code, and some of them belong to another team.
- Produce 14y ago1) Use a framework like Symfony2. 2) Yes, I agree, PHP encourages you to write esoteric code. Oh wait, what the fuck am I smoking? Better yet, what are you smoking? You can do this in every language I know. 3) Use unit and functional testing. You do use automated testing, don't you?
- j_baker 14y agoI think you missed the nuance in #2. Yes, you can write esoteric code in any language, but few languages actively encourage it like PHP.
- elliotanderson 14y agoRead the Symfony source, it's a template for how good PHP should be written.
- ing33k 14y agoIf people who bash about PHP , had used symfony2 framework, they would have changed their mind to some extent..
- Styck 14y agoIf you need to learn a framework then PHP loses simplicity, one of the few things its got going for itself. And if your needs validate the use of a framework, you'd probably be better off with RoR or Django.
- wilmoore 14y agoI love and use many parts of symfony2 (as well as other high-quality libraries); however, that doesn't change my highly negative opinion about the core PHP language. It is still a far cry from desirable, elegant, fluent, or expressive.
- Xylakant 14y agoOne major problem I see in this article is that the stats that are cited as "proof" that PHP is the most widespread language are skewed. * The sample is not representative. It's the top 1 million according to alexa. * The percentage cited is "x percent of all pages that we can determine are..." which skews heavily in favor of PHP since PHP exposes it's version by default at least in older versions while other languages such as ruby don't. The percentage of pages that turned up as "unknown" is not listed. * They don't give an error margin for their stats. * Same is true for the Content-Management Sites. It skews heavily in favor of wordpress because lots of sites do have a wordpress blog installed somewhere. I do acknowledge that PHP is probably leading by market share, but I'm not convinced that it's as pronounced as Fabien wants us to believe. Composer is a nice step forward, but it's still behind of what bundler can do. One of it's main problems is that it created a completely new package format, so you need a new package repo - now they're at a respectable 1900 packages. Bundler uses the regular rubygems packages and has the full list of over 40.000 gems available. All tools that used to work with gems still work. There's also a couple of features that it's missing (local overrides for development, binstubs, etc.) but I guess that's just catch-up work. That the commandline interface looks plain ugly is probably just personal preference (heck, why do I need to call 'php composer.phar' instead of 'composer'?) Last but least, it's pretty much a feature-wise copy of bundler - that's maybe "on par" but not "the most awesome and best thing in existence". So yes, PHP has taken huge steps forward but it's still ugly. You can get shit done if you know your way around and you can write amazing and elegant software in it - it's just harder than it needs to be.
- jasonlotito 14y ago> (heck, why do I need to call 'php composer.phar' instead of 'composer'?) You can. http://getcomposer.org/doc/00-intro.md#globally http://getcomposer.org/doc/00-intro.md#globally $ curl -s http://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer $ composer --version Composer version 6573fd3
- Xylakant 14y agoright. I could write a short shell wrapper as well - but why do I have to? I don't have to with pip or bundler.
- mxey 14y agoFunny. People criticize PHP the language and the PHP fanboys retort by praising PHP the platform. Jeff Atwood more or less said that we should provide the platform advantages of PHP in other languages in order to steer new developers there.
- debacle 14y agoYou can't provide the platform advantages of PHP in other languages because either there aren't enough programmers in that language (Ruby, Python) or that language is fundamentally much more difficult to work with (Java).
- InclinedPlane 14y agoSo create something new.
- debacle 14y agoBut I like PHP. Even with its numerous warts, it's the easiest language I've ever written.
- slurgfest 14y agoThere are plenty of people writing Ruby and Python. There is another reason, which is that some of PHP's design choices seem easy but make things harder down the line.
- jasonlotito 14y agoJeff Atwood wasn't the first to say that, by a long shot. PHP devs have been saying it since Rails made Ruby popular. That it's 8 years on, and Atwoods rehashing old arguments is telling.
- wazoox 14y agoOK, I hate PHP. It's ugly, and I don't want to code anything with it. Good developers mostly aren't available to small shops like mine; I don't have anything to get them in. I must do with young, cheap developers anyway. Young cheap developers knows only one language, to be chosen among PHP or Java (that's just the way it is). So I'm getting a whole lot of interns coming in for two months at a time, and they mostly know nothing but PHP. so we make them code PHP. They built a nice application in a few months for the quarter of the money I would need to get an half-decent <your preferred language here> developer. Getting more done with less money, from a business perspective that's the only thing that counts.
- emperorcezar 14y agoUsing intern developers to write PHP. I really hope you're using a framework, because that above sentence is a recipe for disaster.
- wazoox 14y agoNo, we're using careful project management, code reviews, the interns are very happy because they're learning a lot, and the code is tolerable. Code elegance doesn't put food on the table, anyway.
- emperorcezar 14y agoActually that sounds fine. Good they are learning.
- soc88 14y agoI hate this apologist bullshit. Yes, we know that there are a lot of PHP sites on the net, we aren't retarded. If PHP wouldn't be such a wide-spread problem, people wouldn't have to spend so much time fighting against it. One positive thing: His post was didn't kill my spell checker, that's an impressive achievement for a PHP developer. You don't see coherent sentences that often from those people.
- netshade 14y ago"PHP is the easiest language to learn for non technical people". I believe that is a flawed statement. I think looking at the number of existing sites and using that as evidence that because there are a large number of PHP websites, the website authors must have made some value judgement at some point on the easiest language available and arrived at PHP, is incorrect. I think the early availability of PHP as a web language, the perception of it as an easy language, and the wide install base drive its adoption. I helped my brother learn PHP and JavaScript at the same time, my belief (at the time) being that PHP would be the easiest server side language to learn. Watching him struggle to: A) find adequate, modern PHP tutorials, B) see good examples of data structures, and C) understand the division between server side and client side development made me question my decision to have him learn PHP. By comparison, while JavaScript lacked a centralized site (php.net) to educate its users, he was able to find more than enough resources to help get learning fast.
- bbrizzi 14y agoWell, the reasons I started learning PHP were: 1. It was the most popular web language when I started (in 2000), the alternative being ASP... 2. It's extremely easy to use and set up. Most starting programmers/developpers work on Windows. If you want to start developping on Ruby or Pythons you have two possibilities: - Install linux, which (whatever you may think) is not easy for any newbie. - Try to work out the Windows ports of your programming language of choice. In the case of ruby, you have to find windows installs for ruby, gems, bundler, rake, rails (or whatever app you want to use), git, probably cygwin, your webserver of choice, etc... Most of these elements are not made for the Windows ecosystem and the ports are usually pretty poorly documented. If you use PHP, you just have to: 1. Install XAMPP. 2. Click on "launch server" 3. go to http://localhost/ http://localhost/ This is why PHP is still popular.
- emperorcezar 14y agoPHP is big because 10 years ago, it was the best choice. Back then, the non-microsoft options were Perl, ColdFusion, Java, and PHP. PHP was the best for web development out of that. This isn't the case anymore. PHP has been far surpassed by Python and Ruby. PHP is a wonderful templating language. Where does my opinion come from? I switch us from PHP to Python after writing a large CMS in PHP.
- ericingram 14y agoI've written "large" systems in PHP and some things annoy me, but I imagine this is true with other languages too (I hear from Ruby and Python devs all the time, some things get annoying). That said, I spend most of my time on the web writing templates, and PHP is amazing at making that easier. There's a good reason PHP is used in ~78% of all web sites -- most of them are basic blogs or content sites. Most web development is just templating attached to a business model layer, so why not use a language ideal for templating?
- Shish2k 14y agoDoes PHP have a function to generate a new URL that is the current URL with one of the GET parameters changed yet? After working with PHP for years, I've taken a look at rails and a few python frameworks, and looking back to PHP it makes me sad that I have to keep using a "web oriented language" that doesn't come with basic web features :-(
- wilmoore 14y agoThis is an excellent point that I think too few PHP developers care to admit.
- deleted 14y ago[deleted]
- theycallmemorty 14y agoWhat would happen if you could put a <?python> tag with python code right in a page just like you do with the <?php> tag? Is this even theoretically possible? I feel like the biggest advantage PHP and classic ASP have is that there is a low barrier to get the most basic dynamic content working. If you're not a programmer, you don't need to understand a framework or a design pattern to get things going.
- slurgfest 14y agoThere's no reason you couldn't. It wouldn't be Python, but you could do it by defining a new file format to be parsed by the server (mod_whatever). The earliest Python web frameworks were obsessed with this kind of stunt and it gave rise to a profusion of templating engines, some of which look pretty much exactly like what you are discussing. I think what happened is that people tried it and found that the advantage is not that great, but the disadvantages are substantial for things significantly beyond "hello world".
- dotborg2 14y agoDo PHP engineers even know what multithreading is? ps. I don't mean crontab
- mgkimsal 14y agoDo you even know how many days/weeks/months I've seen engineers waste on tracking down threading issues? ps. I don't mean sewing shirts.
- dotborg2 14y agoPHP programs are indirectly affected by those issues anyway
- ericingram 14y agoI've technically made $millions in transactions on web sites built with PHP, and I've never had to confront multi-threading.
- Danieru 14y agoI would suggest that serving webpages falls into the set of embarrassingly parallel problems. The solution is to saturate your cpu running multiple instances.
- chris_wot 14y agoDon't forget to turn off the Easter eggs when you use your default install of PHP (expose_php = off in php.ini). [1] 1. http://en.wikipedia.org/?=PHPE9568F36-D428-11d2-A769-00AA001ACF42 http://en.wikipedia.org/?=PHPE9568F36-D428-11d2-A769-00AA001...
- mekwall 14y agoAs a developer I have great respect for Fabien Potencier and his contributions to the PHP community. Sadly thoguh, I think he's done so in vain. You cannot fix what's infinitely broken. * PHP may have evolved to support many new methods and features that is expected from a modern language, but mixing and mashing ideas and implementations from other languages in a semingly random fashion doesn't make a language good; only messy. It still and always will lack a proper philosophical design. * PHP's ecosystem is far from healthy. It's flooded with outdated and/or badly written code, so it really doesn't matter if dependency management is good. Wordpress is proof of this, just look at the source. * PHP is neither easy to learn or code (correctly). It's just so forgivable that you can do more or less everything wrong and still have a working application. Fabien, you should know this. * PHP is a resource hog compared to the competition; even with the tiniest stack. I.e. running Node.js will use less then a third of the resources compared to a LAMP stack. There will never be a "best language" to rule them all. Every situation have different needs. Sure, PHP have filled its purpose during the years, but I'm certain that we've hit peak-PHP. It's the IE of programming languages, and its slow death have already begun.
- rbanffy 14y ago> PHP is used by 77.9% of all the websites (...) PHP must have done something right, no? My favorite answer to this is "because millions of lemmings cannot be wrong". PHP is a horrible language. Like FORTRAN and COBOL. Like BASIC. Let me be clear about this. It is a horrible language. Having said that, a good programmer can make good programs even in the most horrible (and I'm deliberately excluding the deliberately horrible ones) language. It is possible to write elegant PHP just like it's possible to write concise Java. All it takes is lots of discipline. Something most programmers, sadly, lack. PHP is immensely popular and its runtime is incredibly easy to deploy. I sometimes have small fights with Apache to enable some WSGI app (I never remember every detail I have to include in the configuration) but PHP is unusually easy to set up. That probably is a good explanation on why it's so popular on cheap hosting - because it's easy to manage. That also makes it a good choice for quick projects such as hotsites. I prefer to do those on Google's App Engine, but this is a question of taste, not of availability. In all fairness, those sites could be developed in ASP/VBScript and I wouldn't regard that as a mortal offense - they'll live for months under a single release lifecycle. Use whatever gets the job done for less. And programmers without discipline usually cost less. Much like there are millions of lines of COBOL, FORTRAN and BASIC we'll never get rid of, there are millions of lines of PHP that'll keep running for decades. PHP is a fact of life. I won't be using it for any new projects and would question the sanity of anyone willing to start a long life one with it, but each developer must choose which tools they want to spend their lives with.
- tubbo 14y agoPHP still can't access email inboxes inherently, can't do CSV import, can't download packages from GitHub the way Bundler can, doesn't support metaprogramming, has a hacked-together OOP system, and has an absolutely horrid syntax. Why am I meant to use PHP again? Oh yeah, because you haven't discovered Ruby yet.
- karlshea 14y agoUh, Ruby can't do most of that out of the box either. Lots of those things you mention you need gems for. And really? Can't do CSV import? What does that even mean? I mean, it's a programming language. There are packages you can get that will do those things, and if there aren't, you program them. I'll give you the point on the syntax.
- glenjamin 14y agoComposer is pretty nice, but there's at least once vital package that's missing from it: PHPUnit. As long as the only decent testing framework[1] isn't in the package repository, It just seems somehow not "official" enough. [1] which still has more than its fair share of legacy warts
- brendoncrawford 14y agoFrom the article: > PHP is used by 77.9% of all the websites whose server-side programming language is known. Selection bias. PHP Has a higher tendency to advertise itself.