Debates about which programming language is the best are always hard and heated. Likewise, there’s no ideal language that works for all web application project requirements. Wikipedia is written in PHP. Gmail is written in Java. Python is number one choice of Google and YouTube. Ruby is used to create Twitter and Hulu. Slashdot is written in Perl. Stackoverflow is written in C#.
Browsing for the best web programming languages, among dynamic ones, you’ll mostly see PHP, Python and Ruby listed. Back in the days several years ago PHP was admitted the best tool for web job but since then both Python and Ruby have matured and grown robust libraries and frameworks around them that make them better candidates for many web projects now.
Today many consider PHP to be great for average everyday web systems. Python and Ruby are thought to be more suitable than PHP for most web applications in general and for more advanced things in particular. Just like PHP, they are free, open source, run on an open source stack (Apache and Nginx / linux, windows and BSD), and play well with any database engine. However, Ruby and Python have better syntax and they both enforce good programming habits by their nature, especially Python. PHP encourages sloppy spaghetti code by its nature. Also, the object oriented features in PHP are very ugly because of its arcane, retarded syntax.
Let’s get deeper insights into these two web programming languages from various standpoints:
As mentioned before, Python and Ruby are two of the most popular dynamic programming languages used in high level application development. In fact, Ruby was built using some of the design elements from Python. Developers often prototype using these two languages before implementing on compiled languages because of their modularity and object oriented features. Many use Python or Ruby instead of Perl as simple scripting languages. Python and Ruby are popular among web developers as well because of their rapid development cycle, with Python boasting computation efficiencies and Ruby boasting code design.
a/ Philosophy
Python really believes that code readability is the most important thing. Hence, there is one-true way of writing code, or as it has been reformulated lately: “There’s a most understandable way to do something and that is how it should be done”. Python is designed to strongly emphasize programmer productivity and it likes things to be structured, consistent, and simple. Python syntax enforces strict indentation rules; in fact, indentation has semantic meaning in Python.
Ruby believes in giving programmer the flexibility, freedom and power. It was designed, first and foremost, to make programming fun for its creator, with guiding concepts as follow: “The Principle of Least Surprise” and “There’s more than one way to do the same thing”. The latter philosophy principle inherited from Perl is the reason why many Ruby methods have alternate names, which may lead to some API confusion among new practitioners. However, this flexibility enables Ruby to be used as a meta language for describing DSL. Also Ruby provides a better way to write concise and compact code. More into the expressiveness of the code and writing code that is clever.
Python people like libraries to be transparent and obvious how they work and hence is easier to learn, while Ruby people tend to provide clean and pretty interfaces with “magic” behind the scenes. This makes development very fast when you understand the magic, but frustrating when you don’t.
b/ Ease of Use
Python is known for its ease of use. It allows beginners to start building powerful sites more quickly, and has the power to grow in complexity keeping its ease of comprehension. For example, one of the hardest parts of coding is going back to what you coded long ago and trying to remember the logic of it. Because Python uses natural language with white spaces and indenting, it is much more clear and easier to read than languages like Ruby. That makes it easier to fix mistakes or do updates. Also, there are literally thousands of pre-built modules that can be snapped on to let you get up and running on the web immediately. Its intuitive introduction to object-oriented coding concepts, such as communities, modules, and libraries, allows you to move on to other related programming languages as they develop.
c/ Object Oriented Programming
Both Python and Ruby support object oriented programming. Still Ruby’s object orientation is considered to be more ‘pure’ in that all functions exist inside a class of some sort. Python’s object orientation is more akin to that of C++, which allows functions and statements that exist outside of classes. In Ruby, even global variables are actually embedded within the ObjectSpace object. Python doesn’t have global variables, instead using attributes of module objects. In Python and Ruby, an instance of literally any type is an object. However, where in Ruby all functions and most operators are in fact methods of an object, in Python functions are first-class objects themselves.
d/ Syntax
Ruby includes several syntactic features which make dynamic extension of and higher-order interaction with external (library) code more straightforward. In particular these are blocks and mix-ins. Most things implementable with block and mix-in syntax are also achievable in Python, they are simply less syntactically natural and clear, and so less commonly form the centerpiece of major libraries or common styles of programming. These features, combined with a lighter-weight syntax with fewer restrictions (whitespace flexibility, optional parentheses, etc), make Ruby more suitable to pervasive and relatively transparent use of metaprogramming.
At the same time, while this flexibility and the Ruby community’s tendency to use it for metaprogramming can facilitate aesthetically pleasing code, they can also create stylistic variation in how the language is used, and obscure the mechanisms by which code actually works. Python’s more restrictive syntax is intentionally designed to steer developers towards one canonical “pythonic” style to improve accessibility and comprehension.
e/ Style
Ruby code is organized into blocks, with blocks starting with various constructs and ending with the keyword “end”. Python code is indentation-sensitive, with successively larger indentation meaning tighter (nested) scopes. Python’s syntax has been described as executable pseudocode.
f/ Functional Programming
Both languages support some functional programming constructs, but Ruby is arguably better suited to a functional programming style. Lambdas in Python are generally very short, because lambdas in Python are restricted to expressions and cannot contain statements. Ruby’s lambda support is far more flexible, allowing for lambda expressions of arbitrary length.
g/ Speed
The standard CPython implementation is generally regarded as executing code slightly faster than Ruby.If speed is really an issue for a Python project, you also have the option to use Cython, Pyrex,Pypy (JIT) or the ShedSkin tools to compile your code into C or C++.
j/ Features
Both Python and Ruby are high level application development languages. Each of them is estimated to have a Capers Jones language level of at least 15. Both languages promote test driven development.
Both languages have full Unicode support, although the way that support is implemented varies. Python distinguishes between “Unicode strings” and “byte-strings”. Ruby, on the other hand, treats all strings as byte-strings with a semi-hidden flag which causes problems when dealing with badly-encoded data from third-party sources.
Both Python and Ruby support multithreading. Python has the Global Interpreter Lock (GIL), which negates much of the potential advantage of using threads; Ruby has a comparable Global VM Lock (GVL).
There are a number of functions that are available by default in Ruby but for which in Python it is necessary to import a module from the standard library. Python supports generators and generator expressions.
k/ Community
There are great communities behind both frameworks. Some people believe that Python has a more developed community in terms of libraries suited for data analysis, machine learning, natural language processing, scientific libraries. As for community folks, Python ones are believed to be conservative and afraid of change, while Ruby guys welcome changes and love new shiny stuff even if it breaks older things. Consequently, Python world is more stable, and you can update your installation without much troubles, but that also means new technology is only added very slowly.
l/ Frameworks
There are a number of Web frameworks based on both Ruby and Python. The most notable and leading are Ruby on Rails (Ruby) and Django (Python) based on MVC. Django is more declarative, with it you’ll have a clearer understanding of what’s actually going on. It lets you specify most configuration details yourself. Django creates a much simpler project structure. On the other hand, the centerpiece of Rails’s philosophy is called convention over configuration. Rails provides you with more defaults.
m/ Popularity
Python is generally more widely used than Ruby, according to most measures, but in the wake of the rising popularity of the Ruby on Rails Web application development framework Ruby’s popularity too has seen rapid growth.
Python is more mature general purpose nature vs Ruby’s more niche (Rails) usage. Python is stronger and sees use in automating system administration and software development, web application development, data manipulation, analyzing scientific data (with help of numpy, scipy, and matplotlib modules), biostatistics, and teaching introductory computer science and programming. Ruby+Rails holds a slight edge over Python+Django for web development and sees use in general programming, and has more mindshare.
In terms of cloud deployment, Python can run on Google-Cloud (Google-App engine). Though Ruby has very strong cloud deployment options in the shape of Heroku and Engine Yard.
Would you prefer Python or Ruby over PHP for implementation of your web project? And is it indeed a philosophy that you chose while selecting between Python and Ruby? Interested to hear your thoughts.

Helen Boyarchuk
Business Development Manager
No, not really. We seem to be able to accomplish most everything we need to do with .php
Nice article. I know python and I love it, but I thought I couldn’t survive with python alone in web development so I needed PHP. But this article has really enlightened me.
Thanks for commenting, Michael and Osborn!
@ all blog readers,
What types of projects may leverage Python or Ruby advantages from your point of view?
In my opinion, this comparison is not done properly and it can be very misleading. Here’s why…
The story goes like this…
PHP was the first popular web programming language and it actually “broke the ice” (Perl was used before it, but it didn’t become so popular).
At some point there was Ruby (started even before PHP), but it was not widely used.
The at some later point Ruby On Rails came out and it “revolutionised” web development. But this is a framework and not a programming language (I don’t know any web developer today that’s coding in plain Ruby).
So a bunch of developers went into the RoR business.
After some time a lot of PHP Frameworks emerged, but beacuse of RoR’s popularity not many people noticed it (like for some time nobody wanted to buy Android because they wanted iPhone).
Now we have some serious and mature frameworks for PHP, like for example Symfony or CakePHP, which are being embraced more and more. They are the real thing to compare against RoR.
A sidenote… Due to it’s history, for some time PHP had a bad implementation of object oriented programming (it was not designed form the start to be object-oriented). But they cleaned it up and now it’s much better. There’s still work to be done on that field, but it’s improving constantly.
And there’s also an important fact to consider… There’s no decent CMS in Ruby (I know, I have searched for it). So if you go with ruby you might get stuck at some point when you need a proper CMS.
In PHP there are many very advanced CMS systems, many of them even on Enterprise level.
As for Python, I don’t know it’s history, but I heard that Django is it’s most popular framework, and many Python developers just love it.
So, to sum it up, comparing PHP to Python and Ruby without mentioning PHP frameworks is not a good comparison at all…
In my opinion, a proper comparison could be done only by someone that used all this languages and their frameworks or is in direct contact with developers that used them all.
What you did here, you just took some excerpts from other articles and answers you got on internet without doing your own research, and combined all this together. And you made a mistake from the start, by asking the wrong question.
It’s OK if you wanted to start a discussion about it, but then you shouldn’t present it in a form of a research without actually doing a proper research.
Written like this, it might mislead people that wan’t to get a good insight into the topic.
You must be a php fanboy, you sound like one. The writer is not trying to bash your precious language, so quit being a killjoy. The article is okay, and informative. I liked it.
Mandarin, have you ever compared an apple to a mandarin?
“(I don’t know any web developer today that’s coding in plain Ruby)”
That’s because you can’t code in plain ruby, ruby does NOT work like PHP. You can’t just plop it on a web server and expect it to work. You need a few libraries here and there, and sometimes you need a framework (okay, most times). PHP itself is a framework with a custom language.
“There’s no decent CMS in Ruby”
This again goes with “you can’t just plop [ruby] on a web server and expect it to work”. Since you need to install all these libraries, it gets pretty hard to install a ruby CMS. You still need to install multiple things even if you user the bundler library. PHP CMS are more popular because of how easy it is to get running. All you do is plop in the files, and it works, unlike ruby which is run from the command line, and most shared hosting doesn’t support. And a CMS doesn’t have to be publicly available to be decent. Mashable is run on a ruby on rails stack now.
I am in no means saying “Ruby is waaaaay better than PHP and Python. PHP sucks!”. No, not at all. I’m just trying to clear up some confusion you (and other people reading this comment) may have. I honestly think each one has their own uses.
I wanted to write an answer to this one, but then I realized that every comment I write here just leads to more and more misinformation written by other people.
So I decided not to do it and go compose a symfony instead…
I totally agree with your statement. This seems to be yet another bash PHP article. @Helen – Tell us how you really feel about PHP! 😉
This line pretty much discounts any possibility of objectiveness on the subject: “PHP encourages sloppy spaghetti code by its nature. Also, the object oriented features in PHP are very ugly because of its arcane, retarded syntax.”
Sounds like a statement from someone still using .php3 extension. No, procedural programming encourages spaghetti code.
The big benefit PHP has OVER Ruby, Python, Java, .Net is that is has multiple frameworks to choose from using varing development / architecture patterns. Want MVC, fine, want decoupled frameworks? No problem. Build from scratch? You got it.
PHP Frameworks [a short list]
Zend / Zend2
Symfony / Symfony2
CakePHP
Phalcon
CodeIgniter
Yii
Ruby Frameworks
Rails
Python Frameworks
Django
Java Frameworks
J2EE
C#
.Net
Every other language out there has so limited framework options. You either build with the one framework, of you’re out of luck. Maybe the real problem with PHP is it’s lack of framework standarization, but what some may see as a problem, I see as flexibility. After all, if all you have is a hammer, every problem will be a nail.
Thanks for a good comment about PHP frameworks. Well-said and to the point! And I didn’t mean to bash PHP at all.
Just one correction… Actually Ruby and Python also have more than one framework. For example:
http://wiki.python.org/moin/WebFrameworks
http://vemod.net/list-of-ruby-web-frameworks
but they are not so popular, widely used and actively developed as many PHP frameworks.
For example, I know a lot of Python and Ruby developers that know only about Django or Rails, and they also think that this is the only existing framework for the language they use.
I agree. Here is my analysis. If I want a simple website with a little logic, I will use PHP just as a language itself
If I want a proper CMS or an e-commerce site, then again I will use very mature and great PHP frameworks. Rails CMS are very few and not at all matured.
If I want a very custom application, which needs a big database system, to be developed custom, and extensive logic that needs to written custom, by hand (by this, I mean something not where we can just tweak a CMS), with login and some common functionalities like user authentication, file upload etc., I think I will use Rails. I am aware there are frameworks like Symphony, CakePHP in PHP, but Ruby as a language and Rails as a framework is very good for this kind of functionality.
And I am not familiar with Python and Django, so cannot comment about that.
Mavko, thanks for your comprehensive comment. Was interesting to hear your points. My aim was initially to raise a discussion providing some basis for it in this article and see various opinions about Python, Ruby and PHP.
Blog your great good information
Good article !!
My 2 pence is —-> use Ruby.
Python OOP not upto mark and the language has GIL issues. PHP and perl are good but people get confused with $,@,% symbols. Ruby at the momment is slow but it would get fast very soon. Also, my new love celluloid does handle concurrency well. Ruby has rubinius to bypass GIL issue.
Further, RoR is a capable framework like Django (python) and
codeigniter+Data mapper (php). Zend may be the best web framework out there but like Zope is not for humans. (suits highly skilled coders)
Hello,
I am in RoR and PHP, and like PHP because came from “C” world, and that was problem for me to start with RoR. Also I hate RoR naming convention/plural/singular, “writing all in english” (it’s not my natural language). But only what I like in RoR is that I can create same things as in PHP, but with less lines of code.
I am playing with Ruby on Rails like with new Iphone (fancy), but still doing all complex things in PHP. My PHP code is 100% MVC, clean and readable. About PHP frameworks, check Laravel.
regards
Hi Alexandar,
thanks for your comment. As for Ruby, you are not the first stating it’s not easy to start with RoR.
According to me, PHP is still the best for web application development. Reason is not just of having luxury of PHP frameworks, it is simplicity too. And PHP itself is a good framework. I worked on ROR and Python too little bit. Although i liked ROR MVC style and less coding, i still believe ROR needs to go long way particularly the way it handles DB. Sometime back they didn’t even have support for enum fields which are all small things, but should be there. Python is interesting now a days. It got improved lot.
I like ruby on rails because it is most productive way to build our website and I have learned many new things in your post which are so useful for me.
Very fantastic and well-written post.Its extremely good and very helpful for me.Thanks for sharing.
Web Development
Thanks, Mariana! Good it was helpful to you. The article was written a couple of years ago, still quite up to date, and start-ups use Python and Ruby so actively, though new instruments have arrived for consideration.