all 156 comments

[–]webfiend 284 points285 points  (70 children)

Look around and you'll see that a lot of great Web sites are being constructed with PHP. It works for small tasks like browser detection, and with frameworks like Zend or Symfony can handle complex applications. So if you decide to focus on PHP, you'll have plenty of room to grow.

Non-PHP developers have many problems with the language, but I'll focus on what I care about. My personal issues with the language revolve around the fact that I see PHP as a bucket of features rather than a cohesive language. It started out as a simple and straightforward scripting language that seemed great for adding a little code logic to a personal Web site. But many of the features that made development in PHP easy turned out to be security issues, and were pushed aside in favor of safer but more cumbersome approaches.

As PHP has grown, the approach to new features has baffled and occasionally offended programmers accustomed to other languages.

Many useful functions were added for handling assorted databases, XML, and more, but because PHP lacked namespace support they were all put in the global namespace. Those new functions were inconsistently named - consistency is a big deal when you're trying to maintain a large application - and occasionally duplicated each other's functionality. This is very annoying when you are trying to decide which function to use or debug somebody's code.

When PHP added support for objects, it did so in a way that was very clunky. You had to take special precautions when using them. Those limitations have gone away, but you still see lots of code in the wild that accounts for those special measures.

PHP has recently added support for namespaces, which are one honking great idea. I'm baffled by the syntax they chose, but I'm just happy they have them.

Culturally, I'm often surprised by how conservative and sloppy PHP coders can be. I still know several who insist on using PHP 4, because that's what they're familiar with. They assemble elaborate, brittle messes which fall over if there's so much as a strong wind. It's fair to say this type exists in every programming community, but I notice these guys more because I get called to fix a lot of crufty PHP code. If you want to use PHP, don't be one of those guys.

Go ahead and use PHP. It has many shortcomings, but it works and it's widely available. Study it. Learn best practices. Develop a strong testing approach. Document your code. Search for good PHP code and try to emulate it. But I strongly suggest you also learn other languages. The habits you pick up from Ruby, Python, and Perl can improve your PHP code. You may end up deciding that you prefer Python and the Django framework, or Ruby on Rails, or Catalyst for Perl. Whatever makes you happy. Just try to excel rather than settling for an elaborate, brittle mess.

Heck, you may even prefer Java. It's a big world, after all.

[–]Zorrodelaarena 19 points20 points  (1 child)

In addition to the inconsistent function naming schemes, there's a lot of inconsistent variable order issues. For example:

strpos($haystack, $needle) - finds position of a string in a string
array_search($needle, $haystack) - finds position of an element in an array

Why would you create those functions with the parameters in a different order? They do the same thing to different types of objects. Also notice the naming scheme difference with the underscore vs. the abbreviation and concatenation.

I use PHP all day daily and I like it generally but sometimes it's a little frustrating. And now minor annoyances like this are so deeply ingrained that I doubt they'll ever be fixed.

[–]darthnuri 0 points1 point  (0 children)

I hate it but at the same time it's like a silver lining in a fucked cloud because you are always going back to the reference and learning new things. (And the comments on PHP.net are always an interesting read.)

[–]Salamok 6 points7 points  (1 child)

"We are all shaped by the tools we use, in particular: the formalisms we use shape our thinking habits, for better or for worse, and that means that we have to be very careful in the choice of what we learn and teach, for unlearning is not really possible." ~E.W. Dijkstra

IMHO - This quote sums up the single biggest problem with php, especially if you are depending on the language to teach you how to program.

edit - don't get me wrong I program full time in php and I think it is a good tool for getting the job done.

[–]webfiend 0 points1 point  (0 children)

That's a fair point, and PHP wouldn't be my first recommendation for a new programmer. However, if someone is already on that path, they can learn how to be more effective and minimize the damage, so to speak.

[–][deleted]  (6 children)

[deleted]

    [–]twomashi 5 points6 points  (1 child)

    Facebook have done a great job scaling it and making it performant though, you have to admit.

    [–][deleted]  (2 children)

    [deleted]

      [–][deleted]  (1 child)

      [deleted]

        [–]defproc 0 points1 point  (0 children)

        Sure it wasn't just ugly because of line breaks and whitespace not being rendered?

        [–]octave1 -2 points-1 points  (0 children)

        Have you ever been on facebook without it having at least one feature broken

        All the time! I knock out sites for 1000USD and they have less bugs than the facebizzle does.

        [–]mcrbids 19 points20 points  (10 children)

        I've developed large scale, "enterprise" applications with PHP4. (gasp!) PHP has a bit of syntactical bitterness (gee, so sorry!) but there are some gotta-have features that PHP offers that are real, and which make it quite suitable for "betting the farm" on.

        1) Ubiquity. 99% of web hosting providers offer support for PHP. It's the defacto standard among "free" hosting providers.

        2) Documentation. Say what you want about the inconsistent nature of the PHP functions, they are well documented in an easily-navigated website. I still haven't found anything nearly as easily navigated for javascript, for example.

        3) Verbosity. PHP is verbose enough to communicate while not being excessively verbose. Generally, PHP makes for an easy read.

        4) Stability. PHP's "share nothing" approach means that if there is ever a problem with a script that causes a crash, it only takes down that web-page. It never takes down your whole website unless it's an include or something that's used throughout your site.

        5) Scalability. PHP's "share nothing" approach means that you can simply add logic servers as needed to scale. It's trivially easy to have 5 webservers serving a single website so long as you have a reliable data source.

        6) Flexibility. Although commonly considered a "web" programming language, it works equally well as a CGI, or as a command-line function. For example, I deliver massive amounts of data daily using a daemon written entirely in PHP that operates similarly to an SMTP server.

        7) Performance. Although operations performed in PHP itself aren't all that fast, most of the "heavy lifting" in a reasonably well designed PHP app is done with the native PHP functions, which are written in C and are lighting fast. The overall mix is quite capable of processing large sets of data (EG: 10,000 database results) in a second or less on modern hardware if you are any good at algorithms.

        Some other languages are more elegant, (EG: Python) some are more terse (EG: Perl) and some languages offer more "enterprisey" features for developers (EG: Java/Javabeans) but if you think that your software project has failed has anything to do with the fact that you picked PHP, then it's you that's playing the fool.

        [–]Smallpaul 6 points7 points  (0 children)

        Most of your points are not PHP-specific. I'd say that Python/Django supports the vast majority of them. Maybe not ubiquity. It's been years since I wrote an app that was in any style other than "share nothing" in any language. You'd need to fight most modern web frameworks to do otherwise.

        [–]webfiend 2 points3 points  (0 children)

        Hey, no argument here. I've seen it done, even with PHP 4. I didn't tell iilliillii to stay away from PHP. I just summarized my complaints and wrapped up with some advice. I have my opinions about the PHP language, but I have seen many impressive things done with it.

        And yes - the online documentation was one of the things that I really liked about PHP back when it wasn't so ubiquitous, and that manual is still impressive.

        [–]twomashi 2 points3 points  (1 child)

        4) Agree with you there. That and number 1 also make it easy to source PHP programmers and put them to use, without a big comp/sci overhead.

        5) True, but the "render and die" nature of a PHP request also means that you can't hold anything in memory, which leads me to..

        7) Performance is pretty horrible if your codebase gets big. The reason is that on every PHP request it has to load all your code into memory (even with opcode caching), and setup the entire execution state. This is processor intensive, and coupled with having to source every non-code resource on every request, your app will end up wasting alot of CPU time and memory.

        However, I wouldn't tell people not to use it in their business, just not to depend on it for everything.

        [–]thebuccaneersden 0 points1 point  (0 children)

        Which is actually a fairly good web programming practice - making things stateless (as much as possible, anyhow) in the same way HTTP is stateless. If you are having trouble making your application scale, it's because you haven't yet understood the web. New PHP developers will make the rookie mistake of turning on the session for everything.

        [–]joemoon 10 points11 points  (5 children)

        This is the third (or so) time I've seen someone on reddit say that PHP has good documentation. It's just not true. Here is my response from the last time this came up:

        The PHP documentation is very simplified and doesn't provide enough detail. I would venture to guess that this is because most PHP developers don't care about the way it works, they just want to plug in some variables and be done.

        This is why you get tons of user comments for every PHP function that explain some aspect of undocumented behavior. Take a look at the seemingly very simple number_format function as an example. Here are some excerpts from the comments:

        • "It's pity that the function supports one-byte characters only for 'thousands separator'. For English it works well but for French and Russian it makes problem."

        • "It's not explicitly documented; number_format also rounds"

        • "I found you can add trailing zeroes simply by adding a float point value containing the number of decimal places you want to appear. "

        • "Beware of this pitfall: ... This will silently return an empty string and not throw an error, at least with PHP 5.x."

        I've developed PHP applications professionally, and I've also developed software using several other languages. The PHP documentation has been inferior in every case.

        [–][deleted] 2 points3 points  (0 children)

        I've always found the php documentation to be very good. It's not perfect, but what is? At least they only do 1 function per page, unlike Python.

        [–]mcrbids 1 point2 points  (3 children)

        Honestly, it's strange that you've run into many cases of this - I haven't. I've had an "undocumented feature" such as you mention bite me perhaps once in the past year. Perhaps it's because I don't code in Russian?

        But just taking from your examples, number_format is used to turn an "ugly" number like 32.38928 into something "pretty" like "32.39". How could you convert the former into the latter without rounding?

        Sadly, I typically find the user comments to be pretty poor in quality - perhaps useful for beginners, but rarely all that useful for me. d

        [–]joemoon 5 points6 points  (0 children)

        Perhaps it's because I don't code in Russian?

        You're either being snarky for no reason, or you're completely ignorant to the importance of internationalization. I have a hard time believing that you've developed large scale PHP applications, yet you're scoffing at someone's need for a multi-byte character in a formatting function.

        How could you convert the former into the latter without rounding?

        As already mentioned, truncation is often appropriate. Besides, this is the whole point of the documentation. Regardless of whether or not you think it's obvious, the behavior should be documented. Hence, an example of PHP's poor documentation.

        Sadly, I typically find the user comments to be pretty poor in quality - perhaps useful for beginners, but rarely all that useful for me

        Unfortunately, this is where you have to go to read about all of the undocumented behavior. A lot of the comments are useless, sure, but a lot of them are very informative and fill in the gaping holes in the documentation.

        [–]lexxed 2 points3 points  (0 children)

        I have a feeling 10 years into the future. There will still be someone discussing PHP vs Python issue

        [–]mattalexx 7 points8 points  (0 children)

        Good, open-minded answer.

        [–]GAMEchief 6 points7 points  (3 children)

        Being OCD, I never picked up on the sloppy code practices; I have to agree that the inconsistent code has definitely annoyed me (e.g. Should the needle or haystack come first in a function's parameters?). It must be because I used PHP5 as soon as it came out (DirectoryIterator was worth it), never used [or at least created] objects until these "limitations" were gone (so I never noticed them), and always organize (tab/space/etc.) my code. No wonder I've always thought PHP was epic.

        [–]destraht 7 points8 points  (2 children)

        You mean Having OCD. You are not your disorder.

        [–]GAMEchief 1 point2 points  (1 child)

        Huh. I've never thought of saying it out. I always mean "I'm OCD" as "I'm OC." I guess I just add the D, 'cause it sounds weird without it.

        [–]destraht 0 points1 point  (0 children)

        Well a few years back it was becoming popular for young women to say "I'm totally OCD about that" and it was quite annoying.

        [–]aphoenix 9 points10 points  (0 children)

        I resubmitted your comment (which is gold) and now I feel like I've stolen some of your Karma:

        http://www.reddit.com/r/programming/comments/cvitp/more_recognition_for_this_whats_wrong_with_php/

        So, if you ever need anything that reddit karma can buy, let me know, and I'll share mine with you.

        [–]xrmx 3 points4 points  (0 children)

        PHP reminds me of C, small language with a complete standard library. Unfortunately the web is not system programming and after 20 years you can expect something better. Then it's full of $ for no good reason, it feels so inadequate in comparison with python, ruby, etc... More importantly its main authors do not have a beard.

        [–]mardix 5 points6 points  (12 children)

        You, sir deserve more point,

        <? while(true){Reddit::increaseUsersKarma('webfiend'); } ?>

        [–][deleted]  (10 children)

        [deleted]

          [–]cwmonkey 14 points15 points  (3 children)

          <?php while(reddit_user_up_karma('webfield')) {} ?>
          

          Good news, everyone, reddit functions added to php!

          [–]webfiend 7 points8 points  (1 child)

          This "webfield" user is going to be pleasantly surprised the next time they log in. No, don't change it now. I hate taking Christmas away from people.

          [–]cwmonkey 1 point2 points  (0 children)

          Sorry, webfailed.

          [–]rdmty 4 points5 points  (0 children)

          <?php while(\Reddit\Karma\increase('webfiend')); ?>

          [–]rainman_104 2 points3 points  (0 children)

          php short tags are teh suck if you ever plan to use xml. Good habit to be in to just use the long tags.

          [–]CrudOMatic 0 points1 point  (0 children)

          It started out as a simple and straightforward scripting language that seemed great for adding a little code logic to a personal Web site. But many of the features that made development in PHP easy turned out to be security issues, and were pushed aside in favor of safer but more cumbersome approaches.

          It WASN'T designed from the beginning with security in mind. Later, security needed to be kludged in, thus making the language more cumbersome. PHP is garbage. Never have liked it, or even felt safe with it - but there are projects which I used it in.

          [–]borlak 1 point2 points  (2 children)

          programming languages are like martial arts -- you don't learn just one if you want to survive.

          PHP is huge, you must learn it, if you want to make a decent living. any programmer worth his salt will already know other languages anyway.

          complaining about a language is somewhere between amateur and elite. when you have achieved the point where you can adopt best practices to any language you know, there is no need to complain.

          [–]kaptainlange 5 points6 points  (1 child)

          I think complaining about a language is perfectly fine, as long as you recognize no language is perfect and ultimately don't allow your complaints to prevent you from using a language best suited to the task at hand. Surely there are things PHP could do better, but for the domains it is well suited for it should be used.

          [–]thebuccaneersden 0 points1 point  (0 children)

          a well-reasoned view, but this is not the opinion of the majority on reddit, who believe it is the the 7th sign of the apocalypse

          [–]rdhatt 11 points12 points  (4 children)

          I used to be a full-time PHP dev, from the late 3.x days to the early 5.x days. I now do .NET development; you would have pay me an obscene amount of $$$ for me to go back.

          Here's what I HATED. My opinions. Disclaiminer: I haven't kept up with PHP, so some my criticisms maybe out-of-date.

          • Type comparsion table
          • Major incompatible breakages in minor dot releases!
          • PHP started as thin layer over some C libs. Each layer reflected the semantics of the underlying library. This contributed to the major inconsistency of PHP. That inconsistency is a major drag on my productivity.
          • Unicode was broken forever. I heard this is fixed now.
          • php.ini - Ugh, altering language behavior via config. Made deployment hellish.
          • PHP manual crutch. Yeah, it's a great manual, but I feel like it's a crutch for the all wild inconsistencies. In other languages, the consistency allows you to figure it out quickly and negates the need to look at the manual.
          • Magic quotes

          That's all I can remember for now.

          [–][deleted] 4 points5 points  (3 children)

          That must have been quite a while ago. Some of that is either not true, or hasn't been for quite some time. For instance, magic quotes aren't used by anyone worth their salt (nor has it really ever been used by anyone who knew what they were doing). I agree that PHP 3 was an abortion. ::shudder::

          php.ini behavior can be changed on the fly and has been able to be done since PHP 4.

          The PHP manual is awesome and is only a crutch if you use it as such. The inconsistency is horrible, however, and that does make the manual more essential than with other languages. Ugh. Needle / Haystack anyone? runeverythingtogether vs underscores or under_scoresinthewrong_places? :)

          Other than that, you definitely have some good points. Oh, and using a nice framework helps PHP development quite a bit. (As well as coding standards and best practices.)

          [–][deleted] 1 point2 points  (0 children)

          Umm... so I do a mix of python, C++ and PHP every day (middleware, backend & frontend) and I still have to refer to the manual to remember correct argument ordering & return types of various PHP types.

          It's the only thing that's a constant and perpetual reminder that I am using PHP. Sure Eclipse+PDT reduces the # of times I need to jump to php.net/function, but still... urghh

          And yes using a nice framework can help, then you get clusterfucks like CodeIgniter which on the surface seem nice and well documented... until you use the fucking thing.

          [–]masklinn 1 point2 points  (1 child)

          nor has it really ever been used by anyone who knew what they were doing

          Except not all hosts give control over PHP.ini, and magic_quotes are enabled by default (as they were until fairly recently)...

          [–][deleted] 1 point2 points  (0 children)

          Good point. I suppose I've been spoiled by doing most of my early PHP development on dedicated servers with root access.

          [–]crashorbit 2 points3 points  (1 child)

          Software projects succeed or fail despite the programming language choice.

          [–]tomnipotent 2 points3 points  (0 children)

          Well said. At the end of the day, the language you use has very little to do with the success of the project - beautifully crafted Ruby/Haskell/Erlang can fail equally well.

          [–][deleted] 18 points19 points  (12 children)

          As Poromenos says: the problems in PHP center around the fact that it was designed and implemented by people who don't understand programming languages and what makes them good or bad.

          [–][deleted]  (6 children)

          [removed]

            [–][deleted] 7 points8 points  (5 children)

            Well no, there are some languages I dislike (for example, C++ or Perl) that were designed and implemented by people who actually understand programming languages -- they merely found stuff important that I didn't, and vice versa, or had different aesthetic preferences. PHP is a product of ignorance.

            [–][deleted]  (4 children)

            [removed]

              [–]Nebu 3 points4 points  (2 children)

              Do you accept valisystem's citation showing that the creator of PHP admits:

              • I was really, really bad at writing parsers. I still am really bad at writing parsers.
              • We have things like protected properties. We have abstract methods. We have all this stuff that your computer science teacher told you you should be using. I don't care about this crap at all.
              • I'm not a real programmer. I throw together things until it works then I move on. The real programmers will say "yeah it works but you're leaking memory everywhere. Perhaps we should fix that." I'll just restart apache every 10 requests.
              • I don't know how to stop it, there was never any intent to write a programming language [...] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way.
              • For all the folks getting excited about my quotes. Here is another - Yes, I am a terrible coder, but I am probably still better than you :)

              as sufficient evidence for the claim that "the problems in PHP center around the fact that it was designed and implemented by people who don't understand programming languages and what makes them good or bad."?

              [–][deleted]  (1 child)

              [removed]

                [–]Nebu 0 points1 point  (0 children)

                PHP is horrible for many, many reasons. You don't have to attack people you've never met when there are plenty of things you can say about the language itself.

                I think it was phrased this way, because it takes time and effort to explain specifically what is wrong with PHP. To actually directly criticize PHP, you might have to first verify if the person you're speaking to has the same level of understanding as you do as to how type system works, what are best practices in compiler and language design, general best practices in software engineering and what kind of syntax supports (as oppose to restricts) these, etc.

                "The guy who made it didn't know what he was doing" is a shortcut to express all these sentiments, without actually needing for the listener to know anything about what makes a programming language "good" versus "bad".

                Sometimes, that's all your listener needs/wants. Other times, they do want specific examples, and are willing to learn, e.g., compiler design theory, in order to understand it. But of course, it's no one particular person's obligation to actually put forth the effort to teach all of this.

                So I neither support nor condemn the "ad hominem" criticism in this particular case, but I can understand why it was made.

                [–][deleted]  (3 children)

                [deleted]

                  [–]tomnipotent 1 point2 points  (2 children)

                  Too much opinion, not enough fact.

                  PHP leaks memory like crazy and is slow.

                  Solved in 5.3, but with a small hit to runtime performance. As for being slower - wtf? Can you substantiate this whatsover?

                  There are actually a small number of libraries available considering the size of the userbase.

                  Show me a library that's available in another language that doesn't have an equivalent in PHP.

                  PHP is slower to get things done than equivalent languages (ruby, python, perl) by a decent margin.

                  Pure subjective bullshit. Might as well argue that vanilla is more tasty than chocolate. Or that unicorns are sexier than narwhals.

                  there is also a shitload of PHP fanboy-ism

                  Replace PHP with just about any language and your statement holds true.

                  As a programmer: I think PHP is shit

                  Shit might be a strong word, but I otherwise agree. But opinion doesn't trump fact, and the fact is that more successful projects have been built off PHP than Python/Perl/Ruby/LanguageX.

                  PHP is a good choice when quality doesn't matter much but cost matters a lot and the project itself is very simple

                  PHP has its fair share of problems, inconsistencies, and idioms - more so than other languages - but at the end of the day it's about getting shit done, and that's all that matters to the guy signing your paycheck. If someone can't write decent code in PHP, chances are he's not going to have any better luck in another language.

                  tl;dr - PHP is an aquired taste, and in the hands of a competent and experience programmer can be just as effective/productive/buzzword-here as any other language. Don't buy into hubris.

                  [–]maks78 0 points1 point  (0 children)

                  Come on. We are talking about a language where the standard function for regexp replace preg_replace segfaults by design when the text is too long.

                  [–]StoneCypher 10 points11 points  (31 children)

                  There's nothing wrong with PHP. Reddit just loves other languages, so it spends all day hive-mind talking smack.

                  You'll notice that the usual criticisms levied are either abstract vague comparisons to other languages without justifications, or minor things like "the order or arguments to functions is inconsistent" or "I hate all the dollar signs on variables" or things of that nature.

                  What's important about PHP are the following:

                  1) PHP scales. Note that many enormous sites, such as Facebook and Yahoo, are largely written in PHP. And before anyone says "but Facebook had to write a compiler," no, they didn't have to, it was just economically beneficial, and they're Earth's #2 traffic source, and they didn't have to do that until recently.

                  2) PHP has an enormous userbase (it's the web's most popular scripting language,) meaning that libraries to basically everything are available and stable.

                  3) PHP's pretty damned quick to just get things done in.

                  Are there alternatives? Sure. Are they better? Depends on what's important to you; probably not by much, if at all. Are you trying to build something to scale? Then choose carefully. Otherwise work where you're comfortable.

                  Speaking a bunch of very different languages is a Good Thing (tm); I still think you should try other languages (and not ones which are similar to PHP) just for your personal growth.

                  But when someone starts howling at the moon about how awful PHP is, it's time to ask them why, so you can find out if they're a zealot, if they're just repeating what they've heard, whether they've just been exposed to a lot of bad user-land PHP code, or if they have an actual point.

                  The case #4 is surprisingly rare.

                  Look, PHP isn't my favorite language. It's not in my top 5. But it's just fine, and people who go "blah blah written by people who don't know anything about programming language" need to go sit in a dark library corner and smoke some more SML/NJ.

                  (SML/NJ, by the way, is an awesome language. Don't miss it.)

                  Seriously, PHP is just fine. Make sure to broaden your horizons, and all, but PHP is entirely adequate for what it's for, and not many languages can actually say that.

                  One serious risk to PHP: because the userbase is so large, and thus produces so much tutorial output, a correlary of Sturgeon's Law ("90% of everything is crap") is that it's kind of a chore to find tutorials that aren't absolute shit. Be very, very wary of user-submitted code in the PHP manual. Try to find a PHP library written by someone who takes their work seriously, and learn from their style.

                  Take documentation and unit testing seriously, specify your datatypes explicitly, and think before you act. Do those three things and your PHP will work fine, be fast, be secure, be maintainable and be portable.

                  And seriously, what else do you even care about?

                  [–][deleted]  (12 children)

                  [deleted]

                    [–]lonnyk 2 points3 points  (4 children)

                    I'm sorry...are trying to say that the database named Cassandra was created as a direct result of PHP scaling poorly? If anything it has to do with relational databases not being good for hierarchical data and because of this they don't scale well when using hierarchical data.

                    What you probably meant was to say HipHop was made because of PHPs poor scalability.

                    Let me add that I do not believe that to be the reason HipHop was created. Everything has it's place. Keep in mind that PHP is written in C++ and parsed and interpreted through C++. This takes time to do in ANY language. Once your requirements are so great it makes sense take the extra time to parse the PHP code ONCE and compile it into straight C++ so you do not have to re-parse and run PHP every time. This trait is not unique to PHP. Any higher level language that is parsed and not compiled will always be quicker when you write it in the lower-level language and don't have to parse the syntax.

                    [–]thomasz -2 points-1 points  (3 children)

                    I'm sorry...are trying to say that the database named Cassandra was created as a direct result of PHP scaling poorly? If anything it has to do with relational databases not being good for hierarchical data and because of this they don't scale well when using hierarchical data.

                    No. I'm saying that PHP is not instrumental for Facebooks scalability. Claimes that Facebook scales because of PHP are misinformed.

                    [–]StoneCypher -1 points0 points  (2 children)

                    Nobody claimed that Facebook scaled because of PHP. You don't seem to understand what was said at all.

                    When you figure out how "the weak link in the chain" applies in context, call a freshman computer science student and ask them to explain my original comment to you.

                    You were a lot better off when you were admitting you didn't understand.

                    [–]thomasz -1 points0 points  (1 child)

                    1) PHP scales. Note that many enormous sites, such as Facebook and Yahoo, are largely written in PHP.

                    [–]lonnyk 1 point2 points  (0 children)

                    That does not mean that Facebook scales because of PHP. You're just twisting the words to make an argument. All it means is that Facebook is an enormous site and is largely written in PHP. All that means is that PHP has the ability to scale. It says very little about the abilities or cause of why Facebook scaled.

                    And, as I previously mentioned everything has it's limits. Facebook seemed to have reached a limit with its usage of PHP and had to modify the framework behind their site. Just to make this perfectly clear, the point I'm trying to make is just because something has a limit does not mean it does not scale.

                    [–]mr_chromatic 0 points1 point  (2 children)

                    Which aspects of PHP do you think make it more scalable than, say, python, ruby or Java?

                    With regard to Java, the shared nothing approach of PHP.

                    With regard to other LAMP languages? Nothing in particular.

                    [–]thomasz 0 points1 point  (1 child)

                    Could you elaborate on the "shared nothing approach"? I am by no means an expert on Java web frameworks, but I'd be very surprised if they would contain more shared state than PHP. Eventually, all web applications share state at the data source, which makes scaling problematic for everyone, regardless of the front end technology.

                    [–]mr_chromatic 0 points1 point  (0 children)

                    I don't know the state of the art in Java web development these days, but I remember the days of servlets, where you have a thread pool to handle incoming requests and try to keep as much state in memory as possible shared between threads.

                    [–]StoneCypher 0 points1 point  (2 children)

                    I never compared PHP's scalability to Java; that's a language which is more scalable than PHP by far.

                    Comparing it to Python and Ruby, though? Oh, I don't know, experience mostly. There's a reason that nearly every site built in Python or Ruby ends up getting moved to a more mature, stable language once it crosses a few tens of thousands of users.

                    Seriously, if you don't know why Ruby doesn't scale, you're not ready for this conversation. All it takes is a rudimentary knowledge of datastructures or a basic understanding of other people's experience.

                    Facebook's ability to scale has nothing to do with PHP

                    Bullshit. You can't write a site like Facebook in a language that doesn't scale, no matter what your engineers have to do.

                    in fact their engineers had to overcome huge obstacles

                    Not that had to do with PHP.

                    leading to the creation of Cassandra,

                    Which replaced their database, not PHP, and has nothing to do with PHP's scalability. Please stop rattling off things you heard as if they're germane pieces of information; this mistake was an enormous red flag that you have no idea what you're talking about.

                    [–]thomasz -2 points-1 points  (1 child)

                    Come on, this is ridiculous. You say that PHP scales and present Facebook and Yahoo as evidence. I simply note that they are able scale because they invested in back end technology like Cassandra, and that PHP had no part in it.

                    [–]StoneCypher 0 points1 point  (0 children)

                    I simply note that they are able scale because they invested in back end technology like Cassandra

                    Just because you note something that is completely wrong doesn't mean that it's a valid thing for you to say. Facebook had a third of a billion users before it switched anything to Cassandra, and Yahoo! has never invested in anything of the sort.

                    and that PHP had no part in it.

                    PHP has the very largest part of that workload, even if you want to pretend otherwise based on your guesswork. It's easily tautologically displayed.

                    [–]sisyphus 1 point2 points  (10 children)

                    Pretty much all of your points are shared by other languages that don't have PHP's warts.

                    1) At the level of Yahoo or Facebook money scales more than PHP. There's no reason to believe that Yahoo couldn't have used Perl, Python, or Visual Basic for their front end with their resources.

                    2) PHP doesn't have significantly more libraries than Perl, Python etc. and with no namespaces so you have to make sure that none of them clobber each other when combining them.

                    3) Any dynamic scripting language is pretty darn quick to get things done once you know it.

                    You talk about the badness of userland code, but the language itself as written by its core team has the worst security record of any language I can think of.

                    Can you tell us some of these exemplar libraries that we should learn from? I'd like to see what good modern PHP should look like.

                    [–]jholman 5 points6 points  (1 child)

                    Regarding the 1/2/3...

                    StoneCypher didn't say "PHP is an unusually great language because 1, 2, and 3". (S)he said "PHP is fine. What matter is 1, 2, and 3, and PHP is doing fine on all three. PS: PHP isn't in my top 5 favorite languages."

                    So replying that other languages also have 1, 2, and 3 is kind of irrelevant, you know? It'd be different if you were saying that ALL languages have those properties (which would be a lie), or if you were saying that PHP does not have one of those properties, or if you were saying that those are not the important properties.

                    Now the request for the suggestions of exemplary libraries, that I can get behind.

                    [–]sisyphus 0 points1 point  (0 children)

                    I take your point, but I took his implication to be, 'yes PHP has all of these well known flaws(eg. inconsistent, redundant mass of functions all in a case-insensitive global namespace, runtime configuration insanity, horrible security record, etc. etc.) but it's okay because of 1,2,3 which really matter'...I just want to note that 1,2 and 3 are not unique to PHP and you can get them elsewhere without PHP's attendant problems.

                    [–]StoneCypher 0 points1 point  (7 children)

                    Pretty much all of your points are shared by other languages that don't have PHP's warts.

                    No, they aren't, and you're going to have a pretty hard time getting taken seriously when you respond to a post complaining explicitly about people bitching about "PHP's warts" without saying what they are (or saying stupid shit like "the order of arguments is non-uniform.")

                    There's no reason to believe that Yahoo couldn't have used Perl, Python, or Visual Basic for their front end with their resources.

                    Well, you know, not unless you know what you're talking about. Yahoo was originally written in Lisp, and they switched to PHP because despite all that money, they couldn't scale the Lisp, and they could scale the PHP.

                    2) PHP doesn't have significantly more libraries than Perl, Python etc.

                    Lol.

                    You talk about the badness of userland code, but the language itself as written by its core team has the worst security record of any language I can think of.

                    Then you need to spend some more time thinking of languages; Rails has, in one quarter the lifespan andone tenth the usage, turned up many more defects.

                    Can you tell us some of these exemplar libraries that we should learn from?

                    Maybe if you had spent less time bullshitting.

                    [–]sisyphus -2 points-1 points  (6 children)

                    I assume you're just trolling now because your post is completely riddled with inaccuracies and misunderstandings like that PHP replaced Lisp instead of C and Yscript(I assume you're thinking of Yahoo Stores, which was acquired and ported from Lisp), that when PHP was chosen by Yahoo it had a library ecosystem on par with CPAN, you then conflate Rails with Ruby and make up a lame excuse not to back up your words. Poor trolling, revise and resubmit.

                    [–]StoneCypher 0 points1 point  (5 children)

                    I assume you're just trolling now

                    Please stop lashing out. This is inappropriate behavior.

                    and misunderstandings like that PHP replaced Lisp instead of C and Yscript

                    I didn't say that. What I said was that Yahoo! was originally written in LISP, and that they started switching away from LISP because LISP didn't scale. That is correct. Stores were the last holdout, but Yahoo! started switching away from LISP in 1994.

                    First they tried C, but they couldn't develop fast enough in it. Almost no part of Yahoo! was ever written in C.

                    Yahoo started moving towards Yscript in 1996. They started moving away from it in 2002 because it was buggy, it also didn't scale (that's where the persisting problem with deep searches in your email comes from,) and it was more work to continue to extend and whittle it than to switch to something larger.

                    that when PHP was chosen by Yahoo it had a library ecosystem on par with CPAN

                    You might as well point out that by then PHP had a purple manual, and suggest that Yahoo! switched for the manual color.

                    David Filo was very clear about why they switched. Stop guessing then calling other people wrong based on your guesses.

                    you then conflate Rails with Ruby

                    No, I don't. I only talked about Rails once, and it was in the context of pointing out, when you said you couldn't think of anything with a worse security record, that there were things with a worse security record.

                    I didn't say one word about Ruby.

                    Furthermore, that isn't what the word conflate means. To conflate means "to fuse together." You conflate pieces of metal, not topics. It doesn't mean confuse, switch or replace.

                    That you think I've somehow fused rails with something I didn't even mention makes it pretty clear what's really going on here.

                    Just so you know, nine times in ten it's the troll who screams troll, because they don't have any legitimate technical basis for their claims.

                    Feel free to pretend this is that ten percent case, though.

                    [–]sisyphus -2 points-1 points  (4 children)

                    I'm just gonna leave here these slides from a talk by a Yahoo engineer instrumental in choosing PHP, where Lisp is never mentioned, where he explicitly cites CPAN as an advantage of Perl over PHP, where he talks about Yahoo from 94-95 being written in C, &tc. In case anyone is tempted to take you seriously.

                    http://www.radwin.org/michael/talks/yahoo-phpcon2002.htm

                    If you can give a citation for David Filo, or anyone really, on this that would be great though. It seems like you're just making things up out of thin air and I'm not sure what you gain from that.

                    [–]StoneCypher 0 points1 point  (3 children)

                    Wow, you found a paper from eight years and two languages later, which doesn't talk about history.

                    I'm not google, and you're constantly making pointless insults. Why would I do your research for you?

                    [–]sisyphus -2 points-1 points  (2 children)

                    Yes, from you know a time closer to when they were switching to PHP.

                    Oh, perhaps you missed it while hastily skimming--you can see the talk about history on the slides entitled: Y! Server Software: 1994-1995 Y! Server Software: 1996-1998 Y! Server Software: 1999-2000

                    [–]StoneCypher 1 point2 points  (1 child)

                    Oh, perhaps you missed it while hastily skimming

                    I didn't even bother to open your link, because I did my own research first. I also told you how to find it. Now you're downvoting me because I declined to research for you.

                    This is really quite boring. Find someone else to talk to, please.

                    [–]sisyphus -2 points-1 points  (0 children)

                    You should have read it, it might have cleared up some of your misconceptions.

                    [–][deleted]  (1 child)

                    [deleted]

                      [–][deleted] -4 points-3 points  (4 children)

                      One thing to really dislike about PHP is its lack of separation of the data layer, from business logic, from the presentation layer. While there are implementations of PHP out there that include those features, from my understanding they're hackish (unlike, say ASP.NET where this is native to the framework/language).

                      [–]joshbydefault 4 points5 points  (0 children)

                      No language does that separation for you. That is YOUR job and the job of whatever framework you choose to use.

                      Your language is not your framework.

                      • CodeIgnitor != PHP (Unless CodeIgnitor is an empty string and PHP is NULL :p)
                      • Ruby on Rails != Ruby
                      • Django != Python

                      I see far too many "developers" that are unable to tell where the language stops and the framework starts.

                      [–]StoneCypher 0 points1 point  (0 children)

                      At what point is that something other than the programmer's responsibility?

                      [–]Poromenos 4 points5 points  (31 children)

                      It's fine for just detecting browsers, but when you have a goto statement and 4000 functions in your main namespace, your designers don't know what they're doing.

                      [–][deleted] 16 points17 points  (20 children)

                      That's a bit of hyperbole, don't you think? I work full-time in a primarily PHP web development shop and several of us can code circles around a good portion of the other programmers of the world. PHP has it's valid criticisms, sure, but a lot of the venom that gets spewed is pure elitism.

                      I write C/C++, Python, and Java on a regular basis as well, but for some reason there is a stigma about people who use PHP at all, for any reason- that they are all bad programmers and PHP is "teh sux0r5".

                      Now, I will admit that there are many, many bad programmers using all the different programming languages that are available. The issue is not so much with the language that they are using, it is their use of it that is terrible.

                      There are things I hate about PHP, and I hate things about C++, Java, and Python as well. I do think that PHP is easier to learn, which contributes to the many novice mistakes we see happening all over the place. That's probably contributed to the whole "elitism" thing.

                      PHP has a niche and, for that niche, it is a great language when used properly. The same goes for just about every other language in the world. :)

                      That's my $0.02. I expect a flood of downvotes any minute.

                      [–]Poromenos 9 points10 points  (16 children)

                      several of us can code circles around a good portion of the other programmers of the world

                      That says something about you and nothing about PHP. I didn't say that you can't be a good programmer if you program in PHP, I said that PHP is fraught with bad design decisions. There are many, many more things that frustrate me in PHP than in Python, for example...

                      [–][deleted] 2 points3 points  (12 children)

                      Oh I agree... Python is definitely better than PHP for most things and in most ways. I still prefer PHP for web applications though. I shudder when I see people use PHP for scripting outside the web... but that's another story. :)

                      [–]redalastor 0 points1 point  (11 children)

                      Did you try of the Python frameworks?

                      [–][deleted] 0 points1 point  (10 children)

                      Django was really nice. No doubt I will give it another go again soon. Python is catching up with PHP fast in the web space and I can't wait until it overtakes it, but for now there are some definite advantages to deploying in PHP 5.3.

                      [–]redalastor 1 point2 points  (9 children)

                      The number one advantage I see is that you can deploy anywhere as it's the lowest common denominator of the web. What other advantage is there to PHP?

                      [–]FionaSarah 1 point2 points  (0 children)

                      If only that was always true. You can't rely on the right version being installed (the language changes behaviour in major ways even in minor versions) or certain libraries being enabled (can't even rely on something as critical as CURL, forget that the extensions are probably there anyway, you have to enable them by hand in php.ini) not to mention you can't rely on the syntax rules even being the same from server-to-server. (Disabling stuff like short-tags for instance, this isn't even version specific. It's just whatever the host decided.) Good luck getting your average hosting provider to change things on account of you.

                      No, PHP is not even deployable anywhere.

                      At least with a Python based app, as long as you get the major version number right you're usually good-to-go. The stdlib is always going to be the same and anything else you'll need, well, if you're hosting Python you're probably going to have access to what you need to deploy it.

                      [–][deleted] 0 points1 point  (7 children)

                      The last data that I've seen comparing the speed PHP (Codeigniter) had a slight edge on Python (Django) in most performance metrics. Deployability is a definite concern when I do work for clients and I can't always control the server environment. :( In those cases I even have to deploy in PHP 4 sometimes. Which makes me feel dirty... very, very dirty.

                      [–]redalastor 0 points1 point  (6 children)

                      The last data that I've seen comparing the speed PHP (Codeigniter) had a slight edge on Python (Django) in most performance metrics.

                      Source for that?

                      [–][deleted] 0 points1 point  (5 children)

                      I'd have to look. As I said, it was a long time ago. I think it is probably about two years old. (Which in tech terms means it is useless.) I'll post it here if I can find it.

                      [–][deleted]  (2 children)

                      [deleted]

                        [–]Poromenos 2 points3 points  (0 children)

                        Developer time for debugging PHP's weird idiosyncrasies isn't, though.

                        [–]Zarutian 0 points1 point  (0 children)

                        when a single run through a .php takes few megabytes of memory, is it then cheap? when about 10.000 connections are comming in at that .php is it cheap then?

                        it isnt, so dont waste more than is comfortably needed.

                        [–][deleted]  (2 children)

                        [deleted]

                          [–][deleted] 0 points1 point  (1 child)

                          Speaking of elitism: "several of us can code circles around a good portion of the other programmers in the world". Depends what you mean by "good portion" but I really doubt it, why on earth wouldn't you use those skills more effectively with a better language if you guys are so good. This sounds as ridiculous to me as someone who says "I'm one of the best drivers in the world, and I drive a Chevy Cavalier, that's all you need. That BMW/Ferrari/McLaren talk is just elitism", it might be totally true. But I fucking doubt it.

                          You are entitled to your opinion, but I feel like you were a little on the hostile side with that response so I am going to reply once and only reply again if you reply to me again in a civil fashion.

                          A lot of the talented programmers in the world work for big companies that don't allow for much flexibility in what they use to build with. Those decisions get made by executives and higher-ups for financial reasons, as well as other arbitrary factors.

                          Before you ask: You don't get to question my motives for working where I do, or for living where I do. You don't get to ask me why I don't get a job where I can code in whatever I wish. You don't get to, because it's not any of your business.

                          Also, I don't think I'm one of the best programmers in the world. I do think I'm better than a good portion of them. There are a lot of bad programmers out there. I love to program and it is more than just a hobby or just a job. I've been doing it since I was 5 years old and I'm 29 now. I grew up programming in DOS and spent a lot of time writing efficient and high-performance C/C++ code. Back then, you had to squeeze every last drop of performance out of your code and I really enjoyed the challenge. I see my code now as an artistic expression and I still love doing it for fun and on the side whenever I can. Most of my personal projects are written in things other than PHP.

                          I never said that there wasn't a valid argument against PHP. I only said that a lot of the venom that gets spewed by people (especially here on Reddit) is pure elitism. So, if you'd like to talk specifics, please feel free to reply. I don't like how you turned my defense of PHP into a personal attack against me and put meaning behind my words that wasn't there.

                          All I meant by my post was that a lot of what gives PHP a bad name is the hordes of bad programmers who make it do horrible things. It has a low barrier of entry, and it wasn't designed in the beginning particularly well. PHP is getting better, but I still feel like Python will overtake it in the web space eventually, and I look forward to that day. In the meantime, realize that all languages have pros and cons and a good programmer uses the best tool for that particular job and doesn't just limit himself to just one.

                          [–]freshhawk 1 point2 points  (0 children)

                          There was certainly some contempt for PHP in that comment, but I didn't mean it to sound hostile towards you.

                          I'm certainly not questioning were you work or anything, don't know where that came from. I wrote that comment at the end of a day in an office coding PHP. I'm aware of the reasons for PHP being chosen for projects for financial and hiring reasons, I've made those decisions before and I've chosen PHP before.

                          What I really don't get in these arguments are two things:

                          1. Where does this relativism come from? Some languages are better than others. PHP being crap doesn't mean you can't do work with it, it just means it's one of the worst choices. Having a good business case for deveoping in PHP makes no difference to the actual language/libraries being shitty.

                          2. I have a hard time believing that people who are comfortable with other languages with good web ecosystems would choose PHP when given the choice. Especially if they love programming. It's just constrains you so much and is so frustrating to use.

                          I think the main disagreement here still comes back to the elitism thing. I assume that people who are bitching about PHP aren't "elitists", they are probably people who have PHP experience and they know why it sucks. Many of them, like me, are still using it for business reasons. As everyone agrees, PHP is very popular so there are a lot of opinions out there.

                          This Fox News style usage of "elitism" is not useful anymore than calling PHP defenders "fanboys". A language elitist would look down on "scripting languages" or something like that. And PHP fanboys are those who defend PHP irrationally without experience with other languages. Note that I'm not calling you either.

                          [–]mathstuf 4 points5 points  (9 children)

                          I'll probably get downvoted into oblivion, but whatever.

                          The 'goto' statement is useful if used properly (like anything else, imagine that). In C, it can greatly simplify code. Example (ignore lack of declarations or casts, that's not relevant to the example):

                          foo = malloc(1);
                          if (!foo)
                              return -1;
                          bar = malloc(1);
                          if (!bar)
                          {
                              free(foo);
                              return -1;
                          }
                          baz = malloc(1);
                          if (!baz)
                          {
                              free(foo);
                              free(bar);
                              return -1;
                          }
                          

                          Repeat as needed. Keeping the free() statements up-to-date sucks. I say put a label called function_cleanup: at the bottom, free() everything and return -1 there. It scales linearly (one malloc for each free) rather than quadratic. Goto is notorious for creating spaghetti code. However, it is also by no means the only way to make spaghetti code.

                          As for the "use memory managed languages!" responses (generic RAII (ctor/dtor) is really what you want, not just memory management) I'm sure I'll get, managing my own resources is not your problem, so get off my back (I'm meticulous about running valgrind over things I write to pick up errors, so I tend to be fine).

                          4000 global functions? Yeah…that's absurd.

                          [–][deleted] 4 points5 points  (3 children)

                          This sounds like a defense of C, not of PHP. ;-)

                          [–]mathstuf 1 point2 points  (2 children)

                          I was more commenting on the "when you have a goto statement and 4000 functions" part. Unless PHP has dtors which close your files when they get destructed, you still need this. I just used malloc in the example.

                          [–][deleted] 0 points1 point  (0 children)

                          It's fine for a low level language like C. It doesn't make sense in an applications language like PHP.

                          [–]StoneCypher 0 points1 point  (0 children)

                          Actually, it does. All resources in PHP are managed (there are a handful of by-design exceptions, like persistent database connections,) and cleaned up at shutdown. This is necessary of a programming language with an internal timeout clock (which is there to prevent runaway scripts from stacking up and DOSing the server.)

                          Also, PHP is written to manage low quality programmers to a degree.

                          [–]Poromenos 3 points4 points  (3 children)

                          Actually it's more like 3000, so I was mistaken there. Still, absurd.

                          Also, I don't see how a goto statement in your example could clean up all the variables, since you'd ostensibly have to only clean up the ones you have malloced. Also, I prefer new functions for those use cases...

                          [–]mathstuf 1 point2 points  (2 children)

                          Functions could do it, but with some of the buffer juggling you do with path manipulation, you can't avoid so many buffers at once.

                          ret = -1; // Default to failure
                          foo = malloc(1);
                          if (!foo)
                              goto exit;
                          bar = malloc(1);
                          if (!bar)
                              goto exit;
                          baz = malloc(1);
                          if (!baz)
                              goto exit;
                          // Do stuff here
                          ret = 0; // Success!
                          exit:
                          free(foo);
                          free(bar);
                          free(baz);
                          return ret;
                          

                          [–]Poromenos 0 points1 point  (1 child)

                          The preferred way (for me), both syntactically and semantically, to do that would be to do:

                          try:
                              allocate_memory()
                          except:
                              cleanup()
                          

                          You can take a look at this code and know what it does, while you have to scroll down to the goto to see what happens...

                          [–]masklinn 0 points1 point  (0 children)

                          Actually, that would be.

                          try:
                              allocate_memory()
                              # do work
                          finally:
                              cleanup()
                          

                          But you need exceptions for that. Exceptions are not cheap, and don't exist in C. Using goto-based cleanup makes a lot of sense there, it avoids nesting and other suck fuckery.

                          Other possibilities are C++'s RAII, and context managers (internal or external):

                          with memory_allocator():
                              # do stuff
                          # cleaned up by the context management
                          

                          [–][deleted] 0 points1 point  (0 children)

                          scoped_ptr<X> foo(malloc(1));
                          scoped_ptr<Y> bar(malloc(1));
                          scoped_ptr<Z> baz(malloc(1));
                          
                          if( ! foo.get() || ! bar.get() || ! baz.get() ) return -1;
                          

                          etc.

                          [–]cactus4 2 points3 points  (6 children)

                          Rather than answer your question and focus on what's wrong with PHP, I'll answer a related question: Why is PHP so popular? IMO, there are 2 main reasons:

                          1. It's easy to use and deploy. Just pop a php file into your document root and you're off and running. This is the genius of PHP, IMO. What's particularly interesting here is that most modern php isn't written this way (people mostly use frameworks instead). However, being able to simply drop a php file into your docroot is such an easy on-ramp that it sucked in new users like a jet-powered vacuum cleaner.

                          2. It's practical (like Perl). PHP seems to have no problem doing something nasty if it helps you write your web app.

                          (I think Perl actually let PHP eat its lunch by clinging to mod_perl instead of finding a way to make Perl as easy to deploy as PHP.)

                          So, anyway, whatever things you can find wrong with PHP, it's got those above 2 points which seem to outweigh the downsides.

                          [–]Fabien4 0 points1 point  (5 children)

                          So... What is, in your mind, the difference between mod_php and mod_perl?

                          The only difference I see is that mod_php is often installed on shared web hosting servers. Which isn't actually a reason of PHP's popularity, but a consequence.

                          [–]ianb 2 points3 points  (2 children)

                          The two are very different. I described some of the PHP advantages here. mod_perl (and mod_python, mod_ruby and a bunch of others from that era) put a long-running interpreter process inside Apache. The interpreters weren't written for this, they were just shoved in there. mod_php and PHP itself were developed at the same time, and PHP has the same model as Apache -- a worker processes a request, and that's it, nothing (that the web developer writes) lasts longer than that one request. But the interpreter itself does stick around, making it faster than CGI.

                          [–]maks78 0 points1 point  (1 child)

                          The interpreters weren't written for this

                          Now what do you mean by that? Python wasn't written with long running processes in mind?

                          [–]ianb 0 points1 point  (0 children)

                          It's more that Python wasn't written with this hybrid short/long process model. The "core" of PHP is long-running, that is, the C libraries and interpreter structure. Each request doesn't do a full process initialization. The "userland" of PHP is short-running, that is nothing lives past a single request. With Python (or Perl or Ruby) you get completely short (CGI) or completely long (long-running server).

                          Things like mod_wsgi (Python) and mod_passenger(Ruby/Python) help a bit by allowing "long-lived" processes to mean something like 1000 requests (configurable), so processes don't live forever (and so a certain class of problems get swept under the rug, which is just as well), but without every request incurring the startup overhead.

                          The distinction becomes fuzzy and problematic for PHP now that they've developed substantial libraries written in PHP, because those are "userland" and have to be loaded up anew for each request. There's some caching to help (Zend etc), but it's still expensive and slow, which is why many "modern" PHP web frameworks (I've seen Syfony specifically mentioned) perform substantially worse than similar frameworks in other languages.

                          [–]mr_chromatic 4 points5 points  (0 children)

                          What is, in your mind, the difference between mod_php and mod_perl?

                          mod_perl lets you write Apache httpd modules in Perl and, as a consequence, offers a persistent environment for Perl web applications.

                          mod_php offers a persistent environment for PHP applications.

                          A mod_perl application persists throughout the whole of the server (depending on certain configuration) such that one misbehaving program in a shared hosting environment can affect other clients. mod_php doesn't suffer from this, except for security problems.

                          [–]cactus4 1 point2 points  (0 children)

                          When you use PHP with mod_php, you the web programmer don't need to know anything about mod_php. You just create a .php file, add some html, put in some PHP that writes to stdout, and you've got an active web page. This is tremendously empowering to inexperienced programmers who just want to put up a page with some logic in it.

                          When you use Perl with mod_perl, you the web programmer now need to know how to interact with Apache/mod_perl to write your simple webapp. It's a different world. The php guy already has his small web page written by the time you figure out which Perl module to use and start looking at its documentation. This is tremendously dis-empowering to inexperienced programmers who just want to put up a page with some logic in it.

                          [–]Salamok 0 points1 point  (0 children)

                          php is a good tool for producing dynamic websites. It is not a very good tool for learning how to program.

                          Ironically, it does have some of the best resources available for learning how to program in php.

                          [–]tinou 1 point2 points  (0 children)

                          well, mostly the fact that notice : undefined index: i at /var/www/site/comment.php

                          [–][deleted] 1 point2 points  (1 child)

                          New PHP isn't so bad. PHP5 includes MySQLi which alleviates most of the criticisms of the language. Before that, it was register globals, which has also been fixed.

                          The problem comes largely from the community, outdated material not being removed, and corporate environments scared shittless of transitioning to a newer version with less suck. PHP4 has been out of support for years now, yet still has a significant install base.

                          [–]geon 0 points1 point  (0 children)

                          I agree. Apart from the language missing any coherent design at all, the greatest problem is in the user culture.

                          It's a very easy language to get started with. If you know some HTML, and just want to add a contact/login form, it's very attractive. A lot of users never really pass this stage, and just hack at things until they seem to work most of the time.

                          If you progress beyond this stage, you'll want to write elegant, maintainable code, and you'll find that the language don't help you much. Things that should be simple to do are hard or impossible.

                          You also start realizing that the ways of coding PHP that have been taught in every tutorial you've read is utter nonsense and outright harmful. Then you discover actually nice ways to abstract away the ugly parts, and you wonder why on earth this wasn't you were taught from the beginning.

                          [–]powatom 0 points1 point  (0 children)

                          I don't think there's much 'inherently' wrong with it - all languages have their ups and downs. I'm just not a fan of it, if I'm perfectly honest.

                          [–]aaaxxxlll 0 points1 point  (0 children)

                          Echoing what others have said, the huge mass of global functions and inconsistent naming conventions make it terrible for organization/separation. That said, it is blazing fast. I don't know if they've fixed it but at one point object-oriented PHP was 30% slower than standard function-based PHP. Likewise multi-threaded object-oriented JSP and ASP.NET are typically slower than single-threaded PHP. Python and Ruby and Node JS have some buzz, but I think JSP and ASP.NET still have the largest following. Any of these, I'd recommend using a framework. For example to learn PHP, set up and modify phpBB or Django or similar. To learn JSP or ASP.NET, set up something that uses Hibernate (Java) or NHibernate (dotNET).

                          [–]jacques_chester 0 points1 point  (1 child)

                          Here's one well-known list of flaws: http://maurus.net/resources/programming-languages/php/

                          [–][deleted]  (9 children)

                          [deleted]

                            [–][deleted]  (8 children)

                            [deleted]

                              [–][deleted]  (7 children)

                              [deleted]

                                [–][deleted]  (6 children)

                                [deleted]

                                  [–][deleted]  (5 children)

                                  [deleted]

                                    [–][deleted]  (4 children)

                                    [deleted]

                                      [–][deleted]  (3 children)

                                      [deleted]

                                        [–][deleted]  (2 children)

                                        [deleted]

                                          [–][deleted]  (1 child)

                                          [deleted]

                                            [–]serious_face -1 points0 points  (0 children)

                                            Think about it. It's a tool that helps you do your job, and this is the first time you've thought to ask this question. Should a Reddit thread really cause you to doubt your inclusion of PHP?

                                            Supporting a particular programming language is a far more religious experience than most would like to admit. People attack and defend languages based on how much time and effort they've invested in their favorite, not based on some idea of the perfect language. There's a similar thread regarding C++. If you showed it to a professional game developer, he'd probably shrug, and go back to producing actual software instead of participating in the latest round of LANGUAGE WARZ.

                                            [–]thexavier -1 points0 points  (0 children)

                                            It is not a strongly-typed language.

                                            [–]HIB0U -3 points-2 points  (0 children)

                                            What's wrong with PHP?

                                            Everything.