![]() |
10 PHP Myths Dispelled
I found this on Alan's blog, to which he then linked through to the original post. So I thought I would bring it over here for anybody who wants to contribute their thoughts. I posted a comment on the original post, and so I've brought it over to TalkPHP as well because it's my take on the article.
The 10 myths which he decided to tackle are as follows:
My comment: Quote:
|
Well, I'd have something to say...
1. PHP 5 is very close to it (although I don't know much about C++/Java way of "object oriented", but I suppose there's not a big difference from what I've seen). 2. every programming language "encourages sloppy code". That depends and differs from one programmer to another. 4. I would say a 10.000 line PHP application runs much more faster (that is parsed, compiled and ran) than an equally long C++ application is compiled (only compiled, not ran). 5. Perhaps Eclipse and Zend are just common text editors, then, and XDebug is their child. 6. not always true. an object-oriented php application doesn't look at all like a procedural php application. 7. perhaps or perhaps not. PHP, although, does require a lot of concentration and will to learn and then work with it, because of the multitude of the additional languages it can work with (like SQL, HTML, JavaScript and such). 8. that I agree with. But then again, that's what it was created for. 9. check (2) 10. no, it is not, if you think a bit (just a bit) before writing an application. Probably the one who wrote this article has something against PHP or hasn't worked with it, otherwise I can't explain why COMMON programming issues are presented here. |
I have to agree with Xenon here, he's said pretty much everything that I would have. The guy who originally posted that list probably just doesn't like PHP. Don't get me wrong, some of his points do hold weight, but most of them seem to be based on his personal opinion rather than any real facts.
|
I must agree with Xenon and Karl, the arguments are mostly ones that have come before with many languages. And I have a few of my own comments, sorry for the verbosity.
3. PHP doesn’t follow MVC To answer this could be long, but I'll be short. For PHP MVC is a choice, not a requirement. Unlike some other languages where things can be unnecessarily complex in a mere error page. The MVC model, Model <-> View <-> Controller, is little more than a concept that has been object oriented. The base concept is abstraction between the data, specifically large amounts of data, and the view. Procedural PHP either follows, or doesn't follow, the MVC concept. It either has code/functions that control the varying data followed by the view creation code/functions, or it has the view creation strewn throughout the data aggregation. Event incorporated view handling with the data has separation, as this, by and large, comes from a database or the filesystem. Object Oriented PHP follows the two options above in manner but is far more encapsulated. The objects would contain all the code for the data, view, and controller--and many libraries already provide this exact MVC framework. Even when the view and data are handled procedurally, bit by bit for page generation, the processes are still separate. Arguably, I would say PHP is one of the few languages that is natively MVC compliant--even if only in concept, rather than strict definition. But in the end, the strictness of the MVC relationship is up to the programmer. 4. PHP is slow because it’s interpreted Absolutely correct. But we're also talking in relative terms. Interpreted languages are slower by definition because they aren't compiled and must be interpreted. That said, I see a great many bloated walruses in many languages, especially C++ (compiled) and Java (interpreted). However, Zend makes a better toaster. It CAN be bytecode compiled from what I understand. And its efficiency competes directly with LUA. Another argument that makes this point null-and-void is abstraction. If I give a C/C++ application and input it doesn't expect it will crash immediately--it was an error. If it doesn't crash this input was expected, and prepared against. Lets pretend you have a hard-coded CGI binary. You just lost your whole interface that touches that input. With the abstraction of PHP I can change one, maybe two, lines per function or object and make it handle any problems like this gracefully. This makes recovery less of an arcane art, and more of an impressive feature. So, bytecode-uberspeed or interpreted-stability? I like the latter. 8-) 5. PHP doesn’t have a good IDE or Debugger News to me. phpDesigner 2008 is a good place to start; it is a PHP IDE. It even pops up as I pause in typing to tell me when and where I've got an error, without clicking debug or starting Apache. As a hobby I use Visual Studio 2008 (with Chrome, an Object Pascal extension language) and even those errors need arcane interpretation--PHP errors are pretty obvious, even when arcane sounding. 7. PHP isn’t really for “serious” developers It's a good thing I'm not serious then. I make plenty of jokes. Or, is that why my .NET-ASP loving uncle is so angry any time I bring up why I disagree with him? I'm glad "it's not for serious developers"... it'd give me ulcers otherwise. I've SEEN those serious folks, and they need to lighten up. Seriously. *!* (Anything C can do, PHP can do better!) 8. PHP is only good for web applications A language being good at its purpose is a bad thing? Correct me if I'm wrong, but not even Java is good at its purpose, whatever that may be. Java programmers are the first to admit to Java's many problems. But, PHP being good at what it is supposed to do is bad.... I think someone needs to see the psychiatrist. 2. PHP Encourages Sloppy Code / 9. PHP code is a mess of “include” and “require” statements that break easily / 10. PHP Code is rife with in-line SQL statements Sure, if you write it that way. But even sloppy PHP can be understood, and isn't nearly so mind-warping as the C-Macro paradigms. And, believe it or not, even this sloppy, "bad", PHP is typically fast, efficient, and understandable! |
Quote:
Quote:
|
Actually, you can use PHP for standalone desktop applications. It only really works well for console apps and it's pretty hacky, but I've done it.
And yeah whoever wrote that article just hates PHP. |
1. PHP is not a truly Object-Oriented Language
Is any language a true OOP language - sure, in some languages, everything is an object. But is that Object Oriented Programming? PHP has become a matured language, and has a full range of OO, including reflection. 2. PHP Encourages Sloppy Code PHP encourages flexibility. If you're sloppy dev, you'll write sloppy code no matter what language. I've seen it, in Java, C, Python. It comes down to the developer. 3. PHP doesn’t follow MVC Of course not, PHP isn't a framework. I'm assuming the author of this question is a RoR follower. Frameworks follow MVC, if you count Ruby on Rails as a programming language, you are sadly misinformed. RoR is a Ruby framework. PHP has countless MVC frameworks. You _CAN_ do true MVC in PHP. Is it suggested? Not really, MVC frameworks are generally slow and have problems scaling. This is an issue inherited by the pattern, not the language. 4. PHP is slow because it’s interpreted Incorrect, PHP can often out perform in execution of like logic in other comparable languages. 5. PHP doesn’t have a good IDE or Debugger Misinformed. Try some good IDE's, like Zend. and as it's been said, xdebug.org - one of the best debuggers out there in the industry. PHP also has quiet a few native debugging tools, including performance functions built into the language. 6. PHP apps all look the same ... uh.. what? That's like saying all cars look the same because they all have 4 tires and at least 2 doors. 7. PHP isn’t really for “serious” developers That would be an insult the the developers I work with, that come from companies like: EA, Google, Yahoo, Lucas Arts 8. PHP is only good for web applications PHP excels at web applications, but can just as easily be used for CLI, and extended to the desktop with GTK+. I've written kiosk software entirely with WAMP stacks simply because it was affordable, scaled, and straight out worked. 9. PHP code is a mess of “include” and “require” statements that break easily If you mean they break because as a developer you're not aware of what 'include' and 'require' are intended to do, then sure, yeah. It's the same process a dev has to go through to get their compile include paths set up in any C/Java project. 10. PHP Code is rife with in-line SQL statements Only if you want it to be. |
Quote:
On this topic... I have this funny feeling that PHP is in this state where people are trying to wrap their heads around the idea that PHP can scale to handle more than 1k hits per day. A LAMP stack, complimented by Memcache, with proper hardware scaling (which any language would need) can handle millions of unique daily users. |
1. PHP is not a truly Object-Oriented Language
2. PHP Encourages Sloppy Code 4. PHP is slow because it’s interpreted 6. PHP apps all look the same 7. PHP isn’t really for “serious” developers 8. PHP is only good for web applications 9. PHP code is a mess of “include” and “require” statements that break easily 10. PHP Code is rife with in-line SQL statements 1. No its not an OO language. Buts thats why I like it. Its easy to use objects, but I don't always have to. 2. So true, have you read other peoples code? complete shit. People are taught the wrong way to program php and thus there are a ton of crap tutorials and projects all over the place. 4. Ye but its negligible for most all projects. 5. Sometimes the truth hurts. 6. Eh?! 7. What do they use then? Ruby.. lol right... 8. What? Simple sites.. really does it matter what language? 9. In some projects yes. But in others no. 10. Mainly up to the developer. I could write an ASP.NET site, Coldfusion or whatever language with as many inline sql statements, and it would be common place. |
Quote:
|
| All times are GMT. The time now is 05:14 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0