Looking at this, it has similar aspects as ASP.NET Core, and the same flaws as the Controller per class design used. Methods such as "index", "show" and "store" do not share a state, they shouldn't share a class either.
However, you can rectify this, by just not trying to share a class with any of those. In .NET Steve Smith, aka Ardalis shows how to do this with his Clean architecture [1]. One idea is to make a class for each endpoint. This also makes it easier for "Update" classes to share functionality with other "Update" classes and so on.
Grouping related functionality in a class and using it as a namespace, and using inheritance to get a few useful common features in close proximity and handing hooks is perhaps not the most correct from an OOP perspective, but it's common and results in much less boilerplate than doing everything 'correctly'.
What's more egregious to me is that the methods should just match HTTP method names and have 1 controller per route.
As a convention I don't think one method per verb in a controller is inherently bad just because they don't share state. Plenty of long running, maintainable projects follow this practice.
Nah, if you want heavy backend, go with Go/Ktor/C#, not node. If you want light backend, use sth like Hono or H3. If you want to primarily produce html, use Remix or Next.
Adonis/Redwood/Nest is something you will regret in few years because it will lock you down to "their" ways of doing things instead of something with replaceable components.
Admitted, Adonis looks most sensible out of these 3. Redwood is poisoned with needless GraphQL and Nest is written like 2008 java.
In Adonis you can at least pick the db layer.
But even Adonis locks you to their validator instead of Zod or his cousins, they use their own Request/Response classes instead of the platform ones, has yucky inheritance and annotations magic etc.
Locking things in is not an issue if things are well built and well maintained. Having used Laravel, I'm amazed at their DX. First party libs all built by the same team, tools also built by the same team. Everything is congruent and just flows.
Compare that to the wild west that is Javascript land. Multiple libraries that all do the same thing in different ways. Stuff being deprecated or completely changed.
Sure, if you want "choice", there's plenty of stuff out there for that. You can cobble together your own framework or pick a light framework pick and then add your "batteries" to it. I hope AdonisJS only has 1 way of doing things and that those ways are good, then it will truly go a long way.
The fact that people (the builders) don't bet on a single horse IS the reason why we are in the state JS world is in. The only person that readily comes to mind is Evan You, who's been working on and driving Vue JS for a very long time. Of course, Vue JS is not a framework.
Adonis is starting to get there, but I don't know much about the core team and how long they've been working on it. If they are able to focus on delivering core features and not getting distracted by every wave that hits the JS world, eventually the level of convenience they provide will reach a tipping point and developers will flock to it.
I think there are multiple reasons why JS world is different.
- JS libs often target browser as well and that's a fast moving target
- JS is primary language of serverless which is also moving fast
- it attracts younger devs chasing hot trends
- the fragmentation is already there, people got used to it and some even embrace it
I lead development on a 12 year old SPA. It's a Ship of Theseus where there is almost zero original code but we never had to rewrite from scratch, instead we were swapping piece by piece as we went. The time investment was reasonably small and we never endangered the business with the full rewrite.
I shudder at possibility that someone before me picked "batteries included" AngularJs (the V1). A sibling project is still fighting it today!
"Locking things in" is an issue. It might not be a too big issue but it is one definitely.
Consider choosing Oracle as your database. It is a great database maintained by a big company so it will be around in future too. But you will be locked-in to very expensive licensing because when big businesses are "locked in" Oracle can and will raise their prices.
Until the next dev comes to the project and doesn’t agree with your opinions, right? I’ve seen this movie far too many times.
The main benefits of these frameworks is that they remove all the bike shedding decisions. And I trust more something used by a lot of people and battle proven even if I don’t 100% agree with everything.
What you think is the best library for validations is just an opinion as theirs, and for example I don’t think Zod is good at all. See? Now on a team of 5 people we have 6 different preferences and we have to schedule 10 meetings to decide what library is best. And next month we will regret using it anyways.
There is a reason Rails, Laravel, Django etc are so popular in their ecosystem.
I honestly don’t believe the “I can do better all of this by myself”. It’s usually an undocumented, unproven, buggy and insecure mess that only the main author knows how it works.
That's why I don't recommend Fastify or Express. Remix and Hono use standard Req/Res
Annotations are not part of Js, they are part of Ts and are a concession to OOP people coming from other languages. It's a personal opinion but I don't like them and I enjoy this opinion is not uncommon because only few libs are riddled with them.
Annotations/Decorators are in stage3 of JavaScript. But I agree they are not super common in JS world except TS heavy libs or frameworks. Btw we aren't big fan of them and use them sparsely in models and commands only
I used it for 3 years where everything which was too important (a took a long time to be done by the only maintainer (Harminder Virk) at that time with his only one "helper" (Romain Lanz) , so long that I had to stop using it because it was difficult to use in those conditions.
You must be its creator (Harminder Virk) because this is the type of responses (much worse ones, to be accurate) you were used to provide for anyone who asks you about something.
If you check my Github profile, you will see I still have on my list of starred repositories several of yours. I also still have at least 2 articles on my blog related to AdonisJs. I hope you understand what I mean.
Hehey! I'm late for the party :D I just wanted people interested in frameworks to take a look on comparison with (my) framework which purposefully takes another approach https://news.ycombinator.com/item?id=40743058
I never understood why you need more than a simple expressjs server. After all nodejs works best if served directly after a load balancer. But before heavy duty application logic. Node is fast in accepting, forwarding and replying requests. Put your real work in small c# or golang apps.
Has anyone tried both AdonisJS and RedwoodJS and can compare the two?
Adonis and Redwood are both trying to be the JavaScript version of Rails/Laravel - a traditional active-record based MVC rapid development server application framework.
The last time I looked for one of these (2018) they were immature and now at least in terms of website and documentation they both appear very capable. But if there’s one thing that JS libraries are good at, it’s marketing and slick documentation.
So, curious to hear any experiences with either and especially both.
I haven't used either so I can't chime in on that front, but long ago I was pretty into Sails which is written by a team that loves rails, but switched to NodeJS so it's basically Node on Rails. I actually thought they discontinued it, but I just searched and it still exists. It was a solid framework like 5 years ago when I used it last so I assume it's quite mature now.
5 - 6 years ago I used sails and regretted it because of the assumptions made in waterline about databases. At the time there was no transaction support and joins were a mess. This was pre-1.0, so perhaps it has changed.
These days I use DRF because I like getting the built in Django admin for free. I know it is a bit dated in some ways, but I love the way Django structures things, works for my mental model.
I looked at AdonisJS, but it has soo many things missing that I'd rather just go with Laravel or Rails. Both of those have been around for so long and have an amazing ecosystem (especially Laravel) and are battle tested.
I've also just lost my trust in JS for any serious long term projects. Things work at first and then a year later all the underlying dependencies have changed and stuff stops working.
Fair criticism of the JS ecosystem. Things are always changing.
Btw, its hard to compare two ecosystems with a checklist. For example, Rails doesn't have inbuilt support for Auth, Authorization or Model factories and you rely on community solutions for those.
Similarly AdonisJS is missing some core integrations like queues and you have to rely on community solutions
Yes, this is why I think Laravel is superior to Rails in terms of out of the box functionalities, but I digress.
In the short term, it's fine to use community solutions, but over time, Adonis should bring those things in-house. They also need to find a proper way to monetize the framework so that the core team has the incentive to stick around for a few years to build something truly great. I think this has been the biggest issue with JS world, very few people can and will stick to working on something for long periods of time to make it really good.
The Laravel team figured out the monetization by building out pro-level tools in their ecosystem that people are willing to pay for.
What is missing for you? I don't see much missing anymore coming from Laravel. There are a few things which I wish were more batteries included, such as "forgot password" but that can be made in minutes with code so it's not a big issue.
No mention of Views? The one thing I'd love to understand and is missing vs. Rails/Laraval is an integrated solution of solving the View part of MVC I think?
Looks like a really beautiful framework.
EDIT: Nevermind, it's in the docs, just not on the main landing page so feels a little more secondary. TLDR they recommend you use Edge/Pug/Nunjucks, htmx, vite for css bundling. Nice!
An official mention of Pug? Now, they got me listening.
Maybe it's because it's (mostly) markup, but Pug is the only whitespace language that I really gel with. I wish it had more support across the board!
Maybe it's the years of Emmet use that's got me biased. I remember getting excited about both of these before they each changed names.
I heavily dislike Pug, just because it depends on indentation. Maybe I'm just my IDE somehow wrong, but trying to rearrange things seems always so much more complicated and trying to learn this clever syntax instead of doing normal html.
I absolutely understand. For me it's the _only_ exception to this feeling. Probably something to do with it not being a programming language, and my own preference for as little nested elements as possible, though I can imagine how anything close to div soup would be completely untenable.
Anyone else see these types of announcement posts, and it's like they already have thousands of users? Where do y'all learn about these projects so early?
So a few reasons come to mind. Firstly, these projects usually do more than one HN posts. And by the time they have thousands of users, they have already done quite a few HN posts by then. Additionally, if you follow a particular scene (JS in this case) then you can hear about these projects quite a lot on tech Twitter. Adonis was being actively discussed a few days ago after Theo posted a video about why there is no Rails alternative in JS-land. I personally remember hearing about Adonis when I searched for a Rails alternative in JS a long time ago.
And lastly, this project specifically has been in the making for a good number of years now. So it makes sense that there are quite a few people out there using it.
There are plenty of mature front end SPA frameworks that would work perfectly fine with Adonis. If you want to build traditional server side templated pages they provide a templating engine called Edge, and the docs tell you how to use Vite to bundle assets. If you want to make pages feel like an SPA without using a framework, they suggest Inertia as another comment points out. What do you feel is missing?
However, you can rectify this, by just not trying to share a class with any of those. In .NET Steve Smith, aka Ardalis shows how to do this with his Clean architecture [1]. One idea is to make a class for each endpoint. This also makes it easier for "Update" classes to share functionality with other "Update" classes and so on.
[1]: https://github.com/ardalis/CleanArchitecture/tree/main/sampl...