Mandarine is a relatively new typescript framework that runs on Deno. Its objective is very simple: to provide as many built-in functionalities as possible for application development.
Mandarine is a ready-for-production framework & one of the few packages that are production-ready, and by far, the best server-side framework in Deno
Mandarine was mainly inspired by Spring Boot & owns a big set of built-in tools for development such as Dependency Injection, Built-in authentication system, MQL (Mandarine Query Language), ORM (with MQL), Built-in session middleware, CORS middleware, and much more.
For more information about what Mandarine has and why is perhaps the best server-side framework in Deno, click here.
Mandarine & NestJS are perhaps brothers from different mothers, they are really similar in terms of syntax & features, some would definitely argue Mandarine has a much better & simpler syntax than NestJS, this is because NestJS tends to adopt the Angular pattern of modules while Mandarine only cares about declarations: there's no such thing as a "module" in Mandarine.
Mandarine does not have the concept of "modules" or "providers", everything is plain declaration of ES6 classes & decorators and it's ready to be used. NestJS on the other hand, abstracts this a little bit more.
Finally, friendly reminder that Mandarine & NestJS run on different runtimes: Mandarine is for Deno while NestJS for NodeJS.
Mandarine is perhaps richer in functionalities. This does not mean that Mandarine has all the features NestJS has, not at all. This means, Mandarine has many others (and more) built-in tools that make development easier and reduce the boilerplate of many packages with only one goal: Every major functionality you would write in Mandarine should be a Mandarine-powered feature.
To explain this a little better, let's look at some of the features Mandarine has:
- Built-in Authentication (No need to write the logic behind securing endpoints, or authorizing users as it is already provided)
- Built-in Repositories (No need to code the logic behind database queries as Mandarine's ORM is fully powered by MQL)
- MQL (Mandarine Query Language)
- Session Middleware (No need to use external packages to manage sessions, as it is already built-in in Mandarine with the option to create your own session container)
- CORS Middleware
- Serving Static Content
- Resource Handlers (Interceptors for different kind of static content)
- Custom Decorators
And of course, there are a few more features that are important but that is not the purpose of this post.
For more information about Mandarine's feature, visit its official documentation
Extraordinary claims require extraordinary evidence
Many of you may be thinking, how come a Deno framework could possibly better or more stable than a NodeJS one?
Let's start with some facts:
- Deno is at version 1.5.0, and it's production ready, this has been stated even by Ryan Dahl (Creator of NodeJS & Deno)
- Deno is richer in functionalities.
- There is already room to argue NodeJS and Deno are both good enough for production environments, some would argue Deno is even better since it provides a set of built-in dev tools (like bundling, linting...) & typescript support as first language.
With that said, we can put Mandarine & NestJS at the same level of the discussion in terms of real-world stability.
Deno has an excellent relation with Rust, in fact, you can connect Rust-written libraries to Deno & call the methods inside those libraries through JS. When you think about it, the limit is the sky. We are talking about direct connection of a very powerful language like Rust (which some argue it's much better and simpler than C++) being called/used from a very popular language like JS. This is a key for Mandarine's plan of success.
As stated in this blog:
If Deno is not capable of providing a required feature for stability, we would use Rust again to cover these needs.
That means, Mandarine is not only a Typescript framework but will also be powered by Rust.
Rust is a very popular language (most loved language for 4 years in a row according to Stackoverflow), it has been out there for 10 years, and we can all agree it is very very stable. As a matter of fact, Google is considering integrating it in its V8 engine (Click here for more)
Now with Deno, Rust & Mandarine, Mandarine would connect every requested feature that Deno cannot provide to its Rust core which means, Rust would provide functionalities to Mandarine thus bringing Rust's stability & Rust limitless internal processes to Mandarine (The JS/TS world).
Quick example of what this means: You want to use Mandarine to modify images, but there are no packages in Deno to do such things (nor Deno provides such functionality). It doesn't matter, Mandarine will provide you a rust application to modify images that you can call from your JS/TS application.
Of course, this is a very vague example, Mandarine's rust core is meant to go along with Mandarine's goals. But I mention this example for a better perspective on what this means.
With the support of Rust, Mandarine can provide functionalities that are yet to exist in Deno & NodeJS, this will give Mandarine advantage in both runtimes.
One of the main features of NestJS (which Mandarine is missing) are microservices. Microservices in NestJS are entirely coded in Typescript (JS). On the other side, Mandarine could provide a communication-interface for microservices written in Rust but used in the JS side, thus providing performance and more stability in terms of maintenance.
One of the goals Mandarine has had for quiet a long time is to provide a very stable, multi-threaded, database driver not only for Deno but for its internal usage.
This week, Mandarine came out with
Mandarine Postgres, a PostgreSQL rust driver that you can use from Deno which officially made Mandarine a framework with mixed codebases.
This driver makes use of
tokio-postgres under the hood, a widely-used Rust driver for postgres which has been out there for more than 4 years.
This, again, is one of the examples of "What Deno can't provide, Rust can".
This post is not meant to dismiss NestJS awesome work and features rather than presenting both facts & views to how Mandarine could in the future surpass NestJS in terms of functionality and perhaps stability with the Deno core.
This post is also meant to show how Deno can get to be more stable than NodeJS in some scenarios, or how packages in Deno can take advantage of Rust for the better.
The different opinions towards NestJS are just that, opinions. It is up to the reader to interpret this post. While it is true that Mandarine may be at the same level of NestJS, it is also true NestJS has been out there for much more time and it is widely used globally because of the excellent work they have done & provided to different companies around the globe.
Click here to see a quick example on how to get started with Mandarine