in reply to Re^2: Perl microservice framework
in thread Perl microservice framework

I'm going to go out on a limb and guess that Mojolicious is lighter-weight (from the coding perspective) than anything that has ever been developed in Java. You can literally write the entire app in a single file, with nice descriptive REST URLs. You don't even need any directory structure.

Here's an example Mojo app that serves a Powerpoint/Keynote-like experience (including navigating the slides from a device the presenter is holding) out of a single HTML file that you pair with the controller.

Here's another single-file app (aside from served assets) that implements a multiplayer Asteroids game, currently hosted live at https://nrdvana.net/asteroids/. I showed that off for my presentation back in 2019 and then it uses so little resources I never bothered to turn it off. It uses 12MB of RAM currently, and lives in a docker container. (I also never bothered to finish it, as there are currently no asteroids or collision detection, heh. It's just a tech-demo of websockets)

Java has a strong need for "lighter weight" because their default framework stance is "500 layers of abstraction". I see Springboot's home page advertising "you don't even need any XML" and it made me chuckle. I did quite a lot of Java in college, and eventually grew to hate it because while the structure of the type system felt nice, it takes forever to get anything done, and you have to learn about each of those layers of abstraction. It would not surprise me if Catalyst (perl's heaviest web framework) was lighter to develop with than Spring. (again, I have no experience with Spring. Tomcat+Servlets were the lightest option at the time I stopped using Java)

It all comes down to what you want the framework to accomplish for you. Catalyst is a structured framework like Ruby on Rails, and by default comes with a directory layout and a config file (but you can technically still do single-file apps with it). Dancer and Mojo are lighter than that, and let you opt-out of most of the extras. Mojo is special in that it was designed for event-driven code, so you can have a single perl process serving lots of clients instead of a giant pool of Perl processes. It also has the event-friendly database drivers like Mojo::Pg. Plack is so light you can barely call it a framework. Whatever level of "lightweight" you want, Perl has it. But then you finish with "I would prefer not to cobble bits and pieces of disparate Perl technologies to build a microservice architecture" ... but then we come right back to the question: what do you expect the microservice architecture to accomplish for you? And if *more* features are your goal, then why are you averse to a normal web framework?

Replies are listed 'Best First'.
Re^4: Perl microservice framework
by mvanle (Acolyte) on Dec 24, 2024 at 05:18 UTC
    Well, I like the idea of having batteries included. I don't have the luxury of time to dabble with too many different options and with their respective ways of doing things (eg. I don't have time to learn both Catalyst and Mojolicious).

    Deciding on a particular stack or framework, and then switching later can be expensive. So I prefer to leverage upon the time and knowledge invested in one good thing that can [ideally] do everything.

      I think you're looking for Mojo, then. Mojo comes with its own event system, so you don't need to change anything later if you decide to do something event-driven. The toolkit all installs as a single dist, so you don't have to worry about version conflicts. Everything in the Mojolicious dist follows a common pattern for objects and minimalism. It's a very capable web framework, but also my first choice for microservices. There's also the separate Minion dist which pairs with Mojo and lets you do long background processes without disturbing the web request processing.
      Well, maybe you should have the "luxury of time" to find out what you need and what you want first?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

        I have already provided an example for a basis for comparison with Spring Boot, with REST as a use case, and stated a preference to avoid having to deal with disparate Perl projects that were not originally designed for microservices architecture (albeit they can be used as such).

        Java has well-understood and popular ecosystems for web and microservices with clear goals for different projects (eg. the need to extend Spring with Spring Boot, and others like Quarkus and Micronaut that tailor to different developer preferences).

        As some people have helpfully pointed out, Perl offers projects that can satisfy aspects of microservices:

      • Catalyst promotes convention over configuration (a style of Spring Boot)
      • Mojolicious is event-driven, can run standalone instances (a feature of Spring Boot)
      • Plack is light weight (the need for Spring Boot)
      • Myraid is unclear to me what it coordinates (my guess is BPM or deployment orchestration, or some kind of burst scaling tool)

        but this is precisely the kind of disparateness I want to avoid where there is no complete unified solution.

        A CPAN search shows projects that come close are apparently primarily only intended as management tools (as opposed to frameworks) (eg. BeeKeeper, Myraid, Narada).

        Judging on the responses received thus far, I believe that Perl has no specific microservice framework.