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) 



  • @Daid said:

    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.

    Here is another example, one that does something:

    a = b;

    -c==d?doSomething():doSomethingElse();

     

    Face it: The rest of C's weird syntax make the ; very desirable. 

     



  • @ammoQ said:

    Here is another example, one that does something:

    a = b;

    -c==d?doSomething():doSomethingElse();

     

    Face it: The rest of C's weird syntax make the ; very desirable. 

     

    I surely hope I never see that in production code.

    After all:

    a = b

    if (-c == d)

      doSomething()

    else

      doSomethingElse()

    does the same and doesn't make you think WTF? Ofcourse you could also overload the - operator to do something like

    TObject X;

    -X; 

    But does that make sense? The examples given so far don't make sense in production code. While it's very fun to do stuff like that in examples and contests, you surely don't do that in production code.... I hope...

     

     

    (Call me a bitch, because I am :P)



  • @Daid said:

    @ammoQ said:

    Here is another example, one that does something:

    a = b;

    -c==d?doSomething():doSomethingElse();

     

    Face it: The rest of C's weird syntax make the ; very desirable. 

     

    I surely hope I never see that in production code.

    Of course the second example is a bit artificial too, but eventually the language must be defined non-ambiguosly. C is bad enough in that respect, though.

    The last thing I want is a compiler that guesses which possible interpretation of ambiguos piece of code is more likely to resemble production code.



  • @ammoQ said:

    The last thing I want is a compiler that guesses which possible interpretation of ambiguos piece of code is more likely to resemble production code.

    PING PING PING PING PING. You have scored the jackpot.

    So redudency is usefull to make sure the compiler interprete (SP?) your code correct. And thus, the $ in php is usefull to make sure the compiler sees your variable actualy as a variable (and not as a define, function, keyword or anything else that PHP might see).

    Ofcourse the example:

    for(int i = o i < w - i i ++)

    Would have scored points for unreadablity, but seems you are pretty focused on wierd C constructions. 

    Enough for today, I hope the light of the C gods shines on you, surely did not on me today (don't you hate the fact that you cannot throw software out of the window?)

    (Oh, and PHP is a pretty wierd language, with all kinds of constuctions you should say away from, like magic quotes, register globals, variable embedding in strings.)
     



  • @Daid said:

    So redudency is usefull to make sure the compiler interprete (SP?) your code correct. And thus, the $ in php is usefull to make sure the compiler sees your variable actualy as a variable (and not as a define, function, keyword or anything else that PHP might see).

    To expand on this, the $ in PHP is there for the same reason it's in Perl and for the same reason it's in most *nix shells -- easy compilation. PHP and Perl are *scripting* languages, designed for high-speed interpretation and execution. In contrast, C, C++, Java, C# are pre-compiled. They can afford to take the extra time to figure out the semantics behind a symbol. PHP and Perl don't have that luxury -- at least Perl didn't back when it was designed, and PHP is basically Perl with that whole HTML interspersal thing mixed in.



  • @Daid said:

    So redudency is usefull to make sure the compiler interprete (SP?) your code correct. And thus, the $ in php is usefull to make sure the compiler sees your variable actualy as a variable (and not as a define, function, keyword or anything else that PHP might see).

    So you have variables with the same name as functions, keywords and stuff? If the main purpose of the $ is to solve that problem for variable, how comes that functions are not preceeded with an § so they can have the same name like a keyword?

     




  • @Whiskey Tango Foxtrot? Over. said:

    To expand on this, the $ in PHP is there for the same reason it's in Perl and for the same reason it's in most *nix shells -- easy compilation. PHP and Perl are scripting languages, designed for high-speed interpretation and execution. In contrast, C, C++, Java, C# are pre-compiled. They can afford to take the extra time to figure out the semantics behind a symbol. PHP and Perl don't have that luxury -- at least Perl didn't back when it was designed, and PHP is basically Perl with that whole HTML interspersal thing mixed in.

    The $ in shells is necessary because without the $, it is a string literal.

    echo hello world

    For a command line interpreter, this behaviour makes sense; a lot of commands expect a filename or something similar.

    I don't know the reason for Perl, but I doubt it's speed. I'd rather guess that Perl requires it to avoid ambiguity.
     



  • @ammoQ said:

    I don't know the reason for Perl, but I doubt it's speed. I'd rather guess that Perl requires it to avoid ambiguity.

    I'm not saying it's elegant; I personally hate it. I'm simply attempting to explain the reasons.

    Perl features a different sigil to refer to a different type of variable -- @ for arrays, $ for scalars, % for hashtables, & for subroutines, etc -- allowing the parser to determine the semantic meaning of a symbol without requiring semantic analysis. This is certainly to decrease the time it takes to interpret a statement and execute it. However, it also allowed for a design philosophy of "different things look different".

    PHP just wanted to be Perl-like, so they added the $ to pick out a variable during parsing, but because memory access was designed differently there was no need to differ access types by sigil.



  • To clarify, perl's variable prefixes are actually based on what type of value is being produced.  An array variable is prefixed with @, but an array element is written

    my @array = (1, 2, 3);

    return $array[$foo];

     and not @array[$foo].  The parser allows the latter, unless the "use strict" pragma is in effect, but it's incorrect.



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

    No. Failing to see why it's necessary is inexperience and ignorance (it doesn't sound like you know any C/C++ from your above posts) on yours. You think it's necessary syntax in virtually every serious programming language just to annoy people for no good reason? Now that's shortsightedness.

    As a general and totally uncontrived example: how about the fact that it decouples the end of a line of code from the end of a line in a text editor?

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

    I agree there's no need to be hard on the creator. It was actually created by a hobbyist during the internet assplosion as a way of adding dynamic content to his personal home page. Not to power enterprise websites. Oh, and I bow before your ability to create new words out of thin air. That kind of arguementation comes from a truly great edumacation ;)



  • @ammoQ said:

    @Daid said:

    So redudency is usefull to make sure the compiler interprete (SP?) your code correct. And thus, the $ in php is usefull to make sure the compiler sees your variable actualy as a variable (and not as a define, function, keyword or anything else that PHP might see).

    So you have variables with the same name as functions, keywords and stuff? If the main purpose of the $ is to solve that problem for variable, how comes that functions are not preceeded with an § so they can have the same name like a keyword?

    (I'm answering this for Perl, because these things happened for real reasons in Perl, and then PHP just copied them without thinking about it too hard) 

    In Perl, they are - the sigil for a function is &. To make your life simple, in any case where the compiler can tell that a bareword is a function name, you may omit the &.

    The use of variable sigils serves many purposes. It creates separate namespaces, so that you don't accidentally clash variable and function names. It eliminates certain ambiguities in the language parse tree that would otherwise require a complicated context-sensitive parser, more punctuation, or whitespace-sensitive magic (is "foo [1]" an array dereference, or a function call taking an array reference as a parameter?). Possibly most important of all, it allows you to say things like "foo $bar baz" without having two different syntaxes for variable references.

    (Perl 5 also uses the sigil to determine the return type of the expression - this is a historical misfeature which is being removed in Perl 6)



  • @Angstrom said:

    To clarify, perl's variable prefixes are actually based on what type of value is being produced.  An array variable is prefixed with @, but an array element is written

    my @array = (1, 2, 3);

    return $array[$foo];

     and not @array[$foo].  The parser allows the latter, unless the "use strict" pragma is in effect, but it's incorrect.

    @array[$foo] is not incorrect, and it's allowed under strictures. However, it is not the same thing as $array[$foo] - the former is a list, while the latter is a scalar. You could also write @array[$foo, $bar, $baz] and get a three-element list; this is known as an "array slice".

    This behaviour is considered a historical mistake. It is being altered in Perl 6, so that you simply use @array[$foo] all the time - the sigil names the variable, and doesn't change depending on return type.



  • I do apologise (I can't edit the original post to include it there) - 'argumentation' is a perfectly valid word... Showing up my own ignorance I guess /roll



  • I've found both to be pretty good candidate for WTFs. PHP is a mutant, ASP.NET is a toy.



  • @Ice^^Heat said:

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

    There isn't any, as already mentioned.

    I, on the other hand, hate PHP. For several reasons:

    • I'm just fine with dynamic & "implicit" typing, but I hate weak typing, because it's unpredictable and often depends on pretty random coercion rules
    • "$". It has a meaning in Perl, it has a meaning in Ruby, but it doesn't have any meaning whatsoever in PHP. I don't doubt it's necessary due to the ad-hoc mostly retarded implementation of the language, but it still doesn't make sense
    • No namespace (oh, and did you know that if PHP gets namespaces, the namespace separator may be \? Nope, i'm not kidding you, seems that "there isn't any other character left"...)
    • And since there's no namespace, every single function is in the global namespace of course, all 3000 of them.
    • No naming standard, and not only there isn't any naming standards but you can take any 10 functions of the standard lib and you'll find half a dozen different naming schemes, "to" can be "to" or "2", words can be camelCased or underscore_separated, functions can use verbs as prefixes or as suffixes, even the order of the arguments varies from one function to another!
    • Oh, by the way, ever wondered why there were 3000 functions? Because every possible variation in a function use actually creates a new function. You thought you could pass a parameter to a case-sensitive search function to make it case-insensitive? Nuh-uh, you have to use another function with the same name (prefixed -- or postfixed? depends) than the original one, and potentially swapped parameters too just to be sure you remembered to read the docs, cause it's too easy if the interface is the same. The language should, like, keep you on your toes or something.
    • Every function is global period. No you can't nest functions, no you can't scope functions, if you define a function it's global whatever place you define it at.
    • Functions aren't first-class objects or course, and the few "functional" constructs (array_filter, array_map, ...) are retarded. At best. Naturally, since functions are not first-class there ain't no anonymous function or closure or lexical scoping. Every function is global anyway so these points are moot.
    • And of course, PHP's support for recursion completely blows. Who'd want recursion anyway? If goto was good enough for my father iteration is good enough for me!
    • I think I already mentioned scopes, which PHP of course doesn't have. Either a variable is global, or it's function-local. Period.
    • PHP arrays are bizzaro hybrids between arraylists (Ruby arrays, Python lists, Java arraylists, ...) and maps/hashes/hashmaps. And they suck.
    • Until PHP5, PHP had no actual standard DB interface and no handling for auto-escaping. addslashes FTW... or was it mysql_escape_string? Ah no there's also mysql_real_escape_string, which is probably the real one, but wait i'm using Postgres so I should probably use pg_escape_string right? Unless i'm using bytefields of course in which case there's pg_escape_bytea... RHAAAA! Of course, even though PHP now has mysqli and PDO, they managed not only to make the OO interfaces to both suck and not to modify the PHP4 db apis to mention them. Checking the aforementioned mysql_real_escape_string? Don't worry, unless you go check the comments you won't find any mention of these. Go-go gadgeto quality for the win.
    • Braindead decisions e.g. magic_quotes and other register_globals. How can you make the core language unsafe by default? Is there anyone who actually sat down and thought about that shit?
    • While the language doesn't aggressively force you to create good/clean code, it sure as hell doesn't help you create clean stuff.
    • The error reporting sucks, the error messages suck, there is no true `strict` mode, and the tools suck. Some people tell me it's possible to easily debug PHP, I can say that it may be possible but it sure as hell ain't obvious.
    • Most documentations, tutorials and others not only suggest but support seriously unsafe and/or retarded practices.
    • And most of the community is kind, but utterly clueless.
    • PHP's support of unicode is pathetic. Even worse than Ruby's, and that's telling as Ruby's unicode support currently utterly blows. Fairly annoying for a web-based language...
    • PHP is slow. Why do you think people tell you to use a bytecode compiler/cache? Because PHP is a fucking dog. A limbless one.
    • PHP's APIs are among the worst in the world. I strongly suggest not to create any C module to PHP. Ever.

    These are pretty much my reasons for hating PHP, on top of an aesthetic issue (PHP code looks bad) and my "gut feeling".



  • @masklinn said:

    There isn't any, as already mentioned.

    I, on the other hand, hate PHP. For several reasons:

    (snip) 

    These are pretty much my reasons for hating PHP, on top of an aesthetic issue (PHP code looks bad) and my "gut feeling".

    I feel for you. Your elaborate answer indicates you actually have to work with PHP. Makes me feel lucky since I ran away from a PHP job immediately after reading a manual of the language.

    Anyway, you are not alone...   http://www.bitstorm.org/edwin/en/php/



  • @ammoQ said:

    @masklinn said:

    There isn't any, as already mentioned.

    I, on the other hand, hate PHP. For several reasons:

    (snip) 

    These are pretty much my reasons for hating PHP, on top of an aesthetic issue (PHP code looks bad) and my "gut feeling".

    I feel for you. Your elaborate answer indicates you actually have to work with PHP. Makes me feel lucky since I ran away from a PHP job immediately after reading a manual of the language.

    Anyway, you are not alone...   http://www.bitstorm.org/edwin/en/php/

    Well thankfully no, I'm not working with PHP right now (I've done it for some time though), and I'll try not to work with it for as long as I can (but yeah I know I'm not alone in hating PHP)



  • "There is no programming language, no matter how structured, that will prevent programmers from making bad programs."
    -Larry Flon



  • @masklinn said:

    @ammoQ said:
    @masklinn said:

    There isn't any, as already mentioned.

    I, on the other hand, hate PHP. For several reasons:

    (snip) 

    These are pretty much my reasons for hating PHP, on top of an aesthetic issue (PHP code looks bad) and my "gut feeling".

    I feel for you. Your elaborate answer indicates you actually have to work with PHP. Makes me feel lucky since I ran away from a PHP job immediately after reading a manual of the language.

    Anyway, you are not alone...   http://www.bitstorm.org/edwin/en/php/

    Well thankfully no, I'm not working with PHP right now (I've done it for some time though), and I'll try not to work with it for as long as I can (but yeah I know I'm not alone in hating PHP)

    I feel your pain, masklinn.  IMO, the people that like PHP don't (no, make that can't) know any other language.   I used PHP years ago when the only options at the time were basically Perl, ASP/Vbscript, PHP, and Java.  Well I just needed a down and dirty web interface to a custom developed quoting application, so I chose PHP.  After that I moved to ASP.Net using VB/C# and I'll never go back.  Even though ASP.Net creates some awful client side stuff, I don't really care.  I'm making Intranet sites not publicly consumable web apps.  Having a truly object oriented language and not having to muck around with HTML is a godsend and things only got better with ASP.Net 2.0.  PHP sucks when it comes to reporting too.  Writing thousands of lines of code to create a decent report SUCKS big time.  That will be the last time I use PHP - I'd rather flip burgers for minimum wage.




  • PHP is a fucking dog. A limbless one.

    BAHAHAHA! :D (my site runs fast, though. Because it's real tiny.)

    I remember this online article that heartily defended PHP/MySQL as the superior option compared to ASP (classic). The article proposed, among other things, variable variable names ($$foo) as a great feature. But that was some time ago, and even though it may have had some merit back then, insights that may have been valid in that
    day are now completely wrong, as PHP has become a tangled hairball of
    junk, while other languages and platforms have evolved and been
    developed.

    not having to muck around with HTML is a godsend and things only got better with ASP.Net 2.0

    Hm. While I'm in favour of letting a programmer program forpetessake, I am cautious of arguments that dismiss a rather pivotal part of websites: the HTML. I have some distrust of out-of-the-box MS-generated HTML. But I have not seen the .Light yet, so...



  • @dhromed said:

    variable variable names ($$foo) as a great feature


    Great feature, until you exedently type a $ extra, and never made use of that feature. Not to mention it can be a great security risk ;)



    PHP has quite some quirks. But so does C++, or java for that mather.

    not having to muck around with HTML is a godsend and things only got better with ASP.Net 2.0
    PHP doesn't force you to muck around with HTML, just to many people do it that way. ASP.Net allows you some pretty ugly HTML mucking. And i've seen my share.

    Whatever you're going to use. Always remember that whatever way you thought up of doing something, 9/10 there is a more pretty (clearner) way that you haven't considered yet. (And 1/10 of those cases you deserve topic here) Ofcourse the numbers drop with experiance.


  • Well, I think I know more of PHP than of ASP.NET now. My first project I used ASP.NET.

    But had a crap design, the only thing that looked nice was the UI. But the code was terrible. When I started my second project, I did it in PHP and applied new stuff, thus more elegant design. Still, I want to get into ASP.NET some more, because it seems much better if you do it right, but web hosting of that is limited.

    Other projects I did in the meantime, were WindowsForms projects. To me, that is the most headache-less way of building Applications. HTML and JavaScript give me a headache! To do simple things, one needs to account for the limitations of browser.

    However, WindowsForms have little use on the internet. And Web Development is what people need, is it not?

    I might be veering off the main topic now, but will ASP.NET evolve into a WindowsForms kind of building applications? Things like XAML and stuff??

    Will internet technology not evolve into making HTML and JavaScript obsolete? HTML and JavaScript feels "Primitive" to me, it doesn't feel like it has any place in this century.

    I might be saying stupid things now, but does HTML and JavaScript really have a future? Amidst al the COM objects and Flash?

    Are there not better ways of designing web applications? Instead of HTML, JavaScript and scripting languages?



  • @Ice^^Heat said:

    However, WindowsForms have little use on the internet. And Web Development is what people need, is it not?

    I might be veering off the main topic now, but will ASP.NET evolve into a WindowsForms kind of building applications? Things like XAML and stuff??

    Will internet technology not evolve into making HTML and JavaScript obsolete? HTML and JavaScript feels "Primitive" to me, it doesn't feel like it has any place in this century.

    I might be saying stupid things now, but does HTML and JavaScript really have a future? Amidst al the COM objects and Flash?

    Are there not better ways of designing web applications? Instead of HTML, JavaScript and scripting languages?

    Is web development what people need?  That I'm not so sure of.  Web apps definitely has some advantages such as centralization and zero client deployments (unless your using applets/ActiveX).  IMO, people are trying to use web tech to do what it wasn't designed to do, so you get hack on top of hack to get things to "work".  A lot of people think that web apps are the future and that thick clients are going to go the way of the dinosaurs.  I just don't see that happening in the next 25 years.  Hell, financial institutions are still using mainframe apps developed in the 60s and 70s even after the supposed "death of mainframes".  The other aspect is access to data.  I just don't see CAD and 3D modeling applications being delivered over the web for security reasons.  I don't think the US Department of Defense would risk transfer of sensitive data over the internet no matter how heavily encrypted it is.  Thick clients offer the sense of control regardless of how true it is.  Thick clients and web apps both have a future - the trick is to know when to use them.

    As far as the future of web apps, I wish I knew.  I agree with you that things seem primitive.  As I noted above the problem is that web tech was designed to present data, not necessarily to process data and that is a huge difference.  If we had a better standard on how to display form inputs on the client, perhaps things would be different.  But even if the standard was developed today to make our lives easier, we'd still have to wait years until we could abandon the current way of doing things. 

    Anyways, those are my opinions.  I could be wrong. 



  • @Ice^^Heat said:

    I might be saying stupid things now, but does HTML and JavaScript really have a future? Amidst al the COM objects and Flash?

    Are there not better ways of designing web applications? Instead of HTML, JavaScript and scripting languages?

    Not so stupid, given that HTML began a a simple thing for describing linked documents, and now there's all this high-level programming stuff and application theory attached.

    But note that an ML, generally speaking, is a very powerful thing. It's a syntax for providing meaning. It's a plaintext data format. Openoffice uses XML for its document formats. Office 2007 switched [i]to[/i] XML for its own format. Despite all the binary stuff that programming adds to the webdev equasion, you still need a lighweight, standard data format in which to express your documents and information, and transmit them.

    That format is XHTML, and it is far better suited for the task than SWF or JAR.



  • But having a format to transmit and view information is something else than application functionality and intuitive UI design, right?

    Is a browsers not nothing more than a Document Viewer? Isn't that the definition? Was it ever meant for Web Applications??

    Then WHY are we building WebApplications, as the standards do not seem to be intended for that.

    I wonder what Web 3.0 will look like :)



  • @Daid said:

    PHP has quite some quirks. But so does C++, or java for that mather.

    Sorry mate, but php doesn't have "some quirks", PHP is a giant hairball of quirks.
    @Ice^^Heat said:

    HTML and JavaScript feels "Primitive" to me, it doesn't feel like it has any place in this century.

    Duh? Javascript is an extremely modern language, it sadly lacks a strong and standard library and the implementations are sometimes quirky (i'm looking at you, Microsoft), but the language itself is very good, clean and extremely capable. (lacks some other stuff like strong typing and modules/packages/namespaces, but these are the few critics I have for the language itself as it stands right now).

    And if you want to know Javascript's future, check JS1.6 and JS1.7 on devmoz, as well as the Javascript 2.0 proposals.



  • @Ice^^Heat said:

    Is a browser not nothing more than a Document Viewer? Isn't that the definition? Was it ever meant for Web Applications??

    Then WHY are we building WebApplications, as the standards do not seem to be intended for that.

    Correct.

    "The Web" in its current form has undergone gowth not unlike PHP. It's a chaotic almagam of poorly connectable languages, syntaxes, protocols and file formats. Only a monolith body of defined standards (i.e. the W3C + monopolists) stands between webdevelopers and total annihiliation inside The Black Consciousness of The Universe.



  • Then its time to think about something new right?? The revolution starts here!

    I better start reading cyberpunk!



    • I'm just fine with dynamic & "implicit" typing, but I hate weak typing, because it's unpredictable and often depends on pretty random coercion rules

    Use doubleval, intval etc. or C-style casts when you want to be explicit. If it doesn't matter, it doesn't matter!

    • "$". It has a meaning in Perl, it has a meaning in Ruby, but it doesn't have any meaning whatsoever in PHP. I don't doubt it's necessary due to the ad-hoc mostly retarded implementation of the language, but it still doesn't make sense
    $ allows string embedding (looks MUCH cleaner than ".$var1.", ".$var2.", especially when displaying a string with many variable parts, variable variables, and constant / variable separation.

    • No namespace (oh, and did you know that if PHP gets namespaces, the namespace separator may be \? Nope, i'm not kidding you, seems that "there isn't any other character left"...)
    • And since there's no namespace, every single function is in the global namespace of course, all 3000 of them.
    Class methods can have the same names as global functions. C++ also didn't have namespaces for some time, but people were somehow able to manage.
    • No naming standard, and not only there isn't any naming standards but you can take any 10 functions of the standard lib and you'll find half a dozen different naming schemes, "to" can be "to" or "2", words can be camelCased or underscore_separated, functions can use verbs as prefixes or as suffixes, even the order of the arguments varies from one function to another!
    Aside from a few "core" functions, the naming standard is to use underscore separated names, and prefix the function name with extension name. There are some discrepancies in OO libraries. Anyway, variable names are case sensitive, but function names aren't. So you can even use aLtErNaTiNgCaSe if you want.
    • Oh, by the way, ever wondered why there were 3000 functions? Because every possible variation in a function use actually creates a new function. You thought you could pass a parameter to a case-sensitive search function to make it case-insensitive? Nuh-uh, you have to use another function with the same name (prefixed -- or postfixed? depends) than the original one, and potentially swapped parameters too just to be sure you remembered to read the docs, cause it's too easy if the interface is the same. The language should, like, keep you on your toes or something.
    Use preg_match. I think you are complaining about the str* functions. They have a different order of parameters, because their interface was designed to be familiar to C programmers. The issue is not about making new functions indiscriminately, but rather not removing obsolete functions.
    • Every function is global period. No you can't nest functions, no you can't scope functions, if you define a function it's global whatever place you define it at.
    I agree with this. But you can use objects if you run out of names. PHP5 has a decent object support.
    • Functions aren't first-class objects or course, and the few "functional" constructs (array_filter, array_map, ...) are retarded. At best. Naturally, since functions are not first-class there ain't no anonymous function or closure or lexical scoping. Every function is global anyway so these points are moot.
    • And of course, PHP's support for recursion completely blows. Who'd want recursion anyway? If goto was good enough for my father iteration is good enough for me!
    What do you need anonymous functions and recursion for in a web programming language? Anyway, you can emulate anonymous functions with eval(). BTW, dynamically creating anonymous functions borders on self-modifying code, so I don't think it's a good technique to use liberally. It may be useful in some cases, but I'd say it's not the kind of feature you want in a web programming language.
    • I think I already mentioned scopes, which PHP of course doesn't have. Either a variable is global, or it's function-local. Period.
    I'm wondering if you invented this to be a problem, or really ran into a problem because of this? I wouldn't deliberately use variables with same names in different scopes, unless I really had a reason to it. Anyway, because of the weak typing, you can reuse your variables.
    • PHP arrays are bizzaro hybrids between arraylists (Ruby arrays, Python lists, Java arraylists, ...) and maps/hashes/hashmaps. And they suck.
    Somehow the concept that you can use anything as the key aligns netaly with the concept of weak typing, don't you think? If you could use only ints or only strings as keys, now that would be a WTF in conjunction with weak typing.
    • Until PHP5, PHP had no actual standard DB interface and no handling for auto-escaping. addslashes FTW... or was it mysql_escape_string? Ah no there's also mysql_real_escape_string, which is probably the real one, but wait i'm using Postgres so I should probably use pg_escape_string right? Unless i'm using bytefields of course in which case there's pg_escape_bytea... RHAAAA! Of course, even though PHP now has mysqli and PDO, they managed not only to make the OO interfaces to both suck and not to modify the PHP4 db apis to mention them. Checking the aforementioned mysql_real_escape_string? Don't worry, unless you go check the comments you won't find any mention of these. Go-go gadgeto quality for the win.
    Auto-escaping? Isn't this magic_quotes you bash in the next point? Anyway, this is relevant only to PHP versions 4 and earlier, which I agree are trash.
    • Braindead decisions e.g. magic_quotes and other register_globals. How can you make the core language unsafe by default? Is there anyone who actually sat down and thought about that shit?
    magic_quotes and register_globals allow beginners to create working scripts. For beginners, security isn't an issue, because they can't lose much. Nobody forces you to use them, and you can tun them off. Actually, I think that PHP is one of the few languages that scale well with your skills.
    • While the language doesn't aggressively force you to create good/clean code, it sure as hell doesn't help you create clean stuff.
    I'd say that the language doesn't force much in general on you, and since most beginners tend to write crap unless forced otherwise, the overall quality of existing PHP code is rather low. But clean coding is about discipline, and if you lack discipline, a strict language won't help you much.
    • The error reporting sucks, the error messages suck, there is no true `strict` mode, and the tools suck. Some people tell me it's possible to easily debug PHP, I can say that it may be possible but it sure as hell ain't obvious.
    Yes brother, everything sucks, and let's hang ourselves. Seriously, the only really bad thing I can say about PHP's error reporting is that if the source contains unmatched {, there is no error report and a white screen. Be more specific.
    • Most documentations, tutorials and others not only suggest but support seriously unsafe and/or retarded practices.
    Like?
    • And most of the community is kind, but utterly clueless.
    This may be pretty accurately said of any community. For each n experts, there are at least 2^n ignorants.
    • PHP's support of unicode is pathetic. Even worse than Ruby's, and that's telling as Ruby's unicode support currently utterly blows. Fairly annoying for a web-based language...
    You didn't notice mbstring extension, which overloads certain core functions and so works transparently. PHP6 will support Unicode internally.
    • PHP is slow. Why do you think people tell you to use a bytecode compiler/cache? Because PHP is a fucking dog. A limbless one.
    Compared to what? Don't compare it to Java, because they have different execution paradigms. Anyway, request processing time is usually insignificant compared to transfer time.
    • PHP's APIs are among the worst in the world. I strongly suggest not to create any C module to PHP. Ever.

    I have to argee with this, PHP's APIs are no match to Java's JNI, but I'd say that Win32 programming has more WTFs to it (like wsprintf not aware of double and lack of encoding conversion facility).

    I think people are hostile towards PHP because it is the first web-oriented language they learn, and they bail out for something they regard "more advanced" before learning how to use PHP well. Therefore, they judge it through their beginner's point of view.



  • @Tweenk said:

    I think people are hostile towards PHP because it is the first web-oriented language they learn, and they bail out for something they regard "more advanced" before learning how to use PHP well. Therefore, they judge it through their beginner's point of view.

    IMO this is not true. You need some experience with other languages to see the deficiencies of PHP.


Log in to reply
 

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