
Originally Posted by
o_O
Here's why PHP is awesome. This is a simple select box:...
PHP really is a horrible language. Horrible horrible horrible. register_globals, anyone? magic_quotes, anyone? PHP encourages mixing interface with application logic, which is entirely the wrong thing to do. PHP4's OO system is almost worse than Perl's, and that's saying something. PHP lacks any kind of consistency in the standard API function names and argument ordering and what have you. It's way too verbose a language for things that should be concise. (Who ever decided to have array() be the way to represent an array literal?) Its references sucks. Its function pointers / "callbacks" suck. It's scoping rules (or lack thereof) generally suck. Lack of namespaces sucks. Lack of exception handling sucks. Implicitly auto-casting strings to numerals and vice versa sucks. Confounding hash tables and plain arrays sucks. Lack of concise syntax for regular expressions sucks in a language specifically intended for what's essentially text processing and template manipulation. Etc. etc. PHP5 probably fixed a lot of this but I doubt I can stomach it long enough to find out.
PHP is a good language if 1) you need to learn it because you bought a vbulletin license or need to write a plugin for the PHP-based blog software you use, 2) Your program is 3 pages of code and has no chance to grow, 3) You have no access to your server to install anything better, 4) You don't know anything else and don't want to learn, 5) well, there is no 5, those are about the only reasons I can come up with. PHP is better than writing a hundred pages of HTML by hand, but only just barely. Sorry for the rant, but every time I'm forced to look at PHP code I want to hold my breath until I die.
Ruby on the other hand...
Code:
#!/usr/bin/ruby
require 'date'
puts '<select>'
(Date.parse('January 1st, 2007') .. Date.parse('December 31st, 2007')).each do |d|
puts '<option>' + d.strftime('%B %d') + '</option>'
end
puts '</select>'
(I wouldn't touch ASP with a 10-foot pole if you paid me.)