paint-brush
Ruby vs PHP vs JavaScript - What Should Your Next App Be Built On?by@tobsch
982 reads
982 reads

Ruby vs PHP vs JavaScript - What Should Your Next App Be Built On?

by Tobias SchlottkeNovember 3rd, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Choosing a language for your web application is no easy task.NodeJS vs PHP vs Ruby? You want to choose something that scales well and covers your business needs both on the front end and back end. Fabian Wesner, Founder of ROQ Technologies, has a lot of experience with web apps. He has shared his insights into web application - based on his years of experience and study. He tells you which factors to consider when choosing a language and even suggests a. language for each use case (eCommerce, Static Web Application, and Dynamic Web Application (SaaS, online portal etc.)

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Ruby vs PHP vs JavaScript - What Should Your Next App Be Built On?
Tobias Schlottke HackerNoon profile picture


Choosing a language for your web application is no easy task. Especially if you are a SaaS for which your web application or online portal is your core offering. You want to choose something that scales well and covers your business needs both on the front end and back end.


Fabian Wesner, Founder of ROQ has a lot of experience with web apps. He built 3 shop systems (that have generated many eCommerce websites) and now offers a modular, Feature-as-a-Service web application generator for enterprise-level execution of web apps.


Fabian shared on the alphalist CTO podcast his insights into web application - based on his years of experience and study. (He spent 20 years working (and leading companies) in PHP before switching to JavaScript which he studied intensively for 3 months full time.


In this article, we will discuss the factors Fabian mentioned in the podcast that he suggests we use to determine which language. He then uses these factors to suggest a language for each use case (eCommerce, Static Web Application, and Dynamic Web Application (SaaS, online portal etc.).


Factors to Consider when Choosing a Language for your Web Application

Use minimal languages (in fact, just use one)

It is a good idea to use just one language family throughout - from the backend to the front end. This not only prevents language mismatch but also increases team productivity.


Productivity of the team is heavily affected by the amount of programming languages that you use. - Fabian Wesner, Founder of ROQ Technologies, former CTO of Rocket Internet and Spryker


3 ways using one language in your web app increases productivity

  1. Everyone becomes a ‘full-stack developer’. Of course, you are going to want to specialize each team member but it helps if the frontend developer speaks the same ‘language’ as the backend engineer and also understands the code the backend is written in. This means that people can also help each other out and contribute to code when needed.
  2. Shared Libraries. It makes it possible to share the same libraries between the backend and the frontend, reducing duplicated code. E.g. the same validation library.
  3. Increases team unity. Yes, sometimes even adults divide into teams. You don’t want a Team JavaScript and Team PHP turf war on your hands - do you?


If you are looking for the best all-encompassing language which will minimize the number of languages in your stack, this is what we suggest.

  • Potential Solutions: Either use all JavaScript in the frontend and backend or render everything on the server-side with PHP and Turbo or Ruby.
  • In Practice: Fabian uses all JavaScript for browser, mobile and server-side backend.
    • Backend: JavaScript

    • Frontend: React and Next.js

    • Mobile App: React Native for mobile app


The Client: Web Only or Web + App

Server-Side Rendering has a lot of advantages, the primary one being the simplicity of having only a single application instead of "frontend" and "backend". One key disadvantage though is how it works on mobile. Mobile Apps work best with Client-Side Rendering which leverages the power of a smartphone best and allows the app to work even there is no internet connection.


For most web apps, a stateful UI is important, and a framework like React, Vue or Angular does the job best. One could use a Ruby + JavaScript Events + React combination to achieve this, or even have a Single Page Application entirely in Ruby. An alternative is to use a library like Hotwire that sends all browser events to the server so that a piece of HTML can be generated there. The result is then morphed back into the DOM.


But Fabian prefers to keep everything in one language and that is why he uses React Native for the mobile app equivalent of his React + Next.js App. He does admit though that using React is still a highly complex process and at times he felt that he was far off from React’s use case - but for him, it's worth it.


If you are building a web application that also needs to use on an app, this is what we suggest

  • Potential Solutions: JavaScript (React Native) / Ruby + JavaScript Events + React / or SPA in Ruby (very hard)
  • In Practice: Fabian uses React Native which actually goes well with the React + Next.js he uses in his main stack


Speed

Speed is important. It determines everything from your customer experience to your hosting setup. When Fabian was the CTO of Rocket Internet, they initially used Magento for their Brazilian store. Yet it was just too slow for their needs - because at the time Brazil did not have a local AWS server so sending traffic to a US-based data center using Magento was just too slow - so they had to host locally which was extremely expensive. This was one of the reasons why Magento was soon replaced by Alice+Bob - Fabian’s first lightweight PHP-based shop system.

Some languages though are faster than others. When building his web stack, Fabian compared different language speeds and he found JavaScript fastest for dynamic web applications.


JavaScript Speed Comparison for Dynamic Web Applications

  • Almost as fast as Java

  • 10 times faster than PHP

  • Faster than Python (even to the point Fabian would use Node.js for BI)


If you are building a Web application based on speed, this is what we say:

  • Potential Solutions: JavaScript or PHP

  • In Practice: Fabian uses JavaScript for web applications. (Yet for eCommerce he might use PHP based on other factors).


Workforce

You want to code your program in a language that is easier to get developers in. This is why Fabian advocates for using the latest version of an industry-standard language.


[It is important to use industry standard languages, else] you will also run into technical limitations very quickly and you also will not find developers. I mean, nobody wants to work with an application that is implemented on, [for example] an old version of [Ruby on] Rails. - Fabian Wesner, Founder of ROQ Technologies, former CTO of Rocket Internet and Spryker



How to get good backend JavaScript Engineers?

JavaScript experts are usually better at frontend programming. It is really hard to find a good Node.js engineer for the backend. Even though people might be familiar with Node.js and how it works, there is more that goes into the backend than just Node.js. Even though it is JavaScript, it is still important to implement coding best practices like SOLID principles or “Clean Code” that are required in PHP and Java. Those with a background in Java and PHP know what an interface is, what an abstract class is etc and because of that, they code well. That is why when hiring for a JavaScript-based backend, Fabian sometimes prefers to recruit those with a background in PHP or Java in addition to training JavaScript engineers to code using best practices.


Ecosystem

One thing that determines the popularity of a language is usually the ecosystem.

Node.js has a very active ecosystem, perhaps even too active in that there are a lot of new features popping up all the time that you can spend your days just re-platforming your code to suit a newly arrived front-end framework or a tool!


React itself probably has more features than business uses (which probably means developers are having fun). Interestingly enough, while PHP has Laravel, Ruby has Rails and Python has Django, Node.js is yet to have a comparable framework of its own. (Although NestJS is promising and is quickly becoming industry standard, yet in terms of functionality it still lags behind Django/Rails as an ecosystem.) Fabian predicts soon a big company will get behind it and introduce it - just like Facebook did with React.


  • Potential Solutions: It depends. PHP for ECommerce, JavaScript (particularly React and NestJS) for all other web applications.
  • In Practice: Keeping with using just JavaScript, Fabian uses
    • Backend: NestJS (using Node.js), TypeORM, Apollo Server
    • Frontend: React,Next.js, Redux and Apollo Client (yet Smelter seems to be gaining popularity)
    • Mobile App: React Native for mobile app

Choosing a Programming Language based on Site Purpose: ECommerce, Static or Dynamic

Ecommerce Website

eCommerce sites are complex as you need to manage the state the whole time. Users need a stateful frontend, but you also need stateless sections to allow for easy scaling. (You might also be interested in hearing Kore Nordmann talk about building scalable eCommerce websites).

Common Ecommerce Features:

  • Shopping cart

  • Check Out

  • Discounting and Sales

  • Catalogue (display, filtering, configuration)

  • Multi-currency

  • Multi-Locale

  • Inventory management


You also need something highly secure, with great performance, and easy to scale.


Fabian knows all about eCommerce - having built modular shop systems for 3 companies (Rocket Internet, Project A, and Spryker).


Fabian says to just go with PHP for eCommerce as most engineers with eCommerce knowledge are PHP engineers. This is because of the popularity of existing open-source shop systems (like Magento) while there is no relevant shop system based on Ruby, Python, or JavaScript.


  • Potential Solutions: PHP because of workforce availability
  • In Practice: Fabian used PHP as a base when creating his own frameworks Alice+Bob and Yves & Zed.


Static (Basic) Website

You can of course build a basic website by rendering stateless pages with a stateful front end. Yet this might be an overblown solution if you are just looking to render static pages to show content. The simplest way to achieve this would be an HTML app that renders content -built in the language of your choice (PHP/Ruby/Python). This setup won’t work on a mobile app though.


  • Potential Solutions: Anything that generates HTML e.g. PHP/Ruby/Python


Dynamic Web App

Whether you use a SaaS or a web portal, there is so much complexity when placing all the states in one browser (or mobile app). Again, you are dealing with a lot of state management with a stateful frontend with scaling capabilities (usually through a stateless setup).


You might be also looking for features like:

Common Dynamic Web Application Features

  • User management (e.g. forgot password, permissions)

  • File upload (usually entails security, storage)

  • Billing (e.g Subscription model, invoice system)

  • 3rd party Integration (e.g. Customer Service Apps (e.g. Twilio), Analytics, ESP, or Local Payment Processing)


Questions you need to ask yourself before devising a tech stack:

  • Authentication: Authorisation or ACL
  • How do you persist data?
  • What kind of database?


What is the best stack for a dynamic web application (SaaS or online portal?)

The answer depends on your budget. If you need something that will cost under 5000EUR to develop, PHP + Laravel is your best bet. Yet if you want to know the ideal setup that will scale the best? Read on.


If I started a new startup and have only a 5,000 Euro budget, then probably this would not be the stack that I'm using. If I build an enterprise project and I have a half a million then it has to be done like this because this is the industry standard. This is the best practice. There is a reason it is all like this. Otherwise, you will also run into technical limitations very quickly and you also will not find developers ..I mean, nobody wants to work with an application that is implemented on, [for example] an old version of [Ruby on] Rails.


- Fabian Wesner, Founder of ROQ Technologies, former CTO of Rocket Internet and Spryker



  • Potential Solutions: JavaScript, Ruby, PHP, or any combo of the above.
  • In Practice: All JavaScript. Fabian chose for his web apps something that is both mobile and web. His exact stack might be too complex, time-consuming for non-enterprise level companies to implement on their own (which is why Feature-as-a-Service exists) but perhaps take the inspiration.
    • Frontend:
      • React (stateful UI) + Next (creates structure e.g. pages)
      • Redux (for state management)
    • Mobile App: React Native for mobile app
    • Backend:
      • NestJS (the modern version of Node.js that is industry standard)

      • GraphQL (for main API approach)

      • Federated Graph for putting all the GraphQL together

      • Apollo server

      • Microservers


Conclusion

In this article, we discussed the factors that go into choosing a coding language for web applications (language flexibility, clients, speed, and workforce) as well as which language Fabian would use for the 3 most common use cases: eCommerce, static, and dynamic web applications.


Happy Coding.


First published here


This article was based on an alphalist cto podcast episode. The alphalist podcast features interviews of CTOs and other technical leadership figures and topics range from technology to management. Guests from leading tech companies share their best practices and knowledge.

The goal is to support other CTOs on their journey through tech and engineering, inspire and allow a sneak-peek into other successful companies to understand how they think and act. Get awesome insights into the world‘s top tech companies, personalities and trends by listening today on Apple, Spotify, Google, Deezer and more.


If you are a CTO at a tech-product company, perhaps you would be interested in joining alphalist -an exclusive CTO network? Reach out to us for more information.