The WEB is not one monolithic technology stack, each website is a collection of technologies, frameworks, libraries, languages and platforms that developers have assembled. In the (quite recent past) most of these collections where following a common pattern; each one included one of the following four components: an operating system, a web server, a sever-side programming language and a relation database.

One of the most common web technology stack in the recent past and even now, is LAMP – Linux/Apache/MySql/PHP. The stack includes Linux as operating system, Apache as web server, MySql as database engine and PHP as server-side programming language. Although this was the original structure, the acronym LAMP now refers more to a generic software stack model, in which any of its components are interchangeable or adaptable as long the resulting stack is not vendor lock-in and is available free of cost. That is why we have WAMP (replacing Linux with Windows) or WIMP (replacing Apache with IIS), or LAMP but with Perl or Python instead of PHP, and so on.

LAMP stack has several benefits, besides the fact that is for free:

1. It offers great flexibility by allowing to interchange the components, and use whatever is most suitable for a specific website;

2. Each component is a product itself, so the whole stack is loosely coupled, but highly cohesive (each component does one thing and one thing only in the context of the whole stack)

3. It can ensure high availability by using multiple web servers and database servers combined with additional components that perform logical aggregation of resources provided by each of the servers, as well as distribution of the workload across multiple servers (clustering, load balancing etc.).

So, what is MEAN? Is just another variant of LAMP? As you might guess, MEAN is also an acronym and it stands for: MongoDB/ExpressJS/AngularJS/NodeJS. The term was first used in a blog post, by Valery Karpov, an engineer from MongoDB (see here). You might be tempted to assume that there is a one-to-one replacement of components between MEAN and LAMP. But it is not. MEAN is a completely different animal; it represents a modern approach on web development in which a single language (JavaScript) runs on every tier of your application, from client to server and persistence.

First of all, it replaces an operating system (Linux) with a platform (NodeJS). Is that better or not? A platform runs on top of an operating system and ensures that your website is independent of the operating system on which it runs. You can develop your webapp on Windows or MacOS and easily deploy it on Linux without worrying about compatibilities.

Moreover, NodeJS is designed to be modular. Whatever feature you need, you just add another module to it and that is it. Fully extensible and highly flexible. One of the modules you can add is actually the web server. So ExpressJS is just another NodeJS module. Great, it means you do not have to worry about installing and configuring a web server as a separate product. But there is more to it. The concept of web server on which you deploy your app is gone. The web server is included in your app, so your app is the web server also. The deployment process is much simpler because the required version of the web server is defined explicitly along with the rest of the required dependencies.

Looking at the database layer, you will use MongoDB instead of MySql. How is that better? First of all, it is easier to work with, since MongoDB is a schema-less document-oriented persistence store, instead of schema-based, table oriented persistence: less time spent on SQL queries and more time on writing map/reduce functions in JavaScript. But most importantly, you no longer need to do the transformation from relational database representation to your application model: MongoDB emits JSON (JavaScript Object Notation) natively.

I think the most important change is in the way you develop the application itself. LAMP stack is based on server-side components (written in PHP) that are dynamically rendering the client-side view. But still, in order to enhance the client experience you will need some sort of client-side development (JavaScript) like for input validation, etc. MEAN propose a different approach: SPA – Single Page Application. Basically, you are moving most of the logic from server-side to client-side using AngularJS MVC model. You will change the synchronous approach to one that is fundamentally event-driven asynchronous in nature. AngularJS will handle the page routing and generation, calling the server only for basic CRUD operations on the data.

AngularJS is HTML centric in nature. Instead of dynamically generating HTML components at runtime, it decorates and enhanced the HTML pages through custom directives, which makes the development faster, more elegant and gives web designers a great deal of flexibility in defining the application layout, look and feel. Of course, you can do also HTML generation with AngularJS, and sometimes you have to, but is done in a way that is more flexible and easier de debug and control.

Moreover, MEAN has evolved into a eco-system, which includes several other frameworks/libraries for unit-testing, object mapping, caching, etc. And to make it really easy to work with, there are full-stack solutions for MEAN applications like meanjs.org or meanjs.io. These allows you to quickly configure and download a MEAN skeleton application on which you can instantly start developing. Additional tools like Yeoman for scaffolding, Grunt, Bower, etc. are extraordinary means that makes your life as developer much easier.

In the same way as LAMP, some of the components might be changed (you can use Ember.js instead of AngularJS, or CouchDB instead of MongoDB), but the most important point is that they are all highly cohesive, loosely coupled components.