Ruby vs Python vs PHP, What Do You Think?

Posted on November 16, 2012
They have used this infographics again in this posting I guess. Because this was initially uploaded on 6th January 2012 (and possibly created even before that.) Here are couple of reasons to support my claim.
  • Upload path suggests that it was uploaded in January 2012 "wp-content/uploads/2012/01/", this is how WordPress stores uploaded files by default.
  • In the response header of this image you may find, "last-modified:Fri, 06 Jan 2012 19:25:29 GMT", this is why I said it was created on or before 6th January 2012.
  • I have seen this infographics several months ago on Google+
 
Python and Ruby implement very similar models, and have similarly powerful libraries and communities. The biggest distinction is in syntax. That said, Ruby does have several syntactic features which make dynamic extension of high-order interaction with external code (e.g., libraries) more straightforward, such as:

Blocks. They allow arbitrary, multi-line closures to be cleanly passed in-line anywhere. Python has two syntaxes for in-line closures: lambdas and nested def statements. Lambdas are equivalent to Ruby blocks, but they can only easily express a single expression, not multiple nested statements, leaving nested def statements -- which are statements, not expressions, and cannot be used in-line.

Mix-ins. They allow imported classes and modules to be extended and overridden by user code after it is imported. Python's runtime model is dynamic enough to inject new or altered methods and fields into an external class or object, but the syntax is procedural rather than declarative and identical to the standard class definition syntax.

Despite that, most everything that can be implemented in blocks and mix-ins, is also achievable with Python. It just isn't as syntactically natural, and thus not commonly used in major libraries. So, Ruby does allow for more transparent use of metaprogramming, but that's a double-edge sword.

Personally, I prefer Python. It's my language of choice for most projects.

Guido recognized the fact that you'll spend a lot more time reading code than writing it, and focuses on guiding developers to write readable code. Yes, that's opinionated, but I don't see that as a negative. There's one way to do something in Python, if you want to write Pythonic code.

Not a huge fan of Ruby's syntax, it's looks like half-baked Perl at times. Do I have to use parentheses here, or wait, do I only have to use them when doing X? It also doesn't help there's several expressions that are all equivalent. In other words, there's more than one way to achieve the same result. Again, half-baked Perl. This is what people mean when they say Ruby is expressive, but Python is far more readable. Being clever doesn't exactly make for easily readable and maintainable code.

Which brings me to monkey patching (that double-edge sword). It used to be heavily encouraged within the Ruby community, though not so much anymore; however, I still run across it often enough to make me cringe. It makes upgrading libraries, and maintaining other people's code, in general, a nightmare. There's so much magic going on at times, that it's sometimes not trivial to understand where and how your code is actually running.

A few other reasons I'm not a big Ruby fan: no tail call optimization -- you'll exceed stack depth far faster than in Python (which is impressive, but not in a good way); can't right associate operators (well, there's the coerce method, but then all your operators are commutative); mutable strings.

Also, as others have pointed out, that infographic isn't entirely accurate as well. For example, Ruby doesn't adhere to the principle of least astonishment, as evidenced by its object model.
 
Btw, thousands of sites running on Windows Server doesn't match millions of sites running on Linux/*BSD. Enjoy your evening.
How many of these millions of websites are hosting large infrastructures?

At work, we use Windows servers for our web facing servers, only using Linux for SQL, as well as a Windows machine for a SQL server. Our autodialling system is using the SQL server.

We considered moving the whole infrastructure to Linux, well that was before I joined. The proposal was dropped in favour of Windows as the server platform.
 
Personally I'm a PHP guy. I tried .NET years ago but the whole Windows development platform is a cluster**** of mess. I am looking at learning Python though. I was stuck deciding between Python or Ruby, however the future prospects for Python just felt more....stable. The community seems a lot less narrowminded as well. Almost every 'Ruby vs Python' post from a Ruby developer turned into a 'Ruby is the best, everything else sucks' post, without providing any real information on WHY it was best.

At the end of the day, its going to be down to personal choice when it comes to web programming. The only time you loose that choice is when you are either restricted to a certain OS, or have to make non-web based applications.

PHP is still a great choice for most people. I must admit the reason I started looking at Python was due to PHP becoming so messy and stagnated. But with PHP 5.4, it's kind of turned a new leaf, and PHP seems to be on the verge of a massive rise in popularity, especially with the likes of Laravel and Composer - together they are simply amazing.
 
Look at the release dates on it - they are very old and incorrect ;)
They have used this infographics again in this posting I guess. Because this was initially uploaded on 6th January 2012 (and possibly created even before that.) Here are couple of reasons to support my claim.
  • Upload path suggests that it was uploaded in January 2012 "wp-content/uploads/2012/01/", this is how WordPress stores uploaded files by default.
  • In the response header of this image you may find, "last-modified:Fri, 06 Jan 2012 19:25:29 GMT", this is why I said it was created on or before 6th January 2012.
  • I have seen this infographics several months ago on Google+

I will like to know if programing languages change rapidly and can vary from one year to the other. This make the decision to choice one language even more complicated.
 
I will like to know if programing languages change rapidly and can vary from one year to the other. This make the decision to choice one language even more complicated.
Programming languages don't change that often but the ecosystem does change rapidly which includes libraries, best practices, tools, trends, jobs, community and whatnot. A programming language in itself is just one chapter of the whole story. Take an example, PHP and Ruby were born almost same time but PHP took off and gained so much popularity in web development that it is virtually available on every host. On the other hand Ruby only took off after Ruby on Rails was born when Ruby had already passed a decade of loneliness.

Having said that, in the above infographics there are some subjective comparisons that are very hard to transform on a numerical scale. Specially, when people have different opinion. It is actually very hard to be unbiased on subjective matters. Creator of such stuff are no exceptions.

Also, some statistical measures change rapidly, no matter language changes or remains the same. For example, if you compare number of jobs in the industry across languages, you will find a noticeable change every other month.
 
I will like to know if programing languages change rapidly and can vary from one year to the other. This make the decision to choice one language even more complicated.
Generally they seem to be very consistant for a long period, then will do a sudden change and become consistent with said changes. PHP being a prime example. In 5.5 they are dropping support for legacy mysql stuff, rendering the likes ov vB3.8 useless until IB fix it. Things like phpBB, Yabb, SMF etc will all be affected by it due to their ancient code base not allowing for a quick fix. As the language matured, people put in preventative measures for stuff like that, so down the line it wouldnt be as big an issue.

For PHP, 5.4 was a massive leap forward, as will 5.5 be. Normally releases add stuff, but the language is going through a transitional period right now to bring it up to scratch. That'll keep it ticking over for another 10-15 years before it needs doing again.
 
Sorta. Node.js seemed to have come out of nowhere, now everyone's using it.

Not really surprising, Javascript is something that pretty much every web developer knows, and node offers insane performance up until the point where its single threaded architecture tops out, which is beyond average uses.

Probably wouldn't write an entire site on node (it can be more long-winded than even php in my experience), but it's excellent in a supporting role such as providing chat or multiplayer
 
Not really surprising, Javascript is something that pretty much every web developer knows, and node offers insane performance up until the point where its single threaded architecture tops out, which is beyond average uses.

Probably wouldn't write an entire site on node (it can be more long-winded than even php in my experience), but it's excellent in a supporting role such as providing chat or multiplayer

As if JavaScript wasn't painful enough in the browser, it boggles my mind why people would want to use it on the server. The language has its good parts, but it also has a lot of warts and several pitfalls.

Then you have Node.js, a platform I wouldn't classify as "excellent". The reactor model is one of the worst ways of doing concurrency. It's only advantage is that it's fairly easy to get going -- it's definitely the simplest model you can get bolted onto a system with relative ease. However, now we have a lot of sequentially-oriented developers who suddenly need to do full concurrency, with their first attempt being on Node.js, a system that doesn't scale either in performance or project size, and on top of a language like JavaScript. Again, it boggles the mind why any one would hail a reactor model as being anything decent to work with. CPS is for the compiler, not for the developer.

The sad part, there's better alternatives out there, such as Erlang and Go, with none of the worries about callbacks in the style of Node.
 
Back
Top Bottom