15 ms·
PHP Sucks But I Like It
- monkeyfacebag 14y ago"WSGI in Python gets you part of the way there, but you still need to import a library to talk to the server. This makes PHP just plain easier to get off the ground for web applications." The first sentence is mostly accurate, but I disagree strongly with the assertion in the second sentence. Grouping related functionality into libraries reduces the cognitive load of programming. The same could be said for his assertion about the benefits of HTTP as a "first-class citizen." I do agree that getting a PHP application running on a LAMP stack is easier than say getting a WSGI implementation up and running, but this has nothing to do with libraries.
- ircmaxell 14y agoMy intention was the full process from creating the first file, to getting a server to serve the content is far easier to do in PHP than Python (granted, in Python it's pretty much boilerplate, but there's a lot more than needs to happen). As far as the benefit of first-class vs libraries for handling the request, that's something to consider (as there are arguments on both sides)...
- drivebyacct2 14y agoThat was pretty thoroughly discussed in the original thread. Yes, PHP throws everything you can do into functions in global scope. It's "convenient" but it's messy. It's also, correct me, but an incredibly trivial distinction.
- nthitz 14y agoCan we all just agree PHP (like many other languages) has some bad features / design choices (evolutionary features, whatever you wanna call em), yet when used properly under the right circumstances it does the job quite well?
- Killswitch 14y agoAgreed.
- mikeash 14y agoI'll accept "does the job". I don't accept "quite well". I've seen PHP do a lot, but I've yet to see it do anything truly well.
- jrockway 14y agoIndeed. It lets you write verbose tangled masses of SQL, code, and HTML. That gets the job done, but when you see the power of declarative programming and good libraries, you can do a lot more with a lot less code.
- methodin 14y agoWhat does it not do well?
- mikeash 14y agoSince I haven't seen PHP do anything well, I'd posit that what PHP does not do well is everything.
- mattbriggs 14y agoA truely masterful carpenter could build you a pretty impressive desk with nothing but a few jagged rocks. But put better tools in his hands, and the same guy will do a much better job, faster. That was the point of the original blog post, and this one didn't really contradict it in any meaningful way.
- Killswitch 14y agoWell said. PHP gets a lot of crap thrown at it, but in the end, one of the biggest companies and second biggest website on the internet uses it as it's primary language.. If it's good enough for them, it's good enough for any of us to use.
- kaiju 14y agoThe wide adoption of PHP has nothing to do with it's actual quality, though.
- ssmall 14y agoIt helps though. High adoption, especially with bigger companies, leads to my eyes on the code which can cause a higher quality run time. It also means there are more tools, frameworks, reference books, and ultimately jobs out there for it.
- drumdance 14y agoYes. The availability of a bunch of easy-to-Google tutorials, libraries, hacks, workarounds etc should be included in the overall utility of a language.
- prodigal_erik 14y agoI just followed the first half dozen search results for "php tutorial mysql". All of them resort to pasting string literals into queries, with not a prepared statement in sight. One of PHP's problems is that it quickly reached a critical mass of self-perpetuating misinformation between the ignorant and the slightly less ignorant, ensuring unforgivable security blunders for years to come. At this point I don't know how anyone could solve this, short of dramatic language changes that make those crappy old tutorials obviously unusable.
- huggyface 14y ago"If it's good enough for them, it's good enough for any of us to use." This doesn't follow at all.
- trebor 14y agoI'm with you Anthony. I work all day with PHP even though I love Ruby (and Rails, and Sinatra...) because practically ALL our client base wants either a static site or Wordpress, or another PHP-based CMS. Few of our clients have the budget for a custom web app with its own custom web stack to power it. There's almost nothing faster to get bootstrapped into a functional application or script than PHP. Assuming your server is already configured with PHP you just upload the project. PHP 5.3 and 5.4 give me great hope for the future of the language.
- mattbriggs 14y ago"rails new project-name", and I have a full app. and heroku makes deployment just a push away. Its not like phps ease of use is not a good thing -- it is. but other languages/platforms aren't _that_ much harder
- deleted 14y ago[deleted]
- trebor 14y agoAnd Heroku sure makes sure that you pay a pretty penny for that convenience. You pay thru the nose for 1 worker and a 20MB database! So you go to a Linode for $20/mo... and immediately need a Sysadmin (or the experience) to handle building the server. A few clicks and you can get a really good shared host with PHP-compatible for $10/mo. It takes more expertise to deal with the other languages and their platforms. Affording a sysadmin to manage the servers can be quite expensive.
- deleted 14y ago[deleted]
- ranza 14y agoI would still have to say that PHP, by all its flaws, gets the job done. And in the end of the day thats what count to me. That might be a bad view to have but I've been sticking with it for a lot of years now even though Ive flirted with a lot of other languages. Its still the girl i get home to every night
- natesm 14y agoI don't like the "tools" analogy that always comes up. For example, Robertson screws are better than Phillips head screws, which in turn are better than flatheads. All of them are tools, and they all effectively do the same thing. But the Robertson screw is better.
- jack-r-abbit 14y agoAnd yet I have 5-6 different sized Phillips and standard screw drivers. I've never even heard of Robertson screws.
- natesm 14y agoWell, they're good for the same reason that hex/Torx is, and I think most people have a set or two of those.
- stan_rogers 14y agoThey tend to be known outside of Canada as "square drive" screws. They can't cam out, are nearly impossible to strip in normal use, and will stay on the driver tip without assistance in almost any attitude other than straight down. They're the darling of woodworkers even in the United States of Phillips. The American bias towards towards the Phillips screwdriver has mostly to do with the gift of patent made to the government in order to support the war effort, putting them effectively into the public domain. They were better than flat screws/drivers, but that's not saying much: when I worked in aircraft maintenance, about half of all of the Phillips-head captive fasteners (Camlock or Dzus type) on inspection and access panels needed to be replaced between periodic (400-hour) major inspections due to stripped heads.
- jack-r-abbit 14y agoI've never encountered those but now I know why I have several square tips in my drill's driver bit set. Thanks
- Jach 14y agoThe best screw is the one which I have a screwdriver/drill head for! (Thus PHP is still the best language for a newbie on $5/mo or less shared web hosting!) But really I agree with your point that these metaphors and analogies into other fields hurt the discussion since it changes to being about pointing out problems with the analogy rather than about whatever the discussion was originally about.
- grandalf 14y agoI've found that the people I know (even excellent programmers) who love PHP tend to hate Ruby and find it extremely confusing. Maybe there is just a fundamental brain-structure difference between individuals... I don't actually think PHP is easier for a beginner than something like Sinatra, so I don't buy the explanation that PHP is easier for those new to programming.
- drumdance 14y agoI like both.
- flyosity 14y agoI think there may be something to this. I'm used to programming in PHP and Objective-C and going to Ruby just throws my brain for a loop. I just can't grok it, and reading someone else's Ruby code confuses the hell out of me. I'm more of a designer than a programmer, so take this all with a grain of salt, but coming from a C-style language background I totally feel like a different part of my brain needs to turn on (or off?) to program in Ruby.
- Jach 14y agoHave you tried Python? My own biased opinion is that Ruby is a problem for some people in the same way Perl is a problem for some people: too much syntax. (I happen to like both Perl and (more so) Python but not really Ruby for other reasons.) Edit: Oh, and PHP was my first language. My feelings about PHP are more or less expressed within this submission.
- 286c8cb04bda 14y agoThis is a warning for future you: Objective-C, when used like Objective-C and not just C-with-classes, is a lot like Ruby. Both have a shared heritage in Smalltalk. E.g. http://www.cocoadev.com/index.pl?HigherOrderMessaging http://www.cocoadev.com/index.pl?HigherOrderMessaging
- mattbriggs 14y agoThe problem is that if all you know is a C style language, getting past non c style syntax is a hard job all by itself. I had a hard time learning clojure, but once I did it was a snap to learn common lisp, scheme, and elisp. Same kind of deal (only I think, a bit more extreme), its a matter of having the right background
- danso 14y agoI used PHP awhile back, but how much of its inconsistencies can be resolved without fundamentally changing the language's positive features? That is, not caring about backward incompatibility. Like, I can't imagine the inconsistency of "==" has any bearing on PHP's flexibility.
- wvenable 14y agoIf you don't care about backwards compatibility you leave a lot of users in the lurch. PHP4 to PHP5 took years to migrate over and Python 3 still hasn't taken over from Python 2. Perl 5 and 6. If you can't get syntax/semantic changes adopted in a single language then getting a whole new language adopted is a non-starter. I think the core PHP developers should take a long look at the inconsistencies of the language and formulate a plan to reduce/eliminate them without breaking backwards compatibility. In some cases, it should be relatively easy but in others it will be very difficult. The inconsistency of "==" would be hard to fix while making sure old code still runs correctly.
- 1SaltwaterC 14y agoThe biggest WTF was that "tied to Apache" section. Being running nginx + PHP-FPM for years, even before FPM was accepted as official SAPI. I guess that people still think that they know better than their sysadmin regarding how to set up a production environment (regarding to the php.ini rant). Maybe because the sysadmins know that expose_php = off turns off those pesky easter eggs. Or they are better at Reading The F[...]riendly Manual (http://www.php.net/manual/en/ini.core.php#ini.expose-php http://www.php.net/manual/en/ini.core.php#ini.expose-php). Had a good laugh at the complaints about PECL libraries that provide "everything but the kitchen sink". Last time I checked, it was still "The PHP Extension Community Library". People should complain about that particular project, if they need to. It has nothing to do with the internals team. Wondering how he could forget about the <script language="php"></script> bit.
- mortenjorck 14y agoPHP is like living in a big city. There are all sorts of things wrong with it, like homelessness, noise pollution, traffic, bad neighborhoods, corrupt politicians, perennially-under-funded public transit; the list goes on. And yet there's nowhere like it. You could move to some ideal community somewhere, and maybe you visit there now and then because it doesn't have all those other problems, but all the arts and culture, all your favorite restaurants and bars, all the meetups and hangouts and friends and co-workers make your city worth the downsides.
- brendn 14y agoI like your city analogy. I won't stoop to comparing programming languages to actual American cities, but I would counter that "PHP is like living in [a particular] big city." Here's where I disagree: it's not enough to say "hold your nose around these parts, but it's OK because those few blocks on Main St. are worth it." There will be flaws in any city, and sometimes due to mismanagement, the flaws will be neglected until blight sets in. Here's where the citizens of the city need to step up: they either flee the city and it continues to decay, or they acknowledge the flaws and address them. Don't just accept the downsides! Fix things. Make improvements. The city only thrives on the investments of its citizens.
- Kilimanjaro 14y agoI've always said somebody should fork php and polish it, getting rid of all the backward compatibility issues and leaving intact the ease of use and deployment. It is unbelievable to me how nobody sees the huge potential it has in books, blogs, docs, frameworks, etc. Like giving php a second chance, this time done right. Rasmus himself should give it a try as a side project with a different name. I would follow him from day one. PHP has a lot of bad parts and, like javascript, is asking for its cup of coffee. The time is ripe.
- fs111 14y agowhat holds you back?
- brendn 14y agoThe arguments in favor of PHP that I continue to hear run along the lines of "everybody's using it" or "it's not that bad if you know what you're doing" or "it's great because it's the Swiss Army knife of languages." It's hard to argue with those sentiments. And I think the root of the argument stems from the diverging convictions of two distinctly different camps of hackers. There are grease monkeys who love tinkering and see value in a tried-and-true tool that works everywhere. And then there are the craftsmen who strive for elegant code and choose their tools carefully. (There's truth in both of those aspirations. Let's not get carried away in value judgements between the two camps.) But hearing "PHP sucks but I like it" sounds like Stockholm Syndrome to me. There are some great aspects to PHP that other web stacks and frameworks could learn from. Yet there are some major flaws that actually get in the way of productivity. I hope we can keep the discussion constructive and learn from both camps in building the future of web programming.
- jack-r-abbit 14y agoI don't think you necessarily meant it as such but in this context it appears that you just referred to PHP developers as "grease monkeys" and other developers as "craftsman". One could misinterpret that as a highly offensive remark.
- brendn 14y agoI think you're misinterpreting my use of "grease monkeys" in general as offensive. (I said not to project value judgements in my original comment. There are certainly developers who see "craftsmen" as aloof purists who look down on practical matters. It cuts both ways.)
- jack-r-abbit 14y agoWell... The Google tells me that "grease monkey" is a derogatory term for a mechanic. I don't think it is generally meant to describe someone that you think very highly of. The Google also tells me that "craftsman" is a person who is skilled in a particular craft or art. I think this is generally used as defined. The Google never lies. Using the two together seems to imply we have "skilled people who care about elegant code and tool selection" and "mechanics that like to tinker". Like I said, I don't think that is how you meant it... but that is how it comes off to me. And I tried really hard not to project any value judgement.
- FuzzyDunlop 14y ago> "You don't need a library or a framework to talk HTTP." With 'library' typically meaning 'extension' in PHP parlance, you do. The socket methods are part of the Socket extension, cURL is an extension you have to compile in. The only reason you'd not actually notice this is because, unless you compiled your own copy of PHP, it will have been done in the default install bundled with the OS, or in xAMP, and will have automatically been injected into the 'global' scope. This is all just daft, though. You could go on forever with the "it can't do X but it can do Y" schtick, with any language.
- wvenable 14y agoI think what he meant wasn't about sockets or Curl, but the fact that PHP is integrated with the HTTP request itself. You don't need an extension for PHP to output HTML or read in query parameters. Python developers user REPL to quickly test elements of their code or play around with the language; PHP developers hit refresh.
- Jach 14y agoThere are two other interpretations of the statement. One is that you don't need any import/includes, which is true of PHP but not of Python. The second is you don't need any external dependencies "out of the box", ignoring the fact that someone had to make the box[1] for you at some point which you mention here. This is true of PHP, and only half-true of Python: I remember messing with "import cgi" at some point, Flask is so so much better. [1] Gentoo's USE flags for PHP (the ones with - are the ones I haven't compiled in for my box): apache2 bcmath berkdb bzip2 cgi cjk cli crypt ctype curl curlwrappers fileinfo filter ftp gd gdbm hash iconv ipv6 json mysql mysqli nls pdo phar posix postgres readline session simplexml sockets spell sqlite sqlite3 ssl threads tokenizer truetype unicode xml xmlreader xpm zip zlib -calendar -cdb -debug -doc -embed -enchant -exif -firebird -flatfile -fpm -frontbase -gmp -imap -inifile -intl -iodbc -kerberos -kolab -ldap -ldap-sasl -libedit -mhash -mssql -mysqlnd -oci8-instant-client -odbc -pcntl -pic -qdbm -recode -sharedmem -snmp -soap -suhosin -sybase-ct -sysvipc -tidy -wddx -xmlrpc -xmlwriter -xsl
- ygmelnikova 14y agoCan't we all just get along?
- mickgardner 14y ago"PHP Sucks" [....] Yep, agree with that part....
- greggman 14y agoThe problem is everyone is conflating things. PHP the language sucks ass. PHP the environment (part of the server + html processor + no setup or configuration for most users + page is the app + etc..) = WIN for many many people. Not a single other environment has ever duplicated that. Until someone does they'll never displace PHP. It's ripe for the replacing but understand that it's not just the language, it's the entire environment surrounding it.
- frankus 14y agoI found myself thinking whether one could make an heir apparent to PHP that removed the suckiest aspects and left the same basic "no configuration, just a bunch of files" model in place (any inherent problems with that model notwithstanding). Sort of how SVN fixed some of the most glaring issues with CVS without forcing people to really change their habits. But I think that the things PHP really has going for it (huge installed base of the runtime, huge installed base of legacy apps, huge developer community) aren't going to smoothly make the jump to a new language. And once you've given up that sort of backward compatibility, why not fix a few other things while you're at it? Still, I think there might be potential for a PHP-like language that breaks some backward compatibility but fixes a lot of basic things like unicode support, modules loaded at startup or runtime rather than as a ./Configure flag, syntactic quirks, etc. Something where you could spend a few minutes to a few hours (max) refactoring a PHP script into PHQ (or whatever you want to call it) script and gradually modernize your app.
- Zarel 14y agoMost of the gripes with PHP seem to do with its syntax, error messages, and inconsistent function naming. It seems like it shouldn't be too difficult to write an automatic converter from "PHP" to "Improved PHP", which might solve a lot of these issues.
- conner_bw 14y agoObligatory "If PHP Were British"? http://www.addedbytes.com/blog/if-php-were-british/ http://www.addedbytes.com/blog/if-php-were-british/
- rometest 14y agowait. after reading the earlier article, i started learning python. you guys cant do this. i need to go back to php now or wait till the wwIII is over
- vectorpush 14y agoA novice programmer can write dangerously horrible code in C or C++ but we don't say those languages suck (most of the time). I'd rather debug/refactor a poorly engineered PHP project than a poorly engineered C or C++ application any day of the week.
- Locke1689 14y agoNo, pretty much everyone says that C++ sucks.
- Scriptor 14y agoC or C++ aren't competing with PHP. You'd have to look at Python or Ruby in this case. While it's definitely possible to write shitty code in those languages it doesn't provide nearly as many ways to screw up. Besides the lack of language features like @ (error silencing), you won't find nearly as many terrible tutorials out there created by some guy who's been learning for a few weeks and decided to write a blog post. Given a poorly engineered PHP or Python project, I will always pick the latter. However, if I were to start a project on my own I'm confident enough in my PHP that the language choice is harder to make.
- vectorpush 14y agoC or C++ aren't competing with PHP. That's true, but my point is that there isn't such a visceral hatred for C and C++ even though they are widespread and notorious for memory leaks, vulnerabilities, indecipherable corporate quagmires (perhaps due to an over-engineered OO architecture or 700 line functions or opaque symbol names or dependency hell, etc). Besides the lack of language features like @ (error silencing) Red-flag bad practices exist on all platforms. The horror story of a PHP project littered with error suppression is like opening up a C project and discovering that the control flow is guided by a 200 label GOTO architecture. It's not PHP's fault that the programmer abuses the language, it's the employer's fault for hiring a highschool student at $15/hr.
- 10098 14y ago> indecipherable corporate quagmires (perhaps due to an over-engineered OO architecture ...) Sounds like Java to me :-)
- Kilimanjaro 14y agoI code like this in php, python, ruby, node and golang: include 'app'; include 'models'; include 'templates'; $data = models::getCustomers() $view = templates::parse('customers',$data) app::show($view) What's so ugly about that? I bet you I can build 90% of sites on the web with that basic snippet of code. In any language...
- vectorpush 14y agoAgreed. My web applications maintain nearly identical structures (with slight variations due to some OO quirks across platforms) regardless of language choice. At the end of the day most imperative scripting languages are semantically equivalent.
- anonymousab 14y agoIt's often called "c++ on the internet" but C++ was never a pretty language. At the very least, it is better than ASP. Good lord, ASP is such a hunk of garbage.
- TomGullen 14y agoASP.net or Classic? Remember Classic was first released 14 years ago, a lot of great stuff has been built in it. I'm not sure why you would call either a hunk of garbage!
- datasage 14y agoMaybe its just me, but there seems to be a bit of confusion between frameworks and language. Or many its that some languages are now rarely seen out of the frameworks that made them prominent. Because PHP was built for a web environment and has features that make it quite useful out of the box, for that environment. With Ruby or Phython you need to do extra work or jump into a framework to get to that "starting point". However, if you are going to start comparing Ruby/Python with a framework to PHP, then you need to look at PHP through one of the prominent frameworks out today (Symphony, ZF, Etc). Otherwise you are comparing apples to oranges.
- jrockway 14y agoThe resounding theme is: "I've only used PHP, and I like it. Therefore it's good." Try getting good at a different programming language, then write your blog post about how PHP is awesome.
- soupboy 14y agoI don't buy your argument. You don't need to try all (or any) programming languages in the world in order to like a single language. I know Python, and I really like Python and think it is awesome. I don't need to have tried Ruby or Haskell or C# to say this. Also, your comment kind of becomes moot because he goes on to say "I do know and actively use Python and server-side JS ..."
- kstenerud 14y agoThe problem is that lack of exposure causes myopia. If all you've ever used is a hammer, every problem starts to look like a nail. Every time I've switched languages there has been a transitional period where I've bemoaned the lack of X in the new language, and later wondered how I ever got by without Y, which lets me do in 10 minutes what took 4 hours and hundreds of lines before. Each new language or technology is a new tool in my toolbox, which allows me to make an informed decision when choosing how to build a product. So if you've only ever used one programming language, then yes, I'm going to take your opinion with a mountain of salt.
- kelnos 14y agoYou don't need to try all (or any) programming languages in the world in order to like a single language. No, but you appear woefully unqualified to put forth any kind of opinion as to why the language you like is a good language if you have no frame of reference. I know Python, and I really like Python and think it is awesome. Sure, but you have no basis to make a comparison. You just happened to luck out; Python is a great language. PHP is... not.
- giulianob 14y agoLanguages I feel comfortable in: -C# -Java -PHP -ActionScript 3 -Javascript -C/C++ (not so much now but did in the past) -Objective C and I've played around with Ruby and Python a little. Knowing all these languages, I still think PHP can be damn good when used properly. If you look at some of the frameworks built with it, they are clean and powerful.
- api 14y agoThe secret to PHP's success is simple. I've never seen anyone point it out. It just works. If you have a web server configured to run PHP, then it's ridiculously simple to get a page to execute. Just put a .php file on the site and it runs. Done. You don't have to jigger a bunch of components, dink around with a bunch of Tomcat or Ruby on Rails or proxy or other annoying settings. Most other web execution environments have a bunch of Rube Goldberg machine components you have to plug together to get them to work. It also performs very well and supports a lot of things.
- emperorcezar 14y agoYes, it just works. That's also where there are thousands of poorly written sites out there that chug down sql injections like they were going out of style. PHP is a reasonable templating language. That's what it should be used for. If you use a framework, you're golden, but at that point you could be using any language.
- sbarre 14y agoIf [language of your choice] was as popular as PHP you can bet that there would be thousands of poorly written sites in that language out there too.
- TylerE 14y agoI sincerely doubt that. PHP has fundamental issues. It's like the people 10 years ago saying "if [other OS] was as popular as Windows XP, it'd be overrun with malware too". No. The issue wasn't Windows marketshare, it was the completely crap security.
- chunkybacon 14y agoThe issue was both Windows marketshare and crap security. If it wasn't easy to write malware for Windows not as many would write it. If there was no one to infect with the malware, also no one would write it.
- 14y ago
- rpeden 14y agoEvery time one of these arguments pops up, I'm reminded of this: http://i.imgur.com/pG3q7.jpg http://i.imgur.com/pG3q7.jpg Different people will end up enjoying different tools. I started web development with Ruby and Rails, but find that I really enjoy PHP. Then again, I don't have to maintain anyone else's crappy code. I find that when I write clean, well tested PHP, it really isn't frustrating or painful. If you prefer something else, that's great! Use it. I guess these types of debates aren't exactly unique to this industry though. When I used to lurk around automotive message boards when I was younger, I recall some pretty epic flamewars among Chevy/Dodge/Ford/etc. fans. Everyone loved their favourite, and were certain that the others were clunky pieces of crap. Sounds a lot like programming language flamewars... :)
- bitwize 14y agoI really love that they used that famous photo of Andrew "Alynna \"Pookie\" Trypnotk" Beaudoin for the C as seen by PHP fanboys cell of the table. Oddly enough, that man's programming preferences are even more hilarious: he likes to do his web development in the scripting language for his favorite furry MUCK. I'm not even kidding; he bolted it onto a Web server somehow and actually did paid contract work in this language. And since he was the only one who knew how to use it, it meant job security. Up to a point. After he got fired, he was also the only one who knew about the back door he snuck into their MUCK-based application server. Mofo was Dennis Nedry in a dirty fox fursuit. Or not, as the picture shows.
- chaostheory 14y agoI agree. Like religion, unless someone tries to force it on me I tend not to care as much.
- jwbrown77 14y agoI think the PHP documentation is the major thing not mentioned here for the non-programmer layman (like me, who uses PHP). Need to know how to use in_array? http://us.php.net/manual/en/function.in-array.php http://us.php.net/manual/en/function.in-array.php Not only is there a quick reference on the top, but clear, concise, and diverse examples on how to use it if you don't want to spend time thinking about how to work the arguments. Maybe the expert programmer doesn't really care about these qualities, because javadoc is "easy" to them, but it doesn't compare to this for me. P.S. As someone who has dabbled with Ruby, Python, etc. I do acknowledge they are vastly superior languages in many respects.
- chromatic 14y agoIf you're glad that PHP.net exists because you can always look up the order of needle and haystack, you'll love a language where the order of needle and haystack is always consistent.
- seldo 14y agoI loved the original post about PHP's fractal awfulness, but this sums up my feelings about it: I like it anyway. His point about PHP being shared-nothing by default is a good one: this is indeed a big part of the admirable scalability of web apps written in PHP (Facebook, anyone?). The one point I'd disagree with is his assertion that PHP doesn't have a templating language. Of course it doesn't: PHP is a templating language. That's what it was written to be. Many of the uglier things you have to do in PHP are related to the fact that what the language always wants to do, by default, is spit out a web page. If what you want to do with your software is output web pages, then PHP is the best call. If you want to do basically anything else, pick another language. But at web applications, PHP just can't be beat.
- wpietri 14y agoI'm glad you like it, but the "shared-nothing" line is outrageous bunk. Commonly repeated bunk, so I don't blame you, but it's still bunk. Pretty much every PHP app in the world shares a database. So you've shifted your scaling problems from an area that programmers understand and control to a 1-MLOC mystery. I bring this up because I have a few friends who make their living saving the asses of PHP programmers who buy the notion that PHP is magically easy to scale. I hear a lot of horror stories from them about the absurd sums of money spent cleaning up the messes. I do agree that PHP is fine for doing basic web apps. But I don't know anybody doing anything serious with PHP that only uses PHP, because serious web apps eventually need more than you can do in that language. PHP's "shared-nothing" scaling just means that when the going gets tough, some language other than PHP will be doing the work.
- seldo 14y agoYou're right that the back-end often gets ported to some other language when a PHP app is scaled-up; this goes with my point that when you move away from spitting out web pages, another language is a better choice. I'm not sure your point about a database is valid; Python and Ruby and Perl apps are all using a shared database (or newer k-v store) as well.
- 14y ago
- 10098 14y agoIf I have learned anything during my 3-4 years of experience as a software dev it is that a) All languages, frameworks and technologies are bad and ugly, each in many of their own horrible ways b) Nobody has any fracking idea what they're doing (mostly) c) Your best bet is to find something that does not hurt you as bad as other stuff and stick with it. If you enjoy php, that fine (of course it's completely beyond me how it is possible to enjoy it, but its not the point). On a side note, after having spent most of my time programming in high-level languages, I wonder how things are down there in bare-metal-programming land. I've grown tired of web development and I wonder what it's like programming in an environment that does not have poorly designed, inconsistent frameworks and leaky abstractions, only registers, memory and pins :) Too bad it's probably too late for me to get started there.
- cageface 14y agoI strongly disagree with A-C but I would encourage you to try some native development if you're curious. HTML5 is the PHP of UI stacks and it's tremendously refreshing to work instead in a well-designed stack like Cocoa Touch or even Android.
- 10098 14y agoActually I have done a fair amount of native development and I mean C++ stuff, not mobile apps (android/iphone development is actually high-level compared to that). I was really talking about going down even deeper than that, to the level where there is nothing between your code and the machine. I try to educate myself on the subject by reading books and occasionally coding something in my spare time, but it's obvious that my current skill-set does not even remotely comply with the requirements for that type of job.
- antirez 14y agoI think many like PHP because an inconsistent language full of design flaws is in many contexts better (in a less is more sense) than a good language that is backed by a complex web framework and library system that contains too many complexities, versioning issues, is slow by default or hard to tune, and so forth. With PHP people have something that just works, reasonably, and given that an interpreter lives the lifespan of a "page view" making big errors is non trivial. So PHP is not a good language, but many other languages should learn something from PHP. The problem is that the community backing this better dynamic languages, such as Python and Ruby, still for some (IMHO obscure) reason aren't shipping something that is PHP-alike, but just with a better base language (without trying to add tons of abstraction layers). I no longer use PHP because after years of using better languages (I like Ruby as a "practical language") it's too hard to return back to PHP, but I often find myself fighting with the useless complexities and layers of abstractions that Ruby contains "by default". Not in the language or the implementation itself, that is good enough IHMO, but in the tons of gems around and in the integration with the web "side".
- TazeTSchnitzel 14y agoPHP sucks, but it will get better over time. Maybe they'll try to do a big leap like Python 2 to Python 3, which would be great. I'm not a big fan, but I like the fact the developers seem to be trying to improve it.
- andrewflnr 14y agoIt shouldn't be that hard to configure some other language to fill the ridiculously-easy-to-use niche that PHP fills. I vote for Lua, personally, though almost anything would do. Embed in HTML, wire stdout to the web page. Add a couple functions for "first class HTTP support". Write an Apache module. You could probably make it even easier to deploy than PHP, with the benefit of a nicer language. Obviously I'm oversimplifying, but it's mainly glue code. Seems like the hardest part is getting it deployed on the $5/month hosts. Is there some obvious reason it hasn't been done? Did they already and nobody cared? If I didn't already have a massive project backlog I might take a shot at it. It seems like a good opportunity for someone to make a difference. Edit: Crud, they already took the name mod_lua: http://httpd.apache.org/docs/2.3/mod/mod_lua.html http://httpd.apache.org/docs/2.3/mod/mod_lua.html
- freshhawk 14y ago> No Debugger - PHP has xdebug which works quite > well as an interactive debugger Good god, what debuggers have you been using that makes PHP and xdebug seem like it "works quite well".
- calloc 14y agoI really dislike it when someone posts something controversial so a couple hours later someone posts the opposite based on their experience. This doesn't add anything useful, post it as a link on the original thread. It is just a bunch of noise cluttering up the frontpage of HN!
- robomartin 14y agoHad we waited for the development of ideal programming tools for the web, the Internet would still be struggling to get off the ground. By making the best of what we have and by continually evolving better solutions we've been able to create something that has, quite literally, changed the world. Let's keep that in mind. The goal and the end-result isn't a monument to superb software engineering. What we create are experiences for, mostly, non-tech users. How the sausage is made almost isn't important (as long as it doesn't kill you). It's easy to get lost in the pursuit for technical excellence and ignore the realities of building a business. The fact that Facebook is built on PHP should pretty much tell the story and put a lid on these endless arguments: You use whatever tools you have available at the time to create a good user experience. People don't pay for your choice of programming language. In fact, they couldn't care less. That's not to say that the tech world should not strive to be on a path of continual improvement and technical evolution. Not at all. I guess what I am trying to say at one level is "quit griping and get back to building a product, nothing else matters". That said: What might be a likely improved successor to PHP? By this I mean, a language that can gain wide adoption while dealing with a number of the issues of PHP (and other languages) and has a high likelihood of being deployed as far and wide as PHP is today.
- MichaelGG 14y agoAnd the fact that great books were written by hand or by typewriter should put a lid on any arguments about text editors, word processors, keyboard layouts, and so on, right?
- blindhippo 14y agoIf all the bitchy python/ruby purists out there want to build a successor to PHP, here is the roadmap: 1) make it as simple to setup a development environment as it is to install MAMP (this is somewhat done - but still hella confusing with both Ruby and Python) 2) start a web host that can offer rails/python hosting as simple AND as CHEAP as shared hosting (6$ per month or less) 3) build the Wordpress/Drupal of Rails/Django 4) make it simple for designers and "site builders" to hack the language. This includes former flash addicts. Until then, all this anti-PHP hate just seems... pointless. As you said, we create experiences for users who ultimately don't care what is beneath the hood as long as it works and doesn't blow up. There are a lot of PHP systems out there and there is a lot of money to be made as a developer who focuses on PHP. It may not be the prettiest language, but I know why I focus on it - it makes me money. I use other tech (rails, ObjC), but PHP is my bread and butter - and if you do it right, PHP really isn't that bad. The only time I've seen PHP apps blow up is when they are past due for re-development anyways - a symptom that is not unique to PHP. Anyone who's seen Rails spaghetti knows what I mean.
- conner_bw 14y agoHating on PHP because it has too many functions is like hating on Chinese because, instead of 26 letters that you can combine to write anything, functional literacy requires a knowledge of between three and four thousand characters and that's just sloppy language design! Also, why not just call them an API to procedures written in C and realize that none of us scripters are coding in anything. I code in Lua.
- joe_the_user 14y agoIt is very interesting how, often when one haphazardly produces a language for a particular purpose, one winds with a language which both "sucks" and is orders of magnitude better for that particular purpose than any other language. Arguable examples include Php, Matlab, shell-script and many others. I'm creating an ad-hoc language right that also has this quality. I cringe as I shoe-horn one or another crude extensions into it and then step back and realize that for its particular purpose, it would be harder to do that much better.
- evilvoidhamster 14y agoI have written, maintained and worked on gigantic PHP codebases, mainly in the realm of ecommerce (not that train wreck, magento). I have a lovehate relationship with the language, and my pet peeve is that it is so easy, we get the lowest ability developers who never take time to learn the theory or any other technologies. Having said that... If it wasn't for the LAMP infrastructure, the ease and speed of development, these codebases could not have been developed. I think the standard libraries could do with an update, to add the consistency they deserve, and do update them to use modern features. The community for PHP is reaching a point of maturity that it has not seen before (look at composer, PSR-0, symfony2 and ZF2). I think this maturity is making the community a good place right now. I'm not leaving it anytime soon. Take away PHP, watch the major sites of the Internet disappear. Where would we be with no Wikipedia?
- aaronsung 14y agoI love PHP too, I can't agree more for the 'just work' point, besides unicode isn't built in. (It 's really a pain for far east users like me)
- kemo 14y agoYes, PHP can suck in many ways. Yes, everything else seems to be more elegant. And yes, newbies don't care. They just want it to work, no matter how. They don't care about creating servers (node) or including something they know nothing about (sinatra). Heck, they might do it with PHP as well, if they knew how to (Kohana?). But they don't and they never will. On the other side, put good developers on a PHP project and you will get a good product, regardless of the haystack position and possibility to suppress errors (etc. etc. etc.). The fact that there is so much spaghetti PHP out there doesn't make it impossible to write good code with it. And that matters a lot.
- deleted 14y ago[deleted]
- deleted 14y ago[deleted]
- zippie 14y agoThe OP says PHP doesn't have XSS filtering but that is simply not true: http://www.php.net/filter http://www.php.net/filter
- bphogan 14y agoPHP is one of the languages I believe every web developer needs to know reasonably well. It's not my go-to language though and I don't much care for it. Let me explain. My feelings on PHP are much the same as my feelings towards JavaScript - most of the code I've encountered in the wild was cobbled together by designers who knew nothing about programming and a lot about how to cut and paste scripts together. I find myself blaming the languages for the mess people left me. But occasionally, much like JavaScript, I'll encounter some PHP code that was truly written by a master - someone who really knows how to use the language effectively, who doesn't intermix SQL, HTML, PHP, and JavaScript in the same 1000 line index.php page. Well-constructed code, designed with purpose. I suppose that's the same with any language, isn't it? PHP, like JavaScript, is everywhere, and if you solve other people's problems for a living, I think you need to know it reasonably well. At least well enough not to make it worse than the last developer.
- logansbro 14y agoUsed to know it just enough to 'deal with it' when there was something that needed to be fixed. Recently I started working for a place that has a few large PHP sites and projects and really dove in. Overall, I'd agree that when you see great PHP it can be nice and impressive. I don't think I'd want to do it 9 hours a day though.
- davidjbeveridge 14y agoAmen. I started my development career with PHP, and the cacophony of intermingled responsibilities and languages in most PHP scripts is deafening. It wasn't until I learned how to apply good OO design to PHP that I enjoyed using it. That being said, I still don't work with PHP unless I have to. I still don't like its mixed naming scheme for string/array functions or its clunky hash/array syntax. At least the object support is reasonable.
- wazoox 14y agoThis debate is always the same rehash of ye olde time story as recounted in "The rise of Worse is better"[1]. That's why we had Unix boxes instead of LISP machines, that's why we had PCs running MS-DOS and not Amigas, why we later had PCs running NT instead of SGI Octanes, and nowadays people have PCs running windows7 rather than elegant iMacs. "Cheap and easy, quick and dirty, and get the job done" is a perfect description of PHP and the very reason for its success. [1]: http://www.jwz.org/doc/worse-is-better.html http://www.jwz.org/doc/worse-is-better.html