[HN Gopher] AdonisJS
       ___________________________________________________________________
        
       AdonisJS
        
       Author : spacebuffer
       Score  : 90 points
       Date   : 2024-06-20 12:42 UTC (10 hours ago)
        
 (HTM) web link (adonisjs.com)
 (TXT) w3m dump (adonisjs.com)
        
       | Ciantic wrote:
       | 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.
       | 
       | [1]:
       | https://github.com/ardalis/CleanArchitecture/tree/main/sampl...
        
         | treve wrote:
         | 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.
        
           | mewpmewp2 wrote:
           | What about just having request handling functions in a single
           | file or a directory?
        
         | crowcroft wrote:
         | Both approaches are fine, and doable.
         | 
         | 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.
        
       | jitl wrote:
       | 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.
       | 
       | Is it actually good?
        
         | itslennysfault wrote:
         | 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.
         | 
         | https://sailsjs.com/
        
           | kevinob11 wrote:
           | 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.
        
           | sureglymop wrote:
           | I think something that is somewhat similar but even more
           | fleshed out than Sails is NestJS.
           | 
           | Personally though, I'm just done with server side JS and the
           | dependency hell coming with it.
        
             | itslennysfault wrote:
             | NestJS is my go to and the reason why I haven't touched
             | Sails in years, but it is more "Angular for the backend"
             | than "Rails for JavaScript" imo.
             | 
             | but I probably should've mentioned it anyway since it has
             | been my node backend framework of choice for quite a while.
             | 
             | I'm kinda with you on that though. I'm actually currently
             | prototyping new services in DotNet Core and am really
             | enjoying it so far.
        
         | charlie0 wrote:
         | 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.
        
           | amanvirk wrote:
           | 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
        
             | charlie0 wrote:
             | 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.
        
       | Brosper wrote:
       | I am just exploring this kind of frameworks for my company. I
       | wonder how many people use it on productions and are happy with
       | it.
        
       | rpowers wrote:
       | 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?
        
         | yasoob wrote:
         | 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.
        
         | bluetidepro wrote:
         | To what "yasoob" said, you probably just missed it in past HN
         | posts: https://hn.algolia.com/?q=adonisjs - It's been talked
         | about for 4+ years now.
        
         | NayamAmarshe wrote:
         | This is getting popular due to the recent 'Laravel vs JS
         | Frameworks' controversy.
         | 
         | https://www.youtube.com/watch?v=yaodD79Q4iE
        
           | amanvirk wrote:
           | Hell yes. Maintaining this framework for 10years and only
           | recently we have started getting attention because of all
           | this Laravel vs JS drama!
        
         | Kerrick wrote:
         | Right here on Hacker News, actually.
         | https://news.ycombinator.com/item?id=16509058
        
       | revskill wrote:
       | Lack of vite/webpack/... FE integration is a huge breaker.
        
         | rykuno wrote:
         | How? It claims to support InertiaJS.
        
           | revskill wrote:
           | Be real, you want to build a SPA, how ?
        
             | 0xblinq wrote:
             | We can't read the docs for you.
        
           | tresormuco wrote:
           | https://docs.adonisjs.com/guides/views-and-templates/inertia
        
         | amanvirk wrote:
         | https://docs.adonisjs.com/guides/basics/vite
        
         | aobdev wrote:
         | 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?
        
         | 0xblinq wrote:
         | Did you even check the docs? Or just reading the title was
         | enough to drop your opinion?
        
       | nikodunk wrote:
       | 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!
       | 
       | https://docs.adonisjs.com/guides/views-and-templates/introdu...
        
         | ortsa wrote:
         | 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.
        
           | efilife wrote:
           | I never saw the appeal of Pug, it's hideous and completely
           | unreadable for me. I can't easily tell where code starts and
           | ends
        
             | ortsa wrote:
             | 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.
        
           | mewpmewp2 wrote:
           | 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.
        
       | morbicer wrote:
       | 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.
        
         | songbird23 wrote:
         | this is the way
        
         | charlie0 wrote:
         | 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.
        
           | morbicer wrote:
           | PHP world is different. There's only Laravel and Symfony. You
           | can't count on both surviving till atomic winter.
           | 
           | As you say, js world is fickle and I wouldn't count on Adonis
           | being here for a long time. Mix and match is more pragmatic
           | in this setting.
        
             | tommica wrote:
             | > You can't count on both surviving till atomic winter.
             | 
             | Nor can you count on your JS library to survive until next
             | winter.
        
             | charlie0 wrote:
             | Lol, Symfony was released in 2005 and Laravel in 2011. PHP
             | is much older. They've been around for long time and will
             | stick around for many winters.
        
               | morbicer wrote:
               | Oops I made a typo, I meant you CAN count on them
               | surviving
               | 
               | In Js world it's better to not bet everything on a single
               | horse
        
           | galaxyLogic wrote:
           | "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.
        
             | 0xblinq wrote:
             | Terrible example.
        
         | amanvirk wrote:
         | Too much misinformation
         | 
         | - Locks you to their own Validator. Nope, Run npm install Zod
         | and you have it working
         | 
         | - Their own Response/Request classes. Isn't it same with
         | Fastify, Express and other frameworks?
         | 
         | - Annotations, Aren't they part of JavaScript?
        
           | morbicer wrote:
           | 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.
        
             | amanvirk wrote:
             | Yeah being subjetive is fine. We all have tastes and
             | preferences and that's why there are so many frameworks and
             | ecosystems.
             | 
             | Going to nitpick a little here
             | 
             | Hono docs language says, they wrap the standard Request
             | object that you can access via HonoRequest.raw
             | https://github.com/honojs/hono/blob/main/src/request.ts#L26
             | 
             | 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
        
         | joshcsimmons wrote:
         | Silly take. Apply this logic to Rails and you'd look like a
         | fool.
        
         | joseferben wrote:
         | i mostly agree with your take, except that if you primarily
         | want to produce html going with a server-side rendered approach
         | might be simpler.
         | 
         | i'm building https://www.plainweb.dev/, which uses htmx + react
         | style components for templating.
        
           | amanvirk wrote:
           | Looks great! +1 for using JSX as a backend templating layer.
           | 
           | We played a bit with Kita too and its great
        
         | 0xblinq wrote:
         | So don't use their opinions, use mine.
         | 
         | 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.
        
         | gavmor wrote:
         | What are "heavy" vs "light?" Featureful middleware/plugin
         | ecosystem vs stdlib+process forking?
         | 
         | And/or are we talking minimum memory footprint?
        
       | holoduke wrote:
       | 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.
        
         | jatkindev wrote:
         | Curious, why do you say Node.js works best served directly
         | after a load balancer? Genuinely just wondering, never heard
         | this before.
        
       | begueradj wrote:
       | 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.
        
         | amanvirk wrote:
         | Heck. 3yrs is quite long. Ill drop anything that doesn't allow
         | me to ship daily
        
           | begueradj wrote:
           | 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.
        
             | amanvirk wrote:
             | That was sarcasm on your original comment that you have
             | edited 3 times.
             | 
             | Anyways, don't take it seriously and have fun
        
       ___________________________________________________________________
       (page generated 2024-06-20 23:02 UTC)