David Hockley

PHP vs NodeJS vs Python vs Ruby - What Do The Statistics say?

(https://cdn-images-1.medium.com/max/800/1*g8fyACCVcgoylQdzjJH3CA.jpeg)

Which language to choose for backend development, between PHP, Python, NodeJS, and Ruby?

I love learning new technologies. If I could, I’d recommend you learn them all. But life is short, and time is precious. And these four languages each have different strengths and weaknesses and use cases. (You can find my video treatment of this question here(https://www.youtube.com/watch?v=Wq7rZxU3_pw))

We’ll look through them together, and by the end, I hope to have helped you make your choice.

And one small detail, before going any further. I’ve limited myself to scripting languages, to avoid making too long an article and to stay on a subject I know well. This is why I’m ignoring ASP.NET or Java.

Now, let’s see who are the contenders.

First, we have **Python, **which was created in 1991 (and version 3 in 2008). Then we have PHP which was created in 1994. Ruby was created in 1995. And finally, NodeJS was created in 2009. But the language is an extension of JavaScript which was created in 1995.

So let’s examine together these different languages, according to different criteria. For each of these, I’ll distribute a total of 10 points in total, and we’ll see where that takes us.

To do so, I will rely on different sources of information, two in particular.

The first of these is the Stack Overflow developer survey, which measures how developers rate different languages. And also the w3tech website, which measures real-world usage(https://w3techs.com/technologies/overview/programming_language)** of different server technologies**.

Round 1: Server Usage

Now, why is it interesting to look at this number? Well, it shows real-world popularity. And it indicates how many opportunities there are to find a job.

So without further ado, here are the usage rates of the different languages, on servers where the language is known:

  • Python has a 1.3% usage rate.
  • Then we have NodeJS with 1.9%.
  • Then we have Ruby which is present in over 6% of servers.
  • And finally, PHP is present on a whopping 78% of servers.

PHP is the foundation on which Wikipedia, Facebook, and of course WordPress were built. And to be honest, WordPress alone is present on 40% of sites — at least those whose technology we know.

That leaves "only” 38% of sites using PHP, once we ignore WordPress. That’s still a factor of 6 compared to the nearest competitor, Ruby.

And so with almost 80% of usage rate in PHP and 6% for Ruby, I’ll give 8 points to PHP and 1 to Ruby (and 0 to the two others) for this round.

Round 2: DX

Now let’s take a look at the StackOverflow developer survey for 2021(https://insights.stackoverflow.com/survey/2021#technology-most-loved-dreaded-and-wanted). We’ll start by looking at two questions this survey asks. The first of these is: This language… do you love it, or do you dread it?

This question is interesting because it reflects the satisfaction and frustration of developers. So it’s a good indicator of what we call the "DX” or "developer experience”. But it’s also a good indicator of the language’s **consistency, **and of the quality of its community.

The second question is: do you want to work in this language? This expresses the attractiveness of a language.

For each language, we’ll take the rate of people who like it, minus the rate of people who don’t like it, and this will give us a net satisfaction score. Then we will add the percentage of people who want to work in the language:

round 2 score = like % - dread % + want %

So. What are the results?

For PHP, 40% of developers say they like it, while 60% say they don’t like it. This gives us a net score of -20%. And only 2.5% of developers want to work in this language, so that makes a total of -17.5 for PHP

For Ruby, next, the situation is slightly less grim: 53% love it, 47% hate it, which is a net score of +6%. And the percentage of people who want to work in Ruby is only slightly higher than that of PHP, at 2.6%. So for ruby, we have a total of 8.5.

Then comes NodeJS, with 63% of positive opinions against 37% negative opinions, for a net satisfaction score of +26. And the attractiveness of NodeJS is at 12%, so we have a total of 38.

(Oh, by the way: For your information, Typescript — which can be used with NodeJS — has a 73% approval rating. Its attractiveness is at 15%. So here it would have a total of 61. I’m not going to include it in the NodeJS total here, but it’s worth mentioning)

Finally, Python has 68% positive reviews and 32% negative reviews, i.e. a net satisfaction score of +36. Taking into account an attractiveness of 19%, this gives it a total score of 55.

Compared to the -17.5 of PHP, Ruby has 26 points more, NodeJS has 56 points more and Python has 73 points more.

If I add all this up and divide each score by the total, we now have percentages that add up to 100, and we use that to assign points.

So all this gives us, for Round 2 : 0 points for PHP, 1 point for Ruby, 4 points for NodeJS, and 5 points for Python.

If we look at the current score, we have for the moment, in last place

  • Ruby, with 2 points in total.
  • NodeJS with 4 points,
  • Then Python with 5 points
  • And finally PHP with 8 points.

Round 3: salaries

Now let’s talk about money and salaries. More precisely, median salaries. Stack Overflow asked developers(https://insights.stackoverflow.com/survey/2021#technology-top-paying-technologies) all over the world what their annual salary was.

Obviously, the global situation doesn’t necessarily translate to each country. But does give us a relative indicator. For a given technology, they identified the salary that had as many people paid more as people paid less, i.e. the median salary for that technology.

It’s worth noting the median is a better indicator than the mean or average. Especially when there are disparities. And when it comes to salaries, things are rarely even.

So let’s take a look at these median salaries.

For PHP, that median annual salary is 39 000 $.

For NodeJS that median salary is 55 000 $.

Next is Python, for which the median salary is 59 000 $.

And finally, we have Ruby is in the lead with 80 000 $.

Let’s do a calculation similar to the previous question. We calculate the difference between these amounts and the lowest of them (i.e. PHP). Then we relate each differential to a percentage, and that gives us for this round:

  • In last place, PHP with 0 points.
  • In third place, NodeJS with 2 points.
  • In the second position, Python with 3 points.
  • And in the first place, Ruby, with 5 points.

Key Takeways

If we calculate the cumulative scores, we now have the following situation:

(https://cdn-images-1.medium.com/max/800/1*mlsCK5hwz6BmnnlWwBqO5Q.jpeg)

The final results

  • NodeJS is in last place with 6 points.
  • Ruby is in second place with 7 points
  • And PHP and Python are in a tie with 8 points.

As you can see, the scores are close, but for very different reasons.

What could justify choosing one over the other?

And this is where another subtlety comes into play.

The syntax of PHP and JavaScript are both inspired by C. For example, curly braces define code blocks.

And Python and Ruby are (relatively speaking) closer to each other. At least visually. For example, blocks are defined by the "def” keyword. Even though indentation has syntactic importance in Python that it does not have in Ruby.

Now: What could make the difference between one language or the other?

Well, this is where the objective side of the numbers finds its limit. In reality, it all depends on where you want to go with your career. What your ambitions are. And how averse you are to risk.

Let me explain.

Let’s take the case of Python. Truth be told, the major use cases of Python is Data and Machine Learning. These offer interesting opportunities and salaries. But they also require a certain appetite for math.

However Python, as a server-side language, is a marginal use case compared to the three other languages.

But if you know you want to go into backend development, and you’re worried about finding a job, you can’t ignore PHP.

It’s not an exciting solution today, but it’s reliable and solid. And as a side note, if you want to find freelance work, it’s worth understanding how WordPress works.

But PHP’s median salary is the lowest of all four.

Conversely, there are fewer opportunities in Ruby. But there are also fewer skilled developers.

This means that the salaries are higher in Ruby.

If you want job security, you’d better go for PHP, if you’re not afraid of risk, but you want a higher salary, Ruby can be a good path to choose.

And finally, we have NodeJS. Here the situation is a bit different. NodeJS is a variant of JavaScript. And as the StackOverflow survey shows, almost 70% of developers use JavaScript.

That means it’s essential to know JavaScript (and ideally TypeScript) if you want to be competitive.

My recommendation, then, is to learn JavaScript and TypeScript, and a second language depending on what you want to do or the job security you want to have.

There’s Python if you’re interested in data science (and math) too.

There’s Ruby if you are not afraid of risk and want to try to get a job that pays more

And there’s the safe solution, PHP. It’s also an easy solution if you already speak JavaScript. But it’s probably not the most exciting one.

But whatever you choose, make sure to have fun along the way!

Social
Made by kodaps · All rights reserved.
© 2023