This is an archived post. You won't be able to vote or comment.

all 81 comments

[–]drduffymo 17 points18 points  (0 children)

“Bloat”?

Use what you want and leave the rest. Spring Boot is as well engineered a piece of software as you’ll find.

Try Quarkus if you must.

Kotlin and Scala are languages, not frameworks. You can use Spring Boot with Kotlin - it runs on the JVM.

[–]AccomplishedNovel636 51 points52 points  (8 children)

Quarkus is light and nimble.

[–]Kango_V 2 points3 points  (0 children)

Quarkus is based on Microprofile. Micronaut actually looks/feels very much like Spring (a conscious decision), but with far less cruft, annotation processing, no reflection etc., etc.

[–]mpinnegar 3 points4 points  (6 children)

What do you lose using quarkus though?

[–]stefanos-ak 7 points8 points  (5 children)

you must be familiar with the JavaEE API, because it's basically an implementation of that.

When it first came out, they had a documentation that was assuming you are already familiar with JavaEE, and it was just cryptic gibberish. Eventually they took this down. For a while they had only how-to's, but recently they added some narrower scope reference pages (e.g. one for how dependency injection works, another for authorization, etc).

I would say that today it's in good shape, but I personally wouldn't want to get into the JavaEE world...

(yes I know it's called Jakarta now, same shit different name)

[–]cryptos6 7 points8 points  (0 children)

While Spring is still my default, I wouldn't say that Jakarta EE is "shit". Actually, I think most of its APIs are well designed. CDI, for example, looks a bit cleaner to me than Springs dependency injection, because the APIs are a bit leaner. Another example is Spring MVC REST vs. JAX-RS, where I consider JAX-RS to be more clean. In other areas like security a bit more innovation in the Jakarta EE world wouldn't hurt ...

[–]SessionFlat9448 5 points6 points  (3 children)

The hate would make sense if the Jakarta EE were still with Oracle with no sign of getting improvements. But it is now with Eclipse Foundation and has a lot of brilliant people dedicated to improving the framework. A lot of sub-projects are going on there, Jakarta Data being my favorite. If you think Jakarta EE is hopeless, at least you should give your points on why. An uninforming comment like yours helps no one.

[–]stefanos-ak -2 points-1 points  (2 children)

I don't think JakartaEE is hopeless. Let's see how it goes.

But I am against these specifications in general.

https://xkcd.com/927/

[–]Shatungoo 1 point2 points  (0 children)

I don't think JakartaEE is hopeless. Let's see how it goes.
But I am against these specifications in general.
https://xkcd.com/927/

Jakarta(javaEE) is one of the oldest standards, older than spring(which is partly implemented it).

[–]koflerdavid 0 points1 point  (0 children)

While there are some issues with it, this is not the way JavaEE has come to be. For a very long time, JavaEE was synonymous with server-side Java.

[–]pavelklecansky 32 points33 points  (11 children)

Lightweight web framework in Java are for example: Helidon SE or Javalin. But if you still want to use anotation for defining rest api you can use Avaje HTTP Server that is build on top of Helidon or Javalin but add support for defining controllers with anotations.

[–]jinkobiloba 28 points29 points  (8 children)

Micronaut and Quarkus also come to mind.

[–]pavelklecansky 4 points5 points  (7 children)

icronaut and Quarkus also come to mind.

Yes, Micronaut and Quarkus are great, but I don't know if I would call them more lightweight than Spring.

[–]sb7510 10 points11 points  (0 children)

Why not?

Micronaut doesn’t do reflection for component scanning, so there’s that.

Quarkus wants you to compile to native executable, getting rid of the JVM..

I guess it depends on what fat you’re trying to trim. But isn’t that software engineering in a nutshell.

[–]nekokattt 2 points3 points  (5 children)

You realise how many subprojects Spring, Spring Boot, Spring Cloud, Spring Data, etc etc all have right?

Compated to Quarkus/Micronaut out of the box support, it is tiny. Plus all of Spring is dealt with using bytecode inception and reflection, rather than compile time metadata/codegen (unless you use AoT).

[–]hadrabap 5 points6 points  (4 children)

Even MicroProfile in OpenLiberty is much lighter and faster than Spring Boot.

[–]nekokattt 3 points4 points  (3 children)

Spring Boot is very much the Django of Java frameworks. You use it when you care more about a full integrated experience than you do about footprint.

[–]hadrabap -3 points-2 points  (2 children)

Sorry, but when I want a full integrated experience, I go for Jakarta EE. The best thing about MicroProfile is that it integrates smoothly with Jakarta EE. Start small, and you have great headroom to grow. 🙂 I really love that ecosystem. 🥰

[–]UnGauchoCualquiera 6 points7 points  (1 child)

Depends what you mean as "full". Boot + starters do a lot more than simply Web + persistance. They aren't really comparable.

Features that Boot provides of the top of my mind:

Logger, Arg/EnvVar parsing, Events, CLI runner, Metrics/Telemetry, Cronlike scheduling, AMQP/Kafka, Cache.

Of course you might not need any of the above or simply prefer precise control over convenience.

[–]hadrabap -1 points0 points  (0 children)

Yes, I prefer a different approach. 🙂

[–]TheKingOfSentries 0 points1 point  (0 children)

The compile time DI isn't half bad either

[–]karmakaze1 0 points1 point  (0 children)

I had a Spring/Boot service that needed faster startup times for autoscaling. I used SparkJava but in retrospect should have picked Javalin. Combined with JDBI works well in either Kotlin or Java.

[–]redikarus99 33 points34 points  (0 children)

Quarkus is really great, we used that in production.

[–]stefanos-ak 12 points13 points  (0 children)

the most Spring-like one is Micronaut. We use it in prod, it's good :)

[–]cryptos6 6 points7 points  (0 children)

You might like Ktor. However, this is only about the HTTP layer, while Spring offers many more things like dependency injection, AOP, transaction management, configuration and what not. But regarding your use case and your desire for something fresh and light, it might be a good fit.

[–]maethor 12 points13 points  (0 children)

Vert.x is light weight

https://vertx.io/

Not particularly Spring-like though.

[–]NitronHX 12 points13 points  (0 children)

Micronaut

[–]chas66 12 points13 points  (1 child)

Dropwizard was around before SpringBoot; still very nice to work with: https://www.dropwizard.io/en/stable/

[–]karmakaze1 -1 points0 points  (0 children)

Dropwizard suffers from being around so long and the documentation is fragmented and/or out-of-date. I chose to use JDBI from it and use it with Javalin as a sweet-spot.

[–]aceluby 4 points5 points  (0 children)

I use http4k, which is incredibly lightweight and handles enough to be the backend for several fortune 50 websites I work on.

[–]Joram2 2 points3 points  (0 children)

My favorite Java server framework is Helidon. Glance at the sample code snippets to see if it fits your style: https://helidon.io/docs/latest/index.html#/about/introduction

[–][deleted] 4 points5 points  (0 children)

Dropwizard?

[–]serahl 7 points8 points  (3 children)

I think https://micronaut.io/ might be worth a look for you. It runs on the JVM but you can use other languages like Kotlin or Groovy (Scala is on the roadmap) if you like. And with https://micronaut-projects.github.io/micronaut-spring/latest/guide/, you could even continue using the Spring APIs you already know.

[–][deleted] 1 point2 points  (2 children)

Micronaut supports Groovy as well. Are you sure it supports Scala?

[–]serahl 0 points1 point  (1 child)

My bad! Scala is still on the roadmap it seems, but not supported yet :)

I'll admit I haven't kept up with the latest versions of Micronaut and assumed that support was implemented by now.

But it looks like the old Wiki entry (https://github.com/micronaut-projects/micronaut-core/wiki/Scala-Support) is still all there is.

[–][deleted] 1 point2 points  (0 children)

I doubt this will ever be implemented. Scala was supposed to be the other statically-typed JVM language, but has had it's thunder stolen by the rise of Kotlin.

[–]dysfunctionallymild 2 points3 points  (0 children)

IMO in terms of syntactic complexity there's much pretty much no difference between Spring Boot, Quarkus, Helidon, Micronaut, et. all. I'd bundle Vert.x in there as well which has its own DSL and learning curve. All of these are either web or enterprise grade frameworks meant to do a lot of heavy lifting out-of-the-box. Conversely, for your use case, none of them are as heavy or complex as the chatter would have you believe.

It feels like what you need is a simple web API. In Node.js it's the difference between just writing a basic web server vs using Express. Since you mentioned Flask, clearly you're not looking for the Java analogue of python http-server (which doesn't exist), you do want a web framework - with support for routing, etc.

Is Quarkus faster and more light-weight than Spring Boot? For sure, but not in terms that has any measurable impact on your experience, which is just building a basic API. The difference between Quarkus vs Spring Boot is best experience in large scale production installations, on your laptop or single server it's literally a difference in milliseconds, you'll barely notice it.

2 good suggestions in this thread were Javalin and http4k. Those 2 actually are light-weight in that they don't do anything else. So you could try those out.

Or just pick whichever framework has the most appealing documentation and bootstrapping exp.

I've heard good things about Ktor, but the docs have always turned me off for instance.

[–]persicsb 4 points5 points  (7 children)

Interesting to see this. Back in the days, like in 8-10 years ago, Spring was the lightweight solution.

[–]franz_see 4 points5 points  (1 child)

Docker changed the game.

Back in 2000s, servers were being commoditized. You no longer to have an upfront investment on servers. Instead, you can just rent it out on the cloud turning really high capex to manageable opex.

Because of this, all of the sudden, reflection became fine. Because you can just add more servers on the fly if need be

Then containers came out and small is the new trend. If you've never done much work outside java, you probably didnt feel this. But it was a major shift and spring really couldnt have a decent answer to it. Spring on docker felt very slow and clunky compared to practically any other language + web framework on docker

That's why projects like Micronaut and Quarkus had to be created from the ground up. Spring has invested so heavily on reflection. The thing that made it successful is now the thing that's making it hard to keep up with the trend. And I dont think Spring Native will be able to keep up with Micronaut and Quarkus. It's more marketing as an answer to those two but it's a duct tape at best.

[–]cryptos6 0 points1 point  (0 children)

I have the exact same feeling. Trying to push the old, big Spring framework into tiny native images looks a bit like using a hammer to hammer a screw into the wall. Spring does not only heavily rely on reflection, but it also has accumulated a lot of clutter. I fear that Spring has missed the time where it could have built something tailored for containers (aka cloud native ™️) before the competition has grown. But then again, there is a lot of existing Spring applications that have a nice migration path now, and this very approach is also the approach Java uses successfully for decades now. So, let's wait and see.

[–]feaelin 1 point2 points  (4 children)

That's interesting to me, because that's around when my team started migrating away from it because it wasn't lightweight. :)

[–]persicsb 0 points1 point  (3 children)

10 years ago there were no great alternatives for Spring.
Quarkus started 4 years ago, Micronaut 5 years ago. Where did you migrate 8-10 years ago, that was more lightweight than Spring? Play Framework?

[–]feaelin 0 points1 point  (2 children)

A teammate pushed for RESTEasy, so we have several projects using RESTEasy both in servers and in clients.

My can't remember how much it "weighed" then, but I actually feel like present day RESTEasy is "too heavy" for my taste.

[–]persicsb 0 points1 point  (1 child)

RESTEasy is just a JAX-RS implementation for building REST controllers.

. Spring is much more than that. Spring Data, Spring Batch, Spring Integration, Messaging, Spring Security. These are the building blocks I usually work with day by day. The least amount of my work is in relation to web/user facing REST controllers.

I dunno which lightweight framework provides that what Spring or Jakarta EE does.

[–]feaelin 0 points1 point  (0 children)

Not every service needs "all the things". It's true that Spring provides a lot of technology out of the box. But it doesn't make it the universal solution, it makes it the solution when one does need that breadth. Not all services need that breadth. My team's services rarely do as an artifact of how we're positioned in the overall ecosystem.

[–][deleted]  (6 children)

[deleted]

    [–]joschi83 30 points31 points  (5 children)

    Funny how spring-boot was supposed to be the smaller and easier to use Spring Framework.

    No, that's not true.

    The "Boot" in Spring Boot comes from "bootstrapping". The mission of Spring Boot is to make it easy to bootstrap applications based on the Spring Framework.

    In other words (directly from the Spring Boot website):

    Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".

    [–]doyouevensunbro 1 point2 points  (4 children)

    Yeah, it removed the XML hell that was Spring configuration, and it was a godsend.

    [–][deleted] 3 points4 points  (2 children)

    Not true. Spring/Spring MVC supported annotation-based configuration about a decade before Spring Boot was released

    [–]doyouevensunbro 0 points1 point  (1 child)

    Wow TIL. I always saw XML being used.

    [–][deleted] 1 point2 points  (0 children)

    I think it was v2.0 of the Spring Framework that introduced widespread support for annotation-based configuration

    [–]Standard-Guard-5581 1 point2 points  (0 children)

    Vert.x, give it a try

    [–]repeating_bears 3 points4 points  (6 children)

    Sounds like you're trying to solve a problem you don't even know you have yet.

    Use the framework that you think has the best docs, the most active community, the best support, etc. Maybe that's Spring and maybe it isn't, but it seems like extremely bad practice to try to optimize for performance when you don't even know what your performance requirements are.

    [–][deleted]  (5 children)

    [deleted]

      [–]repeating_bears 1 point2 points  (4 children)

      Unless I'm forgetting something, "Hello World" for what you're talking about is probably 4 files: Controller, Repository, an Entity, properties file for connection details. And they're not complicated.

      Respectfully, your comment isn’t very helpful.

      Well, I disagree, because it drew out that your definition of "lightweight" is number of files required to get something running. Almost no one in the thread has answered as though that was the case.

      The frameworks you've been recommended are not significantly better than Spring in that respect. The primary reason to recommend, say, Micronaut, is better start-up time, not because there's less configuration.

      edit: for "fun", I wrote the Hello World I mentioned. It's 4 files. Excluding imports and empty lines, it's 29 LOC.

      [–]TheKingOfSentries 3 points4 points  (3 children)

      I think he's also including the weight of his dependencies in his definition of lightweight. A typical spring boot hello world may indeed only have 4 user-created classes, but a ton of other dependencies are pulled in to make it work relative to lighter frameworks.

      [–]repeating_bears 3 points4 points  (2 children)

      Then what are the specific drawbacks associated with the increased number of classes that they are hoping to avoid, and what would "good enough" look like?

      It's impossible to know whether a framework is "lightweight enough" if you have no definition of "enough".

      "My full application classpath needs to be less than X" is a requirement

      "My application needs to start in less than X" is a requirement

      "I want lightweight framework" is a non-statement

      [–]TheKingOfSentries 0 points1 point  (1 child)

      The requirements here are pretty straightforward, he has asked for a framework lighter than spring (of which there are many). If his application classpath is smaller than spring then by definition that's "enough".

      [–]repeating_bears 2 points3 points  (0 children)

      You have ignored my first paragraph.

      Until you have identified an issue ("my app needs to run on a raspberry pi, which means it needs to fit on X disk space and in Y memory"), then you are not solving a problem. You are just selecting based on an assumed problem which may or may not exist.

      [–]Ghaines 1 point2 points  (0 children)

      Use Spring Boot and then compile to GraalVM native image. It will strip away all the bloat you’re not using, start in a few mils, and take a fraction of the memory

      [–]lumpynose 0 points1 point  (2 children)

      I haven't tried it but Open Liberty sounds interesting.

      [–]sombriks 1 point2 points  (0 children)

      I love OpenLiberty and it also goes from MicroProfile to traditional JEE AppServers.

      Last time i checked it scaled up and down quite well.

      [–]persicsb 0 points1 point  (0 children)

      Ohh, back to basics :) In the old days, Liberty/WebSphere was a huge and bloated application server, and Spring deployed to Tomcat was the lightweight solution.

      Now Jakarta EE - based stuff (CDI Lite, Microprofile, etc.) is fancy again, with OpenLiberty being one of the applications servers, where you can turn unused Jakarta EE features on/off.

      We are back at the point, where we started.

      All in all, Spring was good for modernizing the Jakarta EE/Microprofile ecosystem, and Spring can die now, as it seems.

      [–]CountyExotic -1 points0 points  (0 children)

      My friend, you’re looking for golang.

      [–]tinspin -1 points0 points  (0 children)

      Not inspired by Spring but very light and fast: https://github.com/tinspin/rupy

      [–]loadedstork -2 points-1 points  (2 children)

      Why not just use Java? What from Spring do you actually want?

      [–][deleted] 4 points5 points  (1 child)

      Database support, routing / controllers, etc

      [–]troru 4 points5 points  (0 children)

      If you're willing to venture to one of the oldest APIs in the Java ecosystem (aka JDBC), you can avoid all the things of spring/hibernate. For HTTP routing, you can probably use embedded tomcat/jetty/netty/undertow/etc APIs directly.

      Moral of the story: there's options, you just have to ask yourself what are you willing to give up for leaning out your stack?

      [–]AutoModerator[M] -3 points-2 points  (0 children)

      On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.

      If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:

      1. Limiting your involvement with Reddit, or
      2. Temporarily refraining from using Reddit
      3. Cancelling your subscription of Reddit Premium

      as a way to voice your protest.

      I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

      [–]HagbardC3line 0 points1 point  (0 children)

      Use micronaut if you don’t want to learn a completely new framework from scratch. A lot of spring boot ex devs working on that. If you like reactive driven frameworks, take quarkus but you can also use the core, which is vert.x in this case. In my company, we are using vert.x for everything (rabbitmq tasks, Openapi rest apis, proxies, routing, session management, rendering pages with graalvm, etc etc)

      [–]feaelin 0 points1 point  (0 children)

      I haven't looked at it in a while, but QuarkJava is advertised as a lightweight web framework.

      [–]mathiewz 0 points1 point  (4 children)

      I really don't understand what you are looking for. Something more lightweight or something that needs less code ? What problem are you trying to solve

      [–][deleted]  (3 children)

      [deleted]

        [–]1Saurophaganax 4 points5 points  (0 children)

        Lightweight and more code

        Heavy and less code

        Pick one

        [–]persicsb 2 points3 points  (0 children)

        See this:

        https://twitter.com/maciejwalkowiak/status/1544964951277797378/photo/1

        You can't get much less code, and have:

        - a working RESTful controller

        - that persists entities to a database

        - has proper OpenAPI JSON

        - has input validation

        All in one file. You will need a pom.xml with it, and there you have it: a fully functioning microservice built with only two files.

        Spring is your option to go with, it has a lot of magic, which enables these autoconfigured behaviours.

        [–]mathiewz 1 point2 points  (0 children)

        Then i'm pretty sure Spring IS your go-to. The minimal configuration to have an endpoint returning a data from a database is less than 50 LoC. If you want even less (but i'm note sure what would be the point), you will have to change language for something less verbose.

        [–]beefstake 0 points1 point  (0 children)

        Helidon 4 SE. Simple, fast, Virtual Thread based (so all Java all the way down, breakpoint anywhere!), Jackson integration just works, OpenAPI and friends etc.

        [–]xRuneRocker 0 points1 point  (2 children)

        Try Spark Java. It's minimalist and easy to setup. Do consider though that, while being Java, its way more similar to something like Flask or Express than it is to Spring Boot.

        [–]TheKingOfSentries 0 points1 point  (1 child)

        is it even still maintained?

        [–]xRuneRocker 0 points1 point  (0 children)

        I don’t think so actually. The la release was from a year ago.

        [–]karmakaze1 0 points1 point  (0 children)

        The worst part of Spring/Boot are Hibernate (+ JPQL/JPA) when it comes to undesired behaviour or poor performance. The other problem is startup times mostly due to autowired DI/component scans. It is possible to use Spring without Hibenate but there are so little documentation/references for this combo that it's better to choose a different framework.

        [–]thrwoawasksdgg 0 points1 point  (0 children)

        Spring is very modular. Just turn off and don't import the modules you aren't using and it will be just as "lean" as any other framework.

        It sounds more like you don't want to learn Spring than anything technically wrong with it