The general consensus on PHP



  • Many people I meet, see PHP as some kind of a holy grail. That's fine and all, were it not that I often have to "defend" my own preference in Web Development (ASP.NET) .

    I guess PHP is equally as good as ASP.NET. But to me, ASP.NET seems more polished, a nice IDE, and one can focus on Business Logic instead of generating HTML code. I prefer to stay away from HTML and JavaScript, and ASP.NET does that for me nicely. I guess its just personal preference. I don't know what JSP offers however.

    However many people say PHP is easier to learn than ASP.NET, which I don't understand. I do note however, that many PHP developers I know, would like to stay away from OOP as much as possible. Reading a lot on the web, it seems PHP is mostly used for small projects. But, PHP can deliver good solutions (http://www.oscommerce.com/) at a low cost treshold.

    Also, all the webhosts have PHP, and ASP.NET is a minority in that world.

    My question to you is, because there are many professional developers here: What is the general consensus on PHP among professional developers?

    To me its just personal preference, but as I am a novice developer, I am not in a position to judge which is better, but I do like to know the opninion of more experienced developers.



  • everyone that I talk to hates PHP.  They will only use Perl or ASP.NET.   I also know some people that are using Scheme for CGI.



  • Quick awnser, there is no such thing as general consensus regarding PHP, however most of the developers in this site seem prety hostile towards it.
    (in short, you are begging for a flame war, so i shall start the show running by giving my opinion)
    PHP is not a diffucult language to learn, and is somewath enjoyable to use, but i prefer to avoid it, especialy because, not beeing much of a web programmer, i have to integrate apps developed by others, into my systems. The whole package lacks polish.
    For example, i had a system running PHP 5.0.4, and another running 5.1.6. The bundled xml library (simplexml) had a method missing in one of the systems.
    Guess which? The most RECENT one. The revision for that library was older in the younger bundle.
    So you may say this was an error on part of the packager, but...
    Add to that , p.ex. some "programmers" who love to code with Register_Globals = On (very bad on security), or love to infect the system with pear librarys to make trivial tasks.

    Anyway, this may seem unfair on the language, but it ist too easy to make mistakes on PHP.

    So my recomendation would be: If you intend to do it alone, for fun, use it., no regret.
    If you will use it for serious production code, stay away from it, its better for yourself (AND escpecialy for who inherits your code), ASP.NET seems good, JSP no problem.

    Well as an aside, there is only on technology wich pisses me off daily more than PHP (Its flash) so take my comment with a grain of salt.

    Cheers!

    EDIT: SOrry about the formating, ti looks ok in preview (ah the forum software, a lesson in how no to use ASP)



  • I use PHP quite often. I like it.

    The main problem with PHP is that there are many people with half programming knowlage working with it. (See examples posted on php manual pages for example)

    You can produce bad code in every language. PHP contains just loads of those examples.

    Oh, and register_globals is not always bad. If you put the warning level on max you get warnings for each used but not preveus assigned variable.
     



  • I'm among those who do not like PHP. The main reason is that the language is ugly. It's too obvious that this once was a collection of hacks that eventually have grown into something that somewhat resembles a programming language. Just like BASIC in the 80's, it's a language which allows for quick hacks but does not encourage good design.



  • /me drops a couple pennies on the table.

     

    I learned PHP on the job with a previous employer (a mom&pop ISP/Hosting shop). It started out just tweaking minor web pages and eventually graduated into fullscale web applications. I've written some fairly large-scale programs in several languages, such as Python, PHP, C++, C#, and Java. Right now I write web applications in ASP.NET.

    I must say, there are times when I miss PHP. Language-wise, there's none better than C# in my opinion, but some decisions were made when building the ASP.NET framework that continue to tick me off on a nearly daily basis. The biggest offender is the systemic prevalence of the post-back. Posting to the page that build your form is not necessarily bad, per se, but do you really need to post-back every time you switch a tab on a tab control?

    HELL NO you don't. In fact, you shouldn't. Ever. That should be a *get* not a post.

    Then there's the javasript necessary to *call* a post-back. Why do they embed it in a link? Seriously, you should never have your href attribute contain javascript, that's foul! onclick is where that should be handled.

    Gad, I'm ranting. Deep breaths......

    My point is that many of the things in ASP.NET that break good web-development practice do so in a huge way and are pushed as "the right way to do things" by the powers that be. PHP has none of that, and I sometimes miss that. I can code that way in ASP.NET by basically ignoring "accepted best practice" and doing things right, but it's slower and gets me into trouble with my fellow developers who are afraid of HTML and Javascript.



  • Good:
    PHP is nice it offer more possibilities out of the box than asp 3
    the syntax is more natural than most "new" programming languages
    It's easy to write/debug
    It's lightweight
    It's quite fast
    Hosting/Management is cheap

    Bad:
    It's easy, so easy that some non programmer enter the market knowing only a little PHP and building bad apps ( I'm no graphic designer so I don't draw design )
    It's not secure out of the box, it's secure but you can easily write unsafe code with it, mostly with some sql server and eval.
    by today standard PHP begin to show its age, mostly when handling multi byte character format.
    there is little uniformization in API that almost do the same thing so code can vary from a programmer to another one.

    ok as you see most of the bad point come from bad dev practices. So ASP.NET is quite bad too, why because of the IDE visual studio is powerfull but gives bad practice to dev mostly regarding OOP programming practices.

    and comparig JSP/ASP versus PHP is quite unfair from a dev point of view, one is a script language and should be considred as is, the other are compiled language with validation at compile time.



  • @Ice^^Heat said:

    I guess PHP is equally as good as ASP.NET.

    I don't know a thing about ASP.NET, but i'm sure it's way better than PHP. I mean PHP is hardly a language at all. It's just a bunch of libraries and functions. It's "easier to learn" because there is not much to learn.

    It's OK to do really simple stuff with PHP. But when things get just a little more complex PHP is a major PITA. When you do real projects (other than mailforms) in PHP you are either a moron or a masochist.

    @Ice^^Heat said:
    Many people I meet, see PHP as some kind of a holy grail.

    If there is a holy grail its name is LISP 😉


    And for the record: That is THE general consensus on PHP among professional developers.



  • By the way, I find Classic ASP just as annoying as PHP.

    Well... back to my Classic ASP project.



  • I find that PHP as a language is an ad-hoc mess. Too many functions that do the same thing, and not enough strict formality in the language as a whole. There is a lack of proper scoping rules, and if one uses a variable in a function that was defined in a higher scope, you are required to declare it as "global" inside the function. The "$" to declare variables is entirely redundant because $ is the only one there is, and it also allows variables with the same name as a function.

    I don't see much good about PHP, in the sense that it has features that I'd like in other languages. Other than that it's Just Another Language, and one can apply proper design patterns in it as much as you like. I don't make use of the fact that Reg_Globs is turned on one my host, and use the $_GET and $_POST hashmaps instead. (I continue to be annoyed at PHP calling it an "associative array": a word without any real meaning. An array is a numbered list.)



  • @Ice^^Heat said:

    I guess PHP is equally as good as ASP.NET.

    A niggling point, perhaps, but ASP.NET is not a language.   It's a set of libraries and assorted infrastructure built on top of .NET and as such you can use any .NET language you like, C# and VB.NET are the most common, but managed C++ or the new IronPython or NetCOBOL would work just as well.

    -cw



  • I don't think PHP would be a good choice for learning how to program, but it is probably less frustrating.  How many hours have we spent as beginning programmers chasing down that missing semi-colon in a 20 line program?



  • @dhromed said:

    I find that PHP as a language is an ad-hoc mess. Too many functions that do the same thing

    Name one? (But they lack a default way of naming functions)

    , and not enough strict formality in the language as a whole. There is a lack of proper scoping rules, and if one uses a variable in a function that was defined in a higher scope, you are required to declare it as "global" inside the function.
    True, but then again, do you really want functions to mess with global variable? Or should you review your design again and maybe go for an OOP way?

    The "$" to declare variables is entirely redundant because $ is the only one there is, and it also allows variables with the same name as a function.
    Just makes it very clear you are dealing with a variable, which is very nice for beginners to see the difference between functions/variables.

    I don't see much good about PHP, in the sense that it has features that I'd like in other languages. Other than that it's Just Another Language, and one can apply proper design patterns in it as much as you like. I don't make use of the fact that Reg_Globs is turned on one my host, and use the $_GET and $_POST hashmaps instead. (I continue to be annoyed at PHP calling it an "associative array": a word without any real meaning. An array is a numbered list.)
    You mean "my definition of array does not match the PHP definition of an array".

     



  • @Daid said:

    The "$" to declare variables is entirely redundant because $ is the only one there is, and it also allows variables with the same name as a function.
    Just makes it very clear you are dealing with a variable, which is very nice for beginners to see the difference between functions/variables.

    You should not defend this stupidity. PHP is not meant as a language for beginners, though it looks like it was designed by one. 



  • @ammoQ said:

    @Daid said:

    The "$" to declare variables is entirely redundant because $ is the only one there is, and it also allows variables with the same name as a function.
    Just makes it very clear you are dealing with a variable, which is very nice for beginners to see the difference between functions/variables.

    You should not defend this stupidity. PHP is not meant as a language for beginners, though it looks like it was designed by one. 

    There are few languages ment for beginners, and those that are don't work anymore when you want to do something more advanced. You call it a stupidity, because it's redundant. Well, the ';' in C at end of statements is redundent, I guess you rather see that removed too?

    I'm not saying PHP is a holy grail, IMHO there is no such thing as a holy grail in programming, every tool has it's goal. I've working a briljantly set up PHP project. Very nice designed, good OOP structure, easy extendibility. And even the novice programmers that where hired could help out directly. On the other hand, I've worked on a C# .NET application, and that had no design, spiderweb structure, and was buggy has hell and evil to maintain.

    PHP has some strangely named functions (stuff like underscore between words in a function? like: strtoupper vs str_replace) but if you look past that you see a pretty feature rich language with loads of extentions.

    In the end, it doesn't mind if you use PHP, C#, Java or VB. What really mathers is that you know what you are doing. Open your mind and the possiblities are limitless. Or you could show zealot behavior and stick with what you think is pretty.



  • @Daid said:

    There are few languages ment for beginners, and those that are don't work anymore when you want to do something more advanced.

    BASIC = Beginner's All-purpose Symbolic Instruction Code

    You call it a stupidity, because it's redundant. Well, the ';' in C at end of statements is redundent, I guess you rather see that removed too?

    The ; in C is not redundant; consider the program

    int main(int argc, char* argv[]) {
      int a;
      a=3;
      -5; /* useless but valid */
    }
     

    Well, I've once worked with a language (Informix 4GL) that used neighter ; nor end-of-line to determine the end of each statement. It just "guessed" the end of the statement when something that looked like a new statement came along. Gave me strange feeling, though. Anyway, a bit of "redundancy" in the grammar is necessary to distinguish between syntax errors and correct programs. IMO the ; in C helps more in that respect than the meaningless $ in PHP.



  • @Daid said:

    Just makes it very clear you are dealing with a variable, which is very nice for beginners to see the difference between functions/variables.

    @Daid said:

    I'm not saying PHP is a holy grail, IMHO there is no such thing as a holy grail in programming, every tool has it's goal. I've working a briljantly set up PHP project. Very nice designed, good OOP structure, easy extendibility. And even the novice programmers that where hired could help out directly. On the other hand, I've worked on a C# .NET application, and that had no design, spiderweb structure, and was buggy has hell and evil to maintain.

    That's true; one can apply proper pregramming procedures in any language. Or fuck them up. I'm not making a case for or against PHP's tendency to invite or prevent certain correct or incorrect behaviours, thouhg implicit type conversion, such as is present in PHP and Javascript, is iffy, iffy and iffy again. [0 -> false] and ['' -> false] is stupid, and, to boot, inconsistent with empy maps and empty arrays, which do not evaluate to false.

    @Daid said:

    In the end, it doesn't mind if you use PHP, C#, Java or VB. What really mathers is that you know what you are doing. Open your mind and the possiblities are limitless. Or you could show zealot behavior and stick with what you think is pretty.

    Agreed. But we can still complain about egregious features of various languages. 🙂

    You call it a stupidity, because it's redundant. Well, the ';' in C at
    end of statements is redundent, I guess you rather see that removed too?
     

    The ; is definitely not redundant. In JS it's not required, but I write it anyway. Without it, a compiler/interpreter must "intelligently" scan the current line and the next one to see it if they form a single statement. Using ; you remove all doubt.

    I believe the ; is mandatory in PHP. At least that's on my host's php.ini.



  • I don't work in web-dev, so I don't have any use for either; but I
    did a couple of projects at uni a few years back using PHP and remember
    finding it nice enough for those. Two points though... One: surely you
    shouldn't really expect to use a language named Personal home page Hypertext Preprocessor to do serious business stuff. Two: The only person who's really defended PHP so far said:

    "Well, the ';' in C at end of statements is redundent"

    ...hmmm... clearly someone who knows his stuff...



  • @zoolicious said:

    "Well, the ';' in C at end of statements is redundent"

    ...hmmm... clearly someone who knows his stuff...

    The only 'example' that shows otherwise is one that shows a statement that does nothing but is C correct. Guess what, it does nothing, so why should you be able to do that? I'm saying it's redundent, just like the $ in php is dedundent, not that you can blindly keep it out and still use 100% of all the quirks that the language exepts now.

    Take a look at javascript and lua, they live happly without ; (but take them if you add them)
     

    (I think the real reason why PHP has $ in front of variables is so you can embed them into strings, echo "Hello $WorldYouAreOn"; and that IS ucky. To bad you all fail to mention that part.)



  • Failing to see the possiblity that C could be made without ';' is shortsightness on
    your behalf.


    Oh and the 'attacker' on PHP says it contains redundent stuff and is writen by a 5 year old. Great arguementation 😉

    (I would have edited my post, but the WTF forum doesn't let me) 


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.