View Full Version : PHP vs Python and Ruby

05-17-2012, 11:55 AM
In recently time, I more and more listen, that Ruby or Python are bests languages that PHP.
I interested this is correctly? If yes, to tell least one example.
that is:
"Python (or Ruby) can "something", but php cann't this, so, php is worse!"
Please tell this "something". :)

05-17-2012, 01:34 PM
It is difficult to defi ne what readability and usability means to programming
language users. PHP follows a very classical approach, is extensively documented
and will probably be the most familiar to former C-programmers. Python with
its strict indentation enforcements and the small set of keywords will probably
be the best choice for programming beginners. Finally Ruby will probably be
attractive for Smalltalk-enthusiasts and experienced programmers, that look for
elegant and powerful programming expressiveness.
While Python seems to have the most readable syntax of the three languages
(because of the enforced program strucuture), Ruby seems to be the most usable
one (because of its principle of least surprise). Of course PHP is a readable
language too, because most programmers are familiar with C-based syntax.

Ruby is a language that has only one major web framework in the market: Ruby
on Rails. It makes use of CGI as gateway but also provides its own web server,
which is recommended for development and testing only. I will skip a hello world
example here and continue with listing 1.6, the check login function in Ruby.
Listing 1.6. Checking login data in a Ruby
r e q u i r e ' d i g e s t /md5 '
def che c k l o g in ( username , password )
hash = Dige s t : :MD5. hexdi g e s t ( "#fpasswordg" )
username = db . e s c a p e s t r i n g ( "#fusername g" )
r e s = db . query ( "
s e l e c t u s e r i d from us e r s
where username = ' " + username +" '
and password = ' " + password +" ' ; " )
row = r e s . f e t ch r ow
unless row . ni l ?
return row

Cloud Redundancy (http://www.cloudways.com/en/features/developers-playground/)