DEV Community

Cover image for mojo.js 1.0 - from Perl to Node.js
Sebastian Riedel
Sebastian Riedel

Posted on

mojo.js 1.0 - from Perl to Node.js

After one year of development work we are happy to finally announce the very first major release of the mojo.js web framework for Node.js. Now available on GitHub and NPM.

Here's the obligatory "hello world" single file app, with WebSockets:

But mojo.js is not really about single file apps. As a very traditional hypermedia framework and spiritual successor to Mojolicious, it strongly encourages a Model-View-Controller (MVC) layout, while also supporting these single file apps for prototyping.

But, Why?

Right now almost all JavaScript web frameworks are split into two categories. On one side you have middleware frameworks, that do pretty much nothing else than routing on their own, so with every new project you have to build your own framework from scratch with dozens of middleware layers. And on the other side you have the kitchen-sink, where the framework makes every decision for you, forcing you to use React on the frontend, or MongoDB as the database, often even limiting your hosting options to a few large cloud providers. Especially the latter kind of web framework tends not to age very well.

We believe that there is still ample room in the middle for mojo.js. A framework that provides just the essential building blocks for backend web services. The things that rarely change from project to project. Like routing, serving static files, server-side rendering, logging, config files, form validation... you get the idea. In ten years from now you should still feel confident relying on them.

Aside from reliability, having components specifically designed to be used together allows for significant performance optimisations. That's why mojo.js is a lot faster than Express and Koa for example, despite having many more features.

From Perl to Node.js

The Mojolicious project is a group of polyglot programmers who started out with Perl back in the hay days of CGI scripting. Some of us have been making mainstream web frameworks for two decades now. From Catalyst in 2004 to Mojolicious in 2010. Powering some of the largest sites on the web along the way.

Ever since Perl6 (now Raku) started to become a thing we've had plans to port Mojolicious to more languages than just Perl5. But Perl6 drifted into a different direction than what we were hoping for and so those plans never truly materialised.

However, at the same time JavaScript kept evolving. The language gained features like ES6 classes, async/await, ES modules, arrow functions, const/let keywords and much more. Node.js finally brought JavaScript to the server-side. On the language level, there's a pretty close relationship between Perl and JavaScript (and it's not just sharing use strict or having native Regex data types). So it was inevitable that some of us would grow to like JavaScript quite a bit.

Not quite full-stack web framework

I still remember when full-stack meant that the framework contained a router, template engine, and an ORM with support for a bunch of SQL databases. These days they include things like a custom React distribution and a subscription for a serverless hosting service. It's hard to escape these ecosystems again without changing your whole tech stack.

With mojo.js we don't do most of those things. While it ships with a router and server-side renderer with support for multiple template engines, there is no default database. Just a workflow for adding your own model layer. Similarly choosing a frontend framework is entirely up to you. The static file server will deliver whatever assets you need.

What's most important for us, is to provide you with a rock solid foundation. RESTful routing, WebSockets, static file server, cli, logging, config files, session management, form and JSON validation, content negotiation, TypeScript types and a testing framework. Components you can rely on for decades if necessary.

Software supply chain attacks around NPM are a hot topic right now. And it can be quite problematic to audit your whole dependency tree. Thankfully, while the Perl version has no dependencies at all, in JavaScript we only have 23 trusted third party dependencies. And we are prepared to replace every single one of them if necessary, with a port of the battle-tested Perl implementation.

We've also started releasing spin-off projects for standalone use outside of mojo.js, based on some of our other popular Perl projects. @mojojs/dom, @mojojs/template and @mojojs/path follow the same strict rules as mojo.js itself.

What about Mojolicious?

Now you might be wondering if we are going to abandon Mojolicious. And the answer is a resounding no. All of us still enjoy Perl very much, and look forward to keeping it alive for at least a few more decades. πŸ˜‰

Have fun!

Discussion (9)

Collapse
lukeshiru profile image
Info Comment hidden by post author - thread only accessible via permalink
Luke Shiru • Edited on

After talking with other mods, this post is ok. Sorry for the inconvenience caused commenting. I'll still suggest to put it on a "post series" so other folks have more context about the tool.

Original post
If you read the terms:
  • Users must make a good-faith effort to share content that is on-topic, of high-quality, and is not designed primarily for the purposes of promotion or creating backlinks.
  • Posts must contain substantial content β€” they may not merely reference an external link that contains the full post.
  • If a post contains affiliate links, that fact must be clearly disclosed. For instance, with language such as: β€œThis post includes affiliate links; I may receive compensation if you purchase products or services from the different links provided in this article.”

If you only want to promote your product like an Ad, you can do it using the listings option in DEV.

Thanks.


Collapse
kraih profile image
Info Comment hidden by post author - thread only accessible via permalink
Sebastian Riedel Author • Edited on

It's not a product, this is a release announcement for an MIT licensed open source project.

But i will admit that i've made a big mistake choosing DEV for my personal tech blog. The fact that dev.to links are banned on most tech news aggregators has made it unsuitable for serious posts. So i don't think you will have to worry about me posting anything here again.

Collapse
lukeshiru profile image
Info Comment hidden by post author - thread only accessible via permalink
Luke Shiru

You are free to post as much as you want, but if you want to make it a blog post, ideally it should talk about the development process (such as challenges when coding with code snippets as example and so on), compare it at the code level to other solutions (performance, size, DX, etc), show it in action (maybe on a CodeSandbox), and stuff like that.

The format of "I created {library}, because of {reasons}, go check it out" is better suited for the listings section (mainly designed for promotions).

About that "blacklisting", I would love to see some evidence about that, mainly because afaik DEV is one of the best blogging platforms for developers (compared to πŸ’© like Medium, or Hashnode).

kraih profile image
Info Comment hidden by post author - thread only accessible via permalink
Sebastian Riedel Author

Thank you for explaining blogging to me.

lukeshiru profile image
Info Comment hidden by post author - thread only accessible via permalink
Luke Shiru • Edited on

Didn't explained blogging, I explained why I told you that this post is better suited for listings. Due to the confrontational vibe of your answers, it might be a good chance to also remind you that DEV has a Code of Conduct, which includes "Gracefully accepting constructive criticism".

Cheers!

bmeneg profile image
Info Comment hidden by post author - thread only accessible via permalink
Bruno Meneguele

And you went too close of being abusive considering Riedel's answers confrontational and pointing to CoC, is that also state in the CoC?

Being a user of Mojolicious I trully understand and see how this CAN and IS a blog post with actual constructive information with internals and comperison explanation/details. I really didn't understand your point.

Also, how could this info fit 400 chars? Or where did you see any of the terms you quoted in the text? He has posted about his work on this framework for quite some time already.

And you polluting the comments of a real blog post instead of reaching out to him directly shows how you don't understand about blogging.

Thanks.

lukeshiru profile image
Info Comment hidden by post author - thread only accessible via permalink
Luke Shiru • Edited on

If this is part of a series of post, then it should be using the post series feature of DEV. As a user of the tool itself it might be useful for you, but as a user of DEV I opened a post tagged as #webdev #node and #javascript and a title that states "from perl to node", but it is only presenting a tool with a single code snippet that doesn't look much different from express. The problem isn't with the tool itself, the problem is that the format is more an announcement than an actual blog post, which better fits listings.

Now about the CoC, the problem as you might notice is that just now I'm learning this is part of a series, the author had the option to answer something like:

This might be a mistake, this is part of a series of posts with more details about the tool, how was it made, the problems it solves, details about the implementation, and so on. I'll update it to be part of a series.

But instead he chose to say "is not a product" (when I used product as "a thing that is the result of an action or process", so it IS a product), and then proceeded to rant agains DEV as a platform.

When I explained why I wrote my initial comment (a format issue, that could be easily solved), and I asked him about what he mentioned in his rant, instead of answering something like:

I get it, I'll update the post so it looks less like is just an announcement.

And then maybe expanding on his rant ... he chose to just be sarcastic about my explanation. You might see why I sensed he was just being confrontational, so I informed him that is not OK in DEV, so maybe with a cool head we could have a better conversation. Not to mention that there would be way less "pollution" in the comments if the conversation was less "ready to fight" and more "ready to fix". I have strikethrough comments like the first one in the past when the post is fixed.

Sloan, the sloth mascot
Comment deleted
lukeshiru profile image
Info Comment hidden by post author - thread only accessible via permalink
Luke Shiru

Is not entitlement, Sebastian. Is your blog yes, but you have to consider that your post are part of a public feed we all read. I saw it on my feed because the title sounded interesting, and when I got into the post I found it was only an announcement. Initially I thought it was a better candidate for listings, but other mods told me is ok as a post.

If you follow this thread:

  • My comment explaining the terms and suggesting listings (later edited based on corrections by other mods).
  • Your reply ranting about DEV as a platform.
  • My reply saying you're free to post what you want and explaining why I suggested listings. I also asked about your rant against DEV.
  • Your reply sarcastically assuming I was explaining blogging to you when I wasn't.
  • My reply explaining my previous comment and letting you know that is not ok to be confrontational.
  • Reply from Bruno saying this is part of a series of post.
  • My reply explaining that then you can use the post series feature of DEV, and explaining why I considered your responses confrontational.
  • Your reply saying I'm entitled.
  • This reply explaining and summarizing the situation.

Maybe is a language barrier, but if you read my replies, I'm always explaining and your responses are always confrontational.

One thing we agree on is that I don't want to keep this conversation going either, so that's it from me. I'm sorry if my explanations felt "entitled", but I just wanted to inform you of better ways of using DEV as a platform. Hope from now on, if other members of the community ask you about your tool, the responses are friendlier.

Cheers!

Some comments have been hidden by the post's author - find out more