The Battle of (Web) Back-end
Tags: webdev, beginners
Published: 2019-12-01 14:34:06

Last week as I once again found myself marvelling at the ease of which Rails allows you to generate models and controllers with a simple command, I found myself wondering how it is possible that Ruby on Rails is not the most popular and commonly used programming language for back-end web development. 

I decided to do some research, and hopefully understand better the pros and cons of the various popular back-end web development languages. I am going to focus on 3 of the most beginner friendly languages at the moment which also happen to be probably the 3 most popular: Ruby on Rails, PHP, and Node.js. An honourable mention goes out to Python, Scala, Java, GoLang, and the many other back end languages out there. So without further ado..

<h2>Ruby on Rails</h2>

Ruby, along with it's popular and ubiquitous framework, Rails, is the back-end language I have been learning over the past couple of weeks. Despite having many advantages, it is not the most popular back-end language currently. 

<h3>Advantages</h3>
<ul><li><b>Generators</b> - Rails allows you to generate a lot of code with simple one line commands. This saves a lot of time and allows an MVP to be built very quickly. 
<li><b>Libraries</b> - Ruby has a vast library of code that are accessible via the gems. Almost anything you can think of has been built already and is freely avaible as a gem. 
<li><b>Readability</b> - Ruby is a very succinct and readable language. This makes it a favourite for new coders and coding bootcamps. The easy to grasp syntax makes it easier to focus on learning the programming concepts themselves. 
</ul>

<h3>Disadvantages</h3>
<ul><li><b>Speed</b> - The biggest argument against Ruby on Rails is the run-time speed. It can be considered "slow" compared to some other languages such as Node.js, but realistically this is rarely going to be an actual issue for the majority of applications. Twitter famously migrated from Ruby to Scala as they had some scaling issues due to the massive surge in popularity of their website. 
<li><b>Documentation</b> - Some of the Ruby documentation can be shockingly bad, and often it is better to refer to previously asked questions on websites like Stack Overflow than to try and dig through the official documentation.
</ul>

<h2>PHP</h2>

PHP is officially the most commmonly used back-end language, with 83.1% of the market share in 2018 accoding to W3Techs.com. The massive market share comes down to it's age and staying power, being one of the oldest server side languages around, many websites and applications are built on it. Facebook was built on PHP for example. 

<h3>Advantages</h3>
<ul><li><b>Library support</b> - There are variety of code snippets that allow PHP developers to automate common tasks such as session management, authentication and security. These libraries also allow applications to be built more quickly. 
<li><b>Speed</b> - PHP is considered relatively fast as it does not use many system resources. 
<li><b>Popularity</b> - The popularity of PHP itself also helps keep PHP relevant. As it is such a commonly used language, many new developers will learn PHP in order to increase their employment opportunities. 
</ul>

<h3>Disadvantages</h3>
<ul><li><b>Scalability</b> - PHP does not scale well with large applications. PHP code for huge apps will be difficult to maintain. 
<li><b>Poor error handling</b> - It is widely believed that the error handling offered by PHP is sub-par, especially in comparison to other languages. There is a lack of debugging tools which can hinder development. 
</ul>

<h2>Node.js</h2>

Node.js is a newer but increasingly popular technology. It is essentially a runtime environment for JavaScript which allows JavaScript to develop the server side of a web application as well as the front end. 

<h3>Advantages</h3>

<ul><li><b>Low barrier to entry</b> - It is built around JavaScript which means front-end developers will have an easy time picking up Node.js. This also means the front-end and back-end can both be built by the same developers!
<li><b>Great performance</b> - Node.js is known to have great performance. Node.js interprets JavaScript via Google's V8 JavaScript engine, which converts JavaScript into machine code, which is run faster and more efficiently. 
<li><b>Flexibility</b> - Node.js is very flexible allowing developers more freedom when developing apps. This is in contrast to languages such as Ruby where there are much more strict guidelines enforced. 
<li><b>In demand</b> - Node.js is one of the most fashionable and fastest growing languages, making developers very much in demand. Although it is based on JavaScript, it still takes a while to become familiar with the intricacies of Node.js, meaning not all JS professionals will be able to work on Node.js projects immediately. 
</ul> 

<h3>Disadvantages</h3>

<ul><li><b>Less library support</b> - The code libraries of Node.js are less thorough than other popular languages. This means more manual coding has to be done during development. 
<li><b>Bottlenecks with highly computational tasks</b> - Without going into too much detail, Node.js struggles with CPU intensive tasks due to it being built on JavaScript which only uses one thread. Modern CPUs have multiple cores, which are the physical equivalent of a virtual thread. When given an intensive task, the CPU will usually split the task between threads to improve processing speed. Javascript however is designed to carry out front-end tasks which are generally not CPU intensive so only require one thread. 
</ul>

<h3>Conclusion</h3>

As you can see, there are arguments to be made for and against all of the popular back-end programming languages. I think any of the above options would be a good option for a beginner learning to code - I am certainly enjoying learning Ruby on Rails, and will aim to learn Node.js in the not-so-distant future!