16 ms·
The True Problem With PHP
- larrik 14y agoThe TRUE problem with PHP is that you can prototype extremely fast in it, and then you are stuck in PHP. Django and the like have a lot of setup time to really get started, even if after a few hours into it you're already saving time compared to PHP. I've found it hard to argue against PHP with my former bosses, due to this fact.
- bmelton 14y agoI can set up a new Django environment in virtualenv, using Pip in about 15 minutes (using sqlite) without using a 'skeleton' template. Having not touched PHP in years, it would almost certainly take me longer to get PHP up and running with Nginx/Apache. With Django 1.4's templates, you get more speed boost on setting up each app. With 'manage.py runserver', you don't even have to mess with Apache/Nginx to get running. Regardless, comparing "PHP" to Django isn't particularly fair, even though I would argue that it isn't as one-sided as you make out. You can get started in Flask in slightly more than the time it takes to type 'pip install flask'. If you're baselining PHP to Python, then know that Python has a much greater penetration on Unix servers, though arguably 'web hosting providers' are also very likely to have PHP installed (if it isn't dedicated). Since you brought up Django, how long does it take to get started with CodeIgniter or Symfony (a better comparison to Django)?
- smacktoward 14y agoIf you're a real newbie, terms like "virtualenv" and "Pip" are much harder to wrap your brain around than "unzip this ZIP file into your web root", which is the way you set up, say, CodeIgniter.
- bmelton 14y agoIf you're a real newbie, then perhaps PHP is the better choice -- not because of complexity, but because of the lack of proper rigidity enforced in getting started. Though I will say that I read 'getting started' as the cost of getting started on a new project, not 'your very first' project. In that regard, sure, PHP is easier. It gets that way by encouraging programming idioms that most other languages actively discourage. I understand the argument for would-be developers to get started with PHP. That's not too far off from how I got my introduction into web programming, but I have a hard time believing that developing developers choose PHP over Python or Ruby because it's easier to install.
- larrik 14y agoI actually am a full-time Django developer (pip and virtualenv included), and I hate PHP. But if, say, I want to try out a new JS library or widget, I'm pretty likely to just throw a PHP script in my webroot and use that, instead of firing up a full-blown Django project. The time from deciding to write some HTML or JavaScript or whatever to actually writing it in a PHP script? Basically nothing.
- bmelton 14y agoWhat does PHP have to do with JS? I'm not trying to be snarky, but I feel like I'm missing something. How would creating an 'index.php' be any faster than an 'index.py' with Flask or just using Python directly? Again, comparing it to Django isn't exactly fair. I wouldn't see many people standing up a full CodeIgniter setup for that either.
- deleted 14y ago[deleted]
- gee_totes 14y agoAlas, the rapid prototyping is a trap I fall into all the time. Spinning up an ol' Symfony 1.4 application to mock-up a REST API so I have something to build a Backbone.js app against is the practice that keeps leaving me tethered to PHP. If there were something that would allow me to spin up local application and work with my existing, already running Apache processes, I could move away from PHP.
- jurre 14y agoI have the same thing set up with a couple of lines in the terminal with rails though, it's just a matter of having some experience with the tools.
- cheald 14y agoSinatra is pretty great for rapid prototyping. For example: https://gist.github.com/3062572 https://gist.github.com/3062572 Then I just invoke it with "shotgun rest.rb" and hit http://localhost:9393/ http://localhost:9393/ and I'm up and running. It's not running through Apache, but it's not really significantly more difficult than PHP prototyping. curl -d "foo[bar]=1&foo[baz]=hello%20there" http://localhost:9393/foos {"result":"success"} curl http://localhost:9393/foos/1 {"bar":"1","baz":"hello there","id":"1"} Easy peasy.
- virtuz 14y agoThis is always going to be the case with PHP – it's got the lowest barriers to entry of any web language, so it's going to have the largest share of bad coders. It's not a problem; people have to start somewhere and you can't, in an authoritarian manner, stop people from writing blog posts if they're not expert. That said, I don't think it's about this. I think it's about respect. And people, right now, just don't respect PHP.
- teresko 14y agoWhy exactly "bad tutorials" always be the problem ? And how is it related to lowest entry barrier ? Did you read the article ?
- virtuz 14y agoYeah, did you? > But on the fringes, there are a lot of people who are writing articles, tutorials, and posts designed to help beginners learn the language (and usually how to program). The problem with this is that the majority of those authors frankly don't have a clue what they are talking about. It's the most ubiquitous language, which leads to being the easiest to start with. Thing is, if people learn it wrong they're going to churn out crap. That's a vicious cycle.
- soc88 14y ago> The core of the PHP community is filled with a lot of really talented and smart developers doing some really amazing things. Like those, who failed for years to actually consult the results of the test suite before shipping a new release? http://gcov.php.net/viewer.php?version=PHP_5_4 http://gcov.php.net/viewer.php?version=PHP_5_4 Like those who change stuff incompatibly to the worse, while introducing security holes? http://php.net/manual/en/function.is-a.php http://php.net/manual/en/function.is-a.php https://bugs.php.net/bug.php?id=55475 https://bugs.php.net/bug.php?id=55475 Like those were security fixes create even larger holes? http://thexploit.com/secdev/critical-php-remote-vulnerability-introduced-in-fix-for-php-hashtable-collision-dos/ http://thexploit.com/secdev/critical-php-remote-vulnerabilit... Like those who can't program a sane line of code in the language PHP is written in? "OMG, this calculation overflows, let's replace the int by an float!" You can't make that shit up. I have nothing against stupid people, but against stupid people who fight against every kind of process who could prevent their own stupidity like - "learning from mistakes", - "learning the language they actually program in", - "handling bug reports in a way it doesn't alienate reporters" or - "having a decent test coverage". Instead of thinking about yet-another-documentation site, what about fixing the devastating quality of their API documentation (especially the comments)?
- leftnode 14y agoHow so?
- LnxPrgr3 14y agoStill my favorite PHP bug story: http://use.perl.org/use.perl.org/_Aristotle/journal/33448.html http://use.perl.org/use.perl.org/_Aristotle/journal/33448.ht... Though this one isn't far off: https://bugs.php.net/bug.php?id=18556 https://bugs.php.net/bug.php?id=18556.
- cdcarter 14y agoWait wait, this Turkish bug is just under TEN YEARS OLD?
- 14y ago
- mildweed 14y agoI propose this wiki content reside on https://wiki.php.net/ https://wiki.php.net/ Sure, the page self-declares that it is "mainly used to track internal development of the PHP project", but its a wiki. We can change that.
- timaelliott 14y agoAnother day, another "Problems with PHP" article. Seems like everyone has to toss their hat into the ring. If someone were to write a "Problems with PHP and Proper Password Hashing" post it would be #1 for weeks!
- teresko 14y agoThat's not a PHP problem. It's a PEBKAC bug.
- conradfr 14y agoSeriously, it's the very real hacker news circlejerk. I would be more interested about an article titled "From Zend Framework to Django" (or whatever language/framework) than the thousandth article "Your language is bad and you should feel bad".
- jeltz 14y agoDoes not sound like you have read the article. The article was not programming language bashing but bashing of the PHP community by a member of said community.
- madsushi 14y ago"The True Problem with PHP" is all the posts about it on HN.
- Jabbles 14y agoPerhaps you can learn from the Perl community's experience as they realised they had the same problem less than a year ago? http://blogs.perl.org/users/mithaldu/2011/10/perl-tutorials-suck-and-cause-serious-damage.html http://blogs.perl.org/users/mithaldu/2011/10/perl-tutorials-... http://news.ycombinator.com/item?id=3158276 http://news.ycombinator.com/item?id=3158276
- hsmyers 14y agoThey have known and been doing things about bad Perl advice for a lot longer than a year. There have been idiots who have made reputations based on some of the worst possible code you can imagine and it has taken a lot of time to convince newcomers that they should read and ask questions else where. The good news is that the communities like PerlMonks do an excellent job of good advice (occasionally with really good flame wars :) ), the trouble being that it may take a little bit of luck for the beginner to stumble across the resource.
- mootothemax 14y agoPeople telling you to do the wrong thing is undoubtedly a large problem. For example, one of the things I don't like about the CakePHP framework is the advice you find when searching for seemingly simple questions, like how to use the database's current timestamp with Cake's ORM. You typically see one of two responses - either call one of your columns "modified" or "created" and hack it in like that. Or, use PHP's built-in date() function, ignoring the issues that brings (e.g. the current timezone could be anything - not always what the database is operating under). This is an ongoing problem, and is likely related to PHP's ease-of-use; for new users, it's easy to get a sense that you know more than you think you do, and give advice accordingly. The bigger problem is that it keeps building upon itself. People who don't know better, taking advice at face value, then giving that advice increases the number of people writing crap code. Try searching for password storing advice, and you'll see masses of varients of md5('salty_' . $password);
- jere 14y agoI think Jeff Atwood is singlehandedly responsible for that last one: http://www.codinghorror.com/blog/2007/09/rainbow-hash-cracking.html http://www.codinghorror.com/blog/2007/09/rainbow-hash-cracki... >hash = md5('deliciously-salty-' + password)
- teresko 14y agoWell .. if you are looking for high quality code, anywhere related to CakePHP is the wrong place.
- mootothemax 14y agoWell .. if you are looking for high quality code, anywhere related to CakePHP is the wrong place. Hehe, that's might be related to why I wrote one of the things and not the only thing ;-)
- oinksoft 14y agoWhat's with the CakePHP FUD the last couple days on HN?
- 14y ago
- jere 14y agoWow, I had no idea w3schools was so inaccurate. I turn to it all the time for a quick reference. I suppose I'd be classified as one of the lunatic fringe if I was actually writing tutorials. http://w3fools.com/ http://w3fools.com/
- crisnoble 14y ago>But on the fringes, there are a lot of people who are writing articles, tutorials, and posts designed to help beginners learn the language (and usually how to program). The problem with this is that the majority of those authors frankly don't have a clue what they are talking about Where would one find a good tutorial site?
- xd 14y agoI'm getting tired of these posts, but he brings up a good point. You only have to browse code on phpclasses.org (the most popular PHP code contribution site I think?) to see that there is something very very wrong with how PHP code is developed. Also the comments left in the PHP documentation don't seem to be moderated on code quality and a lot of bad practice has slipped in.
- mootothemax 14y agoYou only have to browse code on phpclasses.org (the most popular PHP code site I think?) to see that there is something very very wrong with how PHP code is developed. To be fair, there are plenty of junk code sites out there. I'm amazed that http://www.codeproject.com http://www.codeproject.com still appears to be going strong.
- melicerte 14y agoThat just means that there are bad programmers outside, not necessarily bad languages. Nevertheless, I don't know a single perfect programming language anyway, so you can write tons of article titled "what's wrong with xxx". But, apart driving a lot of readers to your blog, these posts do not help at all.
- ChiperSoft 14y ago> the most popular PHP code contribution site I think? Popular in that everyone knows its name and knows not to ever use it. It's an absolutely awful site that's been awful for an entire decade. Most of the code being uploaded there these days is from indian and brazilian developers. All the good PHP libraries are on github and shared socially.
- rlx0x 14y agosure THATS the problem with PHP, it has absolutely nothing to do with the horrible language design [1] and the dickhead [2] core developers. [1] http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de... [2] https://bugs.php.net/bug.php?id=50696 https://bugs.php.net/bug.php?id=50696 https://bugs.php.net/bug.php?id=18556 https://bugs.php.net/bug.php?id=18556
- ericingram 14y agoIt's one problem and those are two more, but I would argue these problems look minor compared to the obstacles standing in front of some other languages. It seems the HN community tends to over-value language design and under-value low barriers to adoption.
- LnxPrgr3 14y agoIf I'm picking a language for a new project, I don't care about barriers to adoption, as long as they're low enough that I and anyone else I'm trying to work with can get through them. I do care about the language having at least something vaguely resembling reasonable behavior. Why would I optimize for barriers to adoption? I don't need my language of choice to be popular to get away with using it, especially if I'm building one of those Web thingers everyone likes to make these days. What I do need is a language I can be productive in. All else being equal, the less a language surprises me with inconsistent or outright broken behavior, the more productive I can be with it. From http://www.paulgraham.com/avg.html http://www.paulgraham.com/avg.html: "Robert and I both knew Lisp well, and we couldn't see any reason not to trust our instincts and go with Lisp. We knew that everyone else was writing their software in C++ or Perl. But we also knew that that didn't mean anything. If you chose technology that way, you'd be running Windows. When you choose technology, you have to ignore what other people are doing, and consider only what will work the best." So, yes: I can't speak for everyone, but I would rather use a well designed language with poor adoption than a poorly designed language that's been widely adopted.
- its_so_on 14y agoIn other words: The problem with English is that most of the people speaking it, writing it, or teaching it - collectively what I shall call the 'fringe' - could not so much as pen a tolerable introduction to a Penguin Classics paperback. This is 2012, people. Programming isn't just a profession, it's an everyday skill that everyone should learn, regardless of how badly. PHP is a great enabler for this - and I endorse this direction completely.
- soc88 14y agoSmoking isn't just a profession, it's an everyday skill that everyone should learn, regardless of how badly. A cigarette is a great enabler for this - and I endorse this direction completely. -- Your friendly tobacco association.
- weego 14y agoI can't vote this down enough. I have worked with a lot of people and mentored quite a few at companies I've worked at. Some were designers, some weren't even in the IT departments. Any that wanted to learn something about we programming I lead in the direction of PHP which I cut me teeth on before moving onto other things (currently Scala). They could get a dev environment up and running in no time, and better than that they could actually host something they did on shared hosting for practically nothing (or actually nothing as I sometimes gave people sandboxes in my hosting). PHP is a gentle introduction to server concepts and have a fairly simple and not-too abstract syntax. Yes yes, when you really look at it there are some fairly glaring inconsistencies but the reality these people were not at the stage where they would notice or care. It's also embarrassing to me as a professional who, like most, believe that some knowledge in programming will be of great use to people (in business or otherwise) and try my best to support anyone I know wanting to learn something or better themselves that this attitude is so common and outspoken with no logical justification or attempt at rational counter argument. Programming is hard. Good programming is harder, and the levels at which some of us seem to hold everyone around us (and yet somehow I doubt they hold themselves to every minute at work) are unrealistic and can push people further away than do what we should be aiming for which is bringing people in. I'm really proud of every one of the people who stuck with learning and letting me help them and I think it's appalling to belittle their efforts indirectly with comments like this.
- chrisblackwell 14y agoIf everyone spent as much time promoting alternative languages, as they did bashing PHP, then Python would have been the most popular language 3 years ago!
- agumonkey 14y agoAnd/Or setup tons of cheap and easy hosting services. PHP bashing has jumped the shark.
- slurgfest 14y agoThere is really no money in $2/mo shared hosting, is there? I don't think it is a very interesting problem, either. In 2012, the availability of hosting and ease of deploy is no longer a reason not to use Ruby, Python, or whatever.
- LnxPrgr3 14y agoThis is definitely a problem, and not just for PHP. Check out this section from a C++ tutorial: http://www.functionx.com/cpp/examples/returnpointer.htm http://www.functionx.com/cpp/examples/returnpointer.htm. The author is very clearly confused by even the basic rules of C++, yet he's out there trying to teach others. It's the blind leading the blind. (Incidentally, I found it again by Googling for "worst C++ tutorial"—for me, it was the first match.) So yes, someone, please do throw some good advice out there to help drown out the bad!
- randomdrake 14y agoI find it surprising that no one has mentioned, what I consider to be, the best source of information and help with the PHP language out there. The ##php IRC channel on freenode (1) is an absolutely incredible resource. I've idled in there for many years now and the amount of good, relevant, and accurate information that can be obtained in there is incredible. Whether you have been programming for 5 days or 5 years, simply hanging out in the channel for a couple of days can offer insights and tricks that you may have never known about. Over time, the folks there have compiled an absolutely excellent Wiki (2) for developers; old and new. In addition, there is a wonderful list of general do's and don'ts for PHP application development. (3) Time and time again, we get folks in there who are using outdated technologies (hello mysql_* functions) or just awful tutorials or resources and they get turned around in no time. Disclaimer: as the author states, there are many self-described experts in PHP and they do, occasionally offer bad advice. However, it is rare for the bad advice to go unchecked in this IRC channel so I can still recommend it without worry. [1] - http://freenode.net/ http://freenode.net/ [2] - http://wiki.hashphp.org/Main_Page http://wiki.hashphp.org/Main_Page [3] - http://hashphp.org/ http://hashphp.org/
- soc88 14y ago> there are many self-described experts in PHP I think this is the real problem of PHP. It attracts people too stupid to realize that their own level of knowledge should make them avoid teaching others. As soon as someone points out an issue they almost immediately switch to "LALALALALA I CAN'T HEAR YOU!!!".
- vstm 14y agoI guess people are the real problem of PHP. But then again: people are the real problem of everything.
- randomdrake 14y ago>It attracts people too stupid to realize that their own level of knowledge should make them avoid teaching others. There are many very, very smart people that try to teach others as a form of their own expression and learning. People coming from other programming languages that are extremely talented in that language, often take on this role as they are confident in their abilities. That doesn't make them stupid, nor should it disqualify them from attempting to teach or help others. > As soon as someone points out an issue they almost immediately switch to "LALALALALA I CAN'T HEAR YOU!!!". I don't think that's a fair assessment at all. In my experience dealing with precisely that situation, I find that most are actually very willing to accept and admit to their fault. Even in the chat room, over the many years I've been there, there are far more people willing to accept their incorrectness over people who take offense.
- Kilimanjaro 14y agoWhile stupid people keep using blinking tags and lolcats, and while astronauts keep thinking about concurrency and monads, php will grow stronger than ever. Astronauts need to come down to earth and help stupid people build better blinking tags for their lolcats, not push them to write lolcats in monads with concurrency. So, whether astronauts like it or not, a simpler un-evented node.js would sell like hotcakes (because it is js, not because it is evented), while a cleaner, facelifted php will sell even more. Fork php, use + for string concatenating, . for class members, fix haystacks and needles, add [1,2,3] and {a:1,b:2} as simple data structs, that's all lolcats need. Learn to serve your customers, even if they are stupid.
- mootothemax 14y agoIt's not very nice to refer to people as being stupid for wanting to use PHP, or likewise for those who code in PHP themselves. My Erlang isn't bad, but it would be madness for me to suggest it to a client. What happens if I get run over by a bus tomorrow, or we need to bring extra coders on board? Erlang, for all its many, many favours, is just not appropriate for the average-client-on-the-street. I realise that you didn't use Erlang as an example, but there's a reason why there's so much work for competent PHP programmers, and it's not stupidity.
- agumonkey 14y agoYour leave of absence causes demand for Erlang programmers which triggers interest to teach it and a flod of workforce. No more $blub. Hopefully.
- andrewflnr 14y agoOne headless Erlang project is going to cause a flood of interest in Erlang? You have a lot more hope than I do.
- davedx 14y agoSome pretty good ideas right here. Not sure how node.js can be 'simpler' though, it's pretty much coding in pure JavaScript which is a simple language itself?
- uzyn 14y agoSome of the experienced PHP developers have recently started a PHP mentoring program with the aim of helping beginners and intermediate PHP developers. Info: http://phpmentoring.org/ http://phpmentoring.org/ If you're interested in mentoring or being mentored, add yourself to the list. https://github.com/phpmentoring/phpmentoring.github.com/wiki/Mentors-and-Apprentices https://github.com/phpmentoring/phpmentoring.github.com/wiki... The program has only been initialized 4 days ago and it has gotten quite a bit of interest. Freenode: #phpmentoring
- wyclif 14y agoThank you, this is the most useful comment in this thread. Signing up.
- Sumaso 14y agoThe True Problem With PHP is that there are too many people complaining about PHP. Its been said before, and I'll say it again: if you dont like PHP switch to something better, if there isn't anything better make something better.
- clown 14y agoArgue all you want, but all this PHP bashing isn't solving anything, it's just dividing the coding community. I'm going to get back to work and continue coding in my chosen tool, PHP, see you all at the finish line because whatever your tool, we'll all get there in the end.
- zenogais 14y agoThese kinds of comments baffle me. Discussion and critical analysis of your tools is a great thing in my opinion. Work isn't everything.
- clown 14y agoWas just commenting on how I'm currently using it, feel free to replace work with anything you like. I guess like you, I'm baffled too, as comments like "Work isn't everything" baffle me as it's based entirely on assumption and failure to see beyond your scope of understanding. Whilst I agree critical analysis is great, general discussion can be somewhat impressionable on newcomers. Whether you realize it or not, PHP bashing / over praising will been seen by newcomers and they won't know where the foundation lies. Why must we push ideas and concepts onto people, why can't we give our points and let people make up their own mind. Personally I don't want to drift through life with people telling me what to use or what not to use, I'd prefer to see the points and make up my own mind without being preached to.
- PaulHoule 14y agoUh, I haven't seen PHP-ers go to conventions with pornographic slide decks, unlike some users of some more fashionable language. There are some real problems in the PHP community, like the terrible mismatch between the PHP core and PEAR developers, and the fact that nobody's got the guts to declare PEAR a failure, put it down, and start something new. However, other than that, the people I know involved with PHP are reasonable people. For me the trouble w/ PHP is that it works too well. I've got a small project w/ 40 hours budgeted for it, 20 of those are software dev, and 20 are corporate identity and marketing. I have libraries that smooth over the worst flaws of PHP and answers to error handling, sysadmin, and all that. I know the odds are very good I can slap this thing onto one of my production servers, push the 'go' button, and have it work for 2 or 3 years before I need to look at it again. Ruby may be nicer, and Java is better for computationally complex and intensive stuff (not this) but adding a new language to the mix probably means more hosting costs (maybe abother $60-120 a month) and probably turns that 20 hours to 60. It will take me a long time to have faith in the stability of another hosting system too. The reality is I nail out quite a few of these mini projects, some of which succeed, and many of which just smoulder. With PHP I can get them done quick and done well and have low hosting costs and little maintenance burden. To get me to switch you need to quit complaining about the faults of PHP and build my faith that your hosting system is a 'wooden round' that won't cause my 20-hour project to cost me 50+ hours a year in maintenance costs.
- debacle 14y ago> nobody's got the guts to declare PEAR a failure, put it down, and start something new. https://github.com/composer/composer https://github.com/composer/composer
- Kilimanjaro 14y agoWho wants to be the Jeremy Ashkenas of PHP? There, a perfect opportunity for language designers to shine. Nothing fancy, just fork and fix. No need to come up with new paradigms. Nothing to make you sweat. Just fork the damn thing and fix the warts with a scalpel. It is and will be the most used language for web development. If that is not a shiny medal in your chest and a place in history books, I don't know what is. Any takers?
- function_seven 14y agoSeriously, if the first forked revision simply normalized the parameter order of core functions, and standardized on verb_noun() (or noun_verb(), I don't care) function naming, I'd be happy. Yes, it's a cosmetic failing only, but it would go a long way to making the whole language seem coherent.
- Kilimanjaro 14y agoSome things I'd like to fix: Drop the dollar Use + for str concat Use . for class members Use . for dicts Use . for namespaces Use : for key:value pairs Fix needles and haystacks Use camelCase for functions Use arrays and dicts literals Use list genereators Use request and response objects Objectify strings, lists and dicts While most of it is syntactic sugar, this will solve 90% of the problems for 90% of the people. Feel free to add yours.
- Mikushi 14y agoHere is my list: - Stop trying to turn PHP into another language. Millions of developers are perfectly fine with its syntax, deal with it.
- kbanman 14y agoSo, basically make it javascript. I'm a long-time PHP developer, but I'd very much like that. Someday I'll have to learn node.js...
- kree10 14y ago
- gm 14y agoBah. I was expecting more insight than "It's the people at the fringes". The problem with _anything_ big enough to have a fringe is always the people at the fringes.
- hastur 14y agoThe true problem with PHP is that people waste enormous amount of time writing about what's wrong with PHP. And others - on reading this stuff and voting it up on news sites so that it occupies precious front page real estate. Don't like it? Don't use it. Move along.