Confused about what combination of technologies used to make your next web app?
This article makes the case for one very popular stack called MERN (MongoDB, Express, React and Node). We’ll also look at a couple of considerations for making your choice of stack.
A “stack” is simply a combination of front and backend technologies used to make an app. One thing that’s affected stack choices has been the growing popularity of
Single Page Applications (SPAs). A SPA avoids the need to refresh the page every time new content is displayed. In addition, but unrelated to SPAs, NoSQL databases such as MongoDB have become very popular. In the past few years, MERN is a common stack choice especially for building smaller apps.
Here is a bit more about each of the components of the MERN stack:
React anchors the MERN stack and it is the component that renders the view of your app. Although sometimes mistaken for a framework, it is really a library meaning it does not dictate a pattern, but simply offers pieces of utility you can pick and choose from.
React stands out from its declarative nature of updating views. So instead of the old jQuery way of doing things using some DOM manipulation, you don’t have to do anything. React will figure out what the new view should look like and just applies the changes and voila!
React accomplishes this by creating a super-fast virtual DOM which React can update very quickly. Once the virtual DOM is updated, then React can update the traditional DOM all at once. React can “react” very quickly!
This semblance of multi-tasking is done through callback and the event-loop. Think of the event-loop as a “waiting room” for events. So if we write a line of code to open a file, we’ll give that code a callback telling it what to do once the results come back. While waiting for the file to come in, we run other tasks. In the meantime, Node found the file and put it in the “waiting room”. When “set off” the call back will grab that file from the “waiting room” and bring it out to do whatever it was supposed to do, e.g. display, update, etc.
MongoDB is the database used in the MERN stack. It is characterized as a noSQL document oriented database with a flexible schema.
You are probably used to the usual databases with tables consisting of rows and columns. What noSQL MongoDB does is take what would be a row in the traditional database and put that row into a separate document or object. Then, take a pile of those documents and put them into a “collection”.
Keep on coding out your dreams!
*I always have to know where names of technologies come from. So where does the word “mongo” come from? “Mongo” is just a piece of the word “humongous”