Why to use one programming language full stack (Node / JS)
When building a project often a different programming language gets used for the frontend and backend. For example someone might build a React application that talks to an API written in PHP.
There are various reasons for doing so, political reasons in companies, team skillsets and personal biases to name a few.
But I want to talk about the advantages of using one language, for example JavaScript, across the stack. In the case of JS, this might be a React application talking to a API written in Node, maybe with the help of something like Express.
JavaScript is the main candidate to discuss here because it is the language of the web. Whilst there are alternatives, none really have the traction that JavaScript does. It is also used in production and at scale, for full stack applications used by millions.
You get to share code across the stack
This may sound obvious but think about it. If you were using TypeScript, your types get defined once. Even in vanilla JavaScript, utility functions for things such as formatting or parsing don’t have to be written and maintained in multiple different places. You just create a shared library and consume it within the frontend and backend applications. Rolling out new additions seamlessly to both.
Easier hiring people that are willing to work full stack
What are the chances of you finding someone that is interested in writing PHP and JS, or Ruby and JS? Never-mind finding someone that are actually good at both.
In my experience the developers that pitch themselves as full stack tend to have a leaning in one direction or the other. They may write shoddy PHP code and amazing JavaScript.
Writing things one language makes it much easier for people to transition between working on the API side of things vs the frontend. It means that whilst paradigms and patterns may change, the actual syntax is relatable. So its less likely that developers will cause a mess when working on whatever side is less familiar to them.
You an use a similar testing suite for both
If you’re familiar with something such as JUnit you will be able to use the same — or similar approaches to testing. Maybe paired with additional plugins when testing something like React components.
This also means that developers new to one side of the stack will be able to more easily get involved with unit testing.
You can use plugins in both places
You may rely on the use of plugins through something like NPM and some of which may be suitable to use full stack, so no longer will you need to build trust and understanding two different sets of plugins from different sources and for different technologies.