May
Ok so whenever I ask about languages, I always get the most convoluted answers ever. I have been doing PHP programming for about a year, but on and off and nothing serious. I read an article about why PHP sucks, and it really hit home, especially one of the statements.
“A lot of open source projects are written in it, such as Joomla, Wordpress, and MediaWiki. All of their code is ugly, and half of the time there’s random HTML in the middle of their scripts because, of course, we’re working with webpages and why would you ever want to abstract the output from the logic?”
The sarcasm and utter truth from this comment make me laugh. I have been reading some of the ideal books from some of the ideal programmers, and the code is always going in and out of PHP, HTML inside and out in a confusiong manner.
I basically want to know your view of PHP (and if not a high one, an alternate language and why) but no one ever gives any specifics so I thought I would bring up a good point .
Answer:
Well, you asked for it…
The fact that there's a lot of crappy PHP code around can be explained simply by the language popularity. Compared to the alternatives, the language and the execution environment are very accessible and it's extremely easy to start programming with PHP.
There are a lot of entry-level and amateur programmers doing it out there, and there are also lots of non-programmers doing it. This leads to significant amount of convoluted, atrocious and non-maintainable PHP code.
There’s also a great deal of high-quality PHP code. Drupal is specific example.
Similar phenomemon happened with Visual Basic, before they went into .Net business, which effectively scared away many not-so-sophisticated programmers.
Why PHP is so popular as web language, is another question. I think it was the result of natural selection. If you look at the competition, ASP is pretty easy too, but it's proprietary and largely unportable technology. Perl is powerful, but has much higher learning curve - you need to be serious geek to speak Perl fluently. Java-based web platforms are also powerful, but are quite complicated for average programmer.
PHP was designed for HTML generation, unlike other general-purpose languages. And it doesn't suck at it and is very convenient.
Generation of web pages with full abstraction of HTML presentation from the logic exists only in the best world. In the real world applications, there will be HTML sprinkled here and there in the code. It isn’t necessarily a bad thing. Some applications do it superior, some worse, but that's not the fault of the technology in case of PHP. And PHP handles mixing of HTML with the code gracefully, in my opinion, or at least not worse then other languages.
The language itself and execution platform are very powerful and perform quite well in many tasks. I personally like PHP and used it in many projects. It's not suited for 100% of web applications of course, but honestly, PHP's portability and ease of use can't be beaten.
I’ve my share of grievances, though. References in PHP are just not right - it's nearly impossible to figure them out. Name scoping is another thing that’s difficult, though they addressed that in current versions. Nothing major besides that. Those don't outweight the pros, though, and overall I am happy with PHP.
Hope this helps.
Answer:
What's your problem?
If you don't like PHP then don't use it. I'm pretty sure nobody gives a damn. Calling people names because they like something you don't is juvenile.
Or were you just having problems with PHP and the first comment really hit home about the type of programmer you think you’re.
Answer:
PHP itself is a great coding language. Some people just do a really craptastic job of implimenting it. That's not the fault of the language… it's the fault of the programmer.
Answer:
There are TWO (and only two) web-server systems:
LAMP (Linux, Apache, Mysql, Php) or WAMP (Windows…).
Any Window based system is under Microsoft control and, as such, is commercial before efficiency (and payable).
Php runs on Lamp. It is open source, but “controlled” by www.php.net group. And pretty well! Report a bug, and within a few days, the bug WILL be corrected. Try that with MS!
PhP is designed by CODERS, FOR coders. They do not have any financial interest but self satisfaction. Is that the case for MS? Surely not!
PhP is more or less based on C, so a good base of C will get you straight in.
ASP, JSP, .NET and so on are MS products…
I rest my case!
Go for LAMP servers.
Now…
You speak about Joomla and others…
STAY AWAY FROM THESE!
These are applications or “modules” you can include into your code.
Unfortunately, they’re designed for a very wide audience and contain HUGE amount of code you don’t need!
Adapting them to YOUR needs will take you longer than designing your own code!
(Example: I needed to build a bar graph. I got several “off-the-shelf” code. I spent 3 days trying to adapt it to MY requirements. Failed. Started from scrach and used Php functions. 3 hours were enough… This comment is valid for ANY “off-the-shelf” download!)
PhP? thumbs up, 100%!