Posted in c#, javascript, nodejs, ravendb, mongodb

RAW and MEAN

  • RAW - RavenDb / Angular.js / WebApi
  • MEAN - MongoDb / Express.js / Angular.js / NodeJs

Both are considered full application stacks. With Angular.js in common.

If I were creating any decent sized application, today, it would be a face off between these two stacks. I am excited about the MEAN stack, however domain modeling in JavaScript terrifies me. Given it's loosely typed nature, writing a tight; immutable domain could be... Well, messy?

For this article I am going to pick out a few points which I either like or worry me about the two stacks, and talk about those.

Domain modeling in Node?

Why not just use your mongoose database models?

Using the MEAN stack we would probably be using Mongoose as the ORM for our MongoDb.

Mongoose is already an abstraction on the data layer, which offers a nice convention to help create your models.

Of course you could separate your mongoose models from a more POCO domain model. This would require almost duplication of the domain for not much benefit. Keep it simple.

RavenDb and Mongoose ORM

Similar to RavenDb, as an ORM; Mongoose doesn't get in your way. You are free to design your models however you like.

This is down to the nature of NoSql document stores. They tend not to suffer from the same pain points SQL ORM's such as Entity Framework and NHibernate do.
We are storing and retrieving objects after all, there is no impedance mismatch.

Angular.js

So, Angular has won the war?

There are good alternatives for sure, however I don't feel dirty when I say that Angular seems to have come out on top. It's certainly more popular, it has company backing and a very active open source community. Win.

Mongo and Raven

These two are similar in nature. Mongo has strong ties to NodeJs. There are mongo drivers available for other platforms (such as the C# driver).
Same goes for Ravendb, you can also find libraries for node (node-ravendb).

That being said, they were both build with their respected consumers in mind.

  • Query RavenDb using LINQ.
  • Query the Mongo shell using JavaScript.

It's worth mentioning, RavenDb (like with most of the RAW stack) has a price tag associated with it. Where as licensing isn't an issue using Mongo.

Infrastructure

So the RAW stack is pretty much a Microsoft stack. You can run WebApi under Mono, however RavenDb is still unable to run under Mono as of version 2.5. This isn't the end of the world - version 3.0 is coming soon and this includes support for Mono! So along with WebApi support, the whole RAW stack will soon be deployable under Mono.

The MEAN stack can be hosted on Linux. So setting up an application is certainly cheaper, if that's your thing.

Application Setup

This is where the MEAN stack really shines for me. Using something like mean.io you can run two commands (assuming you have the prerequisites, bower; mongodb etc..) and have a basic application setup and ready to go.

It's literally:

$ sudo npm install -g meanio 
$ mean init yourNewApp

This will generate the boilerplate for your application.
Using something like Mean.io does of course make certain presumptions, such as using grunt and twitter bootstrap.

Tools

The tools which support JavaScript keep getting better and better. Jetbrains' Webstorm is a great IDE!
For me though it still struggles to give the same level of itellisense and code completion utils as Visual Studio does for C#. Understandably this is because JavaScript is a much harder language to predict, given it's not a strongly typed; compiled language.

So Webstorm is great for JavaScript and the MEAN stack, no doubt. Though I believe they still have a ways to go to compete with the developer experience Visual Studio gives developers.

Tooling for the RAW stack seems more solid to me. This gives it an edge.

I don't want to give it all to Visual Studio though. Webstorm is a hell of a lot cheaper, and keeps getting better.

Bits I’ve left out

  • Performance (This is a silly argument)

Some more info