10 ms·
There's some great stuff on the JVM today, but Spring Boot is recapitulating all the problems of J2EE. Everything is extremely "decoupled" to the point that you
by lmm 6y ago
There's some great stuff on the JVM today, but Spring Boot is recapitulating all the problems of J2EE. Everything is extremely "decoupled" to the point that you have no idea where anything comes from or why, and just adding a new dependency to your classpath will radically change the behaviour of your application (oh, you added a dependency on a library that has a transitive dependency on the MongoDB client? Guess that must mean you want a MongoDB connection pool spun up and running).
I swear I'm going to add a bitcoin miner to my libraries and list it in spring.factories so that it autostarts whenever someone starts a Spring Boot application with my library on the classpath. There'll be an undocumented config property to turn it off or make it mine to a different address. That's standard practice with every other library that uses Spring Boot, so it's perfectly ethical, and it's not like anyone using Spring Boot would notice that their application was wasting a bunch of resources.
Maybe someone else did this already. That would explain a lot actually.
- reda-alaoui 6y agoI think too that Spring Boot opt-out autoconfiguration is an issue. Take a look at https://github.com/spring-projects/spring-boot/issues/25742#issue-835713980 https://github.com/spring-projects/spring-boot/issues/25742#... I included a workaround allowing to opt-in for autoconfiguration instead of opting out. I have used the filter for more than 2 years without issue.
- codr7 6y agoThis. I spent so much time this week chasing magic buttons in that over engineered piece of stink. I'd rather do raw HTTP servlets at this point.
- diroussel 6y agoEven servlet containers are the wrong approach. I have from experience it’s best to stick to libraries. You know where you are when you call a function. The Servlet spec now includes annotation scanning by default now, which is unnecessarily complicated and slows down start up.
- ianlevesque 6y agoThere's always https://javalin.io/ https://javalin.io/
- aww_dang 6y agoPlain servlets, jetty, haproxy for TLS, jstl, postgres, apache dbcp. Add in whatever specialty libraries for the project and you can pull away with 1/100th of the dependencies.
- doctor_eval 6y agoAgreed, though I’d also add MyBatis.
- theandrewbailey 6y agoI built a blog engine that almost has that stack (Payara instead of jetty, apache dbcp).
- dmux 6y agoYou can even pair that down a little further if you use the built-in HttpServer that's been in the JDK since 1.6.
- mustardo 6y agoTotally agree, why i use https://www.dropwizard.io/en/latest/ https://www.dropwizard.io/en/latest/ with guice, generally waaayyy more explicit about whats going on
- MrBuddyCasino 6y agoAnd it starts a lot faster. We used that combination at the last startup I was employed at, and it worked great.
- mustardo 6y agoYea no runtime classpath scanning is a requirement for me, we do compile time eclipselink weaving etc which makes startups way faster
- midrus 6y agoI used Dropwizard many, many years ago. It was what made me like Java. Such an awesome tool. I'm happy to see so many years later it is still alive and kicking and powering so many systems. We definitely need more of this.
- rococode 6y agoAlso very lightweight and pleasant to use are Javalin and SparkJava. I've used them for all kinds of projects with great results. Basically a Java version of Python's Flask - small and concise but stable and performant enough for many (or even most) web projects. https://javalin.io/ https://javalin.io/ http://sparkjava.com/ http://sparkjava.com/
- dmux 6y agoOur team has had a lot of success with both of these too. The single architectural choice I completely disagree with though is their use of Static methods to hook things together.
- tracer4201 6y agoI first used Spring while doing an internship in 2007. I remember writing about bunch of XML bean configuration and wondering.... why??? Sounds like the ecosystem didn’t get much better.
- misja111 6y agoI've been through the whole evolution from Spring with XML configuration to the current 'convention over configuration' approach of Spring Boot. I actually liked the idea behind the XML configuration when I first got to know Spring in 2007. With this you could decouple the composition of your application from the actual code. You could deliver a jar and the user could decide with his own XML which parts to use and which not, for instance if he wanted to use your software in test mode or if he wanted to use another database. Otoh, most people who were using Spring were just following the cargo cult and not using any of the freedom that XML offered, and then all the XML configs were just massive overhead. Then came Spring annotations. For the cargo cult followers this must have been a big relief. For those of us who really used the XML application configuration, the decoupling of code and configuration was now gone. There was still the option to use XML but it was frowned upon by the community. And finally there was Spring Boot. The advantage of Spring Boot is that if you just want all the default Spring choices you can have a full fledged service up and running in no time. This looks really nice in blogs and demo's. With 'convention over configuration' you only have to adjust the parts where you don't like the defaults. This might seem nice but if you're working on a larger software project this can quickly turn into a major headache. All kind of choices are made for you by conditional spring beans which you might not even know they existed, there can be complex conditions determining their behaviour that might change all of a sudden when you add a new jar to your classpath. Spring has one big advantage though. It is so very popular and widely used that as a Java developer you only need to get good at this one framework and you will get plenty of job opportunities for years to come. And the reverse is also true for employers: just choose Spring as your framework and you will have no problem finding new developers.
- jillesvangurp 6y agoThere's a next stage after annotations. The current thinking is to replace annotations with function calls. It makes more sense if you use Kotlin because Java is a bit verbose when you do this and in Kotlin you get to create nice DSLs. This cuts down on use of reflection and AOP magic that spring relies on and also enables native compilation. It also makes it easier to debug and it makes it much easier to understand what is going on at the price of surprisingly little verbosity. Kofu and Jafu are basically still experimental but work quite nicely https://github.com/spring-projects-experimental/spring-fu/tree/master/kofu https://github.com/spring-projects-experimental/spring-fu/tr... Another trend is native compilation. Spring native just went into beta (uses the Graal compiler). That still relies on reflection but they re-engineered the internals to be more native friendly. Spring Boot basically added the notion of autoconfiguring libraries that simply by being on the classpath self configure in a sane way. It's one of those things that makes the experience a bit more ruby on rails like. Stuff just works with minimal coding and you customise it as needed (or not, which is perfectly valid). Compared to XML configuration, Spring has come a long way. Separating code and configuration is still a good idea with Spring but indeed not strictly enforced. @Configuration classes can take the place of XML and if you use the bean dsl, that's basically the equivalent of using XML. Only it's type checked at compile time and a bit more readable.
- shipp02 6y agoThis. I tried to bootstrap an web flux application without spring boot or kofu or anything and you have to move thorugh so many different classes to get to the appropriate bean for the handlers that I just gave up. Also multiple simmilarly named classes like ``WebHandler``, ``HttpHandler``. I don't have much other experience so I thought it was just me. DI is also a pain and you never know where something is comming from unless you are familiar with what every single functions adds to the ``CONTEXT``.
- avodonosov 6y agoThat`s not spring boot, that`s whole spring (and google guice, etc), starting from the idiotic XML for bean wiring, to equally idiotic anntations, and finally, after 15 or how many years, they realized that plain java can be used for object creation. What a discovery! Still, they introduced @Configuration bullshit, etc. (There are cases when such features may be useful, e. g. systems that are extended by 3rd party plugins, like Maven, although may be done without that as well). For normall applications that´s nothing more than bloat and limitations. The problem that the majority of users follow cargo cults without understanding what are they doing. In result the ecosystem is full of bad practices. AbstactArgumentBuilderFactoryFactory were in fashion for the same reason. Otherwise Java is a neat little language and a good platform.
- abraae 6y agoWas "boolshit" a typo or is it a magnificent new pejorative?
- avodonosov 6y agoTypo :)
- chris_wot 6y agoAlso amazing new pejorative.
- Cullinet 6y agoah, I am promoted thus to reminisce upon my boolshitten youth spent vainly stabbing out crud most fervid and amorous to dump the vilest cores to jest with that naivest child me to know it better than to presume that my brittle logic could affect it so profoundly to do my bidding...
- bryanrasmussen 6y agoit's an amazing new type description where some shit is either true shit or fake shit.
- shipp02 6y agoI would like to draw you attention to vertx[1] its an eclipse project with well thought out API's and documentation and no magic. [1]https://vertx.io/ https://vertx.io/
- sreque 6y agoI felt strongly enough about this topic to write a full blog post: http://sreque.blogspot.com/2019/08/the-autumn-manifesto-why-spring-is.html http://sreque.blogspot.com/2019/08/the-autumn-manifesto-why-.... TLDR: so-called DI frameworks are really just frameworks for creating and consuming global variables and have very little to do with the actual principle in of DI. That said, I think the jvm and java the language are in a great spot. It's the frameworks and community that need a shift in mindset.
- lmm 6y agoI disagree with that blog post. It may be technically possible to hijack the classloader mechanism to make instantiating classes do dependency injection, but it's not easy or idiomatic, and it's not good for maintainability either; a reader can't tell the difference between a global service and a value object if both are just "new Foo()". DI, in the sense of separating the instantiation of long-lived service objects from the classes containing business logic that accesses those long-lived service objects, is a great thing for testability and maintainability. Autowiring mechanisms where you have some kind of global bag of (pseudo-singleton) services by type, and wire service dependencies implicitly by type rather than explicitly, are a legitimate tradeoff that's appropriate for some cases. Don't conflate Spring with Spring Boot. One is a framework that offers some legitimate value even if it makes some questionable tradeoffs; the other is a fractal of bad design.
- hderms 6y agoWhich one is the fractal of bad design?
- lmm 6y agoSpring Boot
- sreque 6y agoIn response to: "DI, in the sense of separating the instantiation of long-lived service objects from the classes containing business logic that accesses those long-lived service objects, is a great thing for testability and maintainability." You don't need a DI framework to do any of what you described. Also, I believe that what you are saying doesn't fundamentally describe DI, though it is related. In this post I go over what DI really means: https://sreque.blogspot.com/2019/09/dependency-injection-101.html https://sreque.blogspot.com/2019/09/dependency-injection-101... I have never seen a case where using autowiring forms a legitimate tradeoff; it has always resulted in worse, harder-to-maintain code with little benefit in return. I conflate Spring with Spring Boot because Spring Boot is built on Spring and most of my problems with Spring Boot apply equally to Spring.
- sz4kerto 6y agoThere's a very good reason why Spring is used so widely. Complex enterprise apps are often complex because the use case and the environment is complex. E.g.: - integration testing and unit testing is required - transparently pluggable backends for message queues so that locally you can use SQLite as your pub/sub storage but in production it's Google P/S - standardized health check endpoints for all your apps ... The list is infinite. You can make a decision for each point or you can agree with the team that you're using whatever Spring provides. In a team with 100 devs, simplifying and unifying decisions is extremely important. And Spring _works_. I don't like it either, but it works. The alternative is: solving all the problem that Spring solves with different tooling. And no, you can't avoid dependency injection in a 700 kLOC medical application, because you need to test the hell out of it.
- lmm 6y agoSpring proper is (relatively) fine; you can make applications with it that are more-or-less maintainable. Spring Boot is very different. It's a write-only framework, and while businesses may have enthusiastically adopted it, it's new enough that they haven't (yet) had to pay the maintenance costs and realise how bad they are.
- simmerup 6y agoWhat do you mean by write-only framework?
- nwatson 6y agoWOF == you understand your software while you're writing/developing it but give it a rest for a Trump's "two weeks" and you'll have no clue what you did.
- Pet_Ant 6y agoApparently Donald Trump always said "two weeks". I was unaware of this meme. * https://www.axios.com/trumps-timeline-always-two-weeks-1513302785-b6370a4f-bb5e-434a-80ca-1249c7cf2baa.html https://www.axios.com/trumps-timeline-always-two-weeks-15133... * https://www.bloomberg.com/news/articles/2017-06-06/in-trump-s-white-house-everything-s-coming-in-two-weeks https://www.bloomberg.com/news/articles/2017-06-06/in-trump-...
- stevoski 6y agoMy frustrating experience with J2EE and Spring is what led me to choose https://sparkjava.com/ https://sparkjava.com/ as the Java framework for my SaaS. The Spark framework is so light and refreshingly comprehensible. I can actually tell what's going on when a problem occurs.
- meddlepal 6y agoI used to really like Spark but the primary maintainer seems to go through periods of disinterest. I switched to using Javalin https://github.com/tipsy/javalin https://github.com/tipsy/javalin which was built by one of the top Spark committers a few years back.
- spullara 6y agoFriends don't let friends use Spring*.
- eitland 6y agoIt is telling that today modern JavaEE is in many ways a breath of fresh air compared to Spring :-|
- pjmlp 6y agoOne of the best decisions I have done, when I need to use my Java hat, is to have kept using JEE. Spring even needs a web app to help configure its pleothora of behaviors.
- reactor 6y agoThis 'magic' is one of the reason why we switched to https://quarkus.io/ https://quarkus.io/ Couldn't be more happier.
- a_imho 6y agoI simply don't understand how people favor a stringly typed custom DSL in a reasonably typed language like java. Why is it better to write Spring annotations instead of actual java code? There is literally no upside.
- dmux 6y agoOne possibility is that the code is just Java and the end of the day. You could run it independent of Spring processing the annotations.
- lmm 6y agoAnnotations are fairly typesafe. The parts that aren't safe are parts that Java offers no way to do at compile time (e.g. "are all the arguments to this constructor of types that are in this set of existing services?")
- selfhoster11 6y agoI read a comment once, saying that Spring is a lot like the COMEFROM statement [0]. You are in a class, but you have no idea how you got there, or how to get somewhere else. Your IDE is no help, because everything is "decoupled". [0] https://en.wikipedia.org/wiki/COMEFROM https://en.wikipedia.org/wiki/COMEFROM
- laurent92 6y agoI’m just learning about the COMEFROM statement, this exactly captures my reluctance with very modern apps. I especially despise checking permissions or caches using annotations, because you are never sure they are applied. I hope one day COMEFROM is as forbidden as GOTO.
- geodel 6y ago> I swear I'm going to add a bitcoin miner to my libraries and list it in spring.factories That will be great service to this world. Considering endless turds Spring/Boot generates at runtime, bitcoin mining might most ethical thing to do.
- ralmidani 6y agoAs someone who loves Python/Django, dabbled in Ruby/Rails, learned a multitude of front-end JS frameworks (Backbone, React, AngularJS, and Ember), and currently works with Java in an enterprise environment, I just want to add two points: - If you're going to have config/setup files, make sure they utilize a language that is Turing Complete. YAML looks pretty, but for all practical purposes, is it really better than XML? - I've said this before, and I will say it again: I doubt writing an import statement ever killed anyone. Edit: the two points are related. Having a Turing Complete config/setup file makes it easier to add a level of indirection between your code and library/framework code, so you can e.g. utilize different implementations for different ENVs.
- jrochkind1 6y agoXML is not any more or less "turing complete" than yaml, is it? They both express static data structures. I suppose you can make turing complete languages that use the syntax of either one (XSLT is one; i'm sure there are others in YAML), although it gets pretty iffy.
- ralmidani 6y agoI agree, static data structures are far from ideal. Practically speaking, there's not much more you can accomplish with YAML or JSON compared to XML, even if some people find the syntax more palatable. Also, trying to shoehorn conditions and loops into a non-Turing Complete language is cumbersome. I would imagine it being a nightmare for platform and framework maintainers, as well. Rather than create a config or dependency DSL for every platform, why not just put the language to work for you?
- jrochkind1 6y ago> there's not much more you can accomplish with YAML or JSON compared to XML, even if some people find the syntax more palatable. Sure, and vice versa. I think there are arguments to be had for whether you want your config language to be "turing complete" (or in general capable of containing logic or just static data). I am not sure I am convinced. But you seemed to be saying that XML was preferable to yaml for some reason related to turing completeness/logical power, which I'm not seeing. You can "shoehorn" conditions and loops into YAML or XML if you want (by defining a semantics on top of either one), and it's going to be cumbersome, yup.
- jrochkind1 6y ago> Everything is extremely "decoupled" to the point that you have no idea where anything comes from or why, and just adding a new dependency to your classpath will radically change the behaviour of your application What does "decoupled" even mean anymore? That sounds like the opposite of "decoupled" to me. (/not a Java programmer).
- Koshkin 6y agoI guess it means that dependencies are hidden now.
- awild 6y agoEverything is wired up using Dependency Injection. So you just state your claims and are given appropriate objects that may be created by some third party factory factory. It's really neat until it isnt.
- superbaconman 6y agoIt's there an unspoken rule about how much dependency injection is too much dependency injection? Like I can see how it could get bad, but how do you know when you've gone too far?
- awild 6y agoProbably as soon as you don't know why an object appears in your tree. I'm not at all an expert on Di as the only project I worked on that used it a lot, I was also responsible for refactoring it such that spring di was only optional by annotated constructors, because spring startup is atrocious and we wanted to use part of the application in lambda. I've not used it since because the project I inherited suffered extremely from nih syndrome.
- lmm 6y agoThe logic seems to be that having X use Y if it's available at runtime is less coupled than having X hard-depend on Y at build time. But IME the end result is similar to a "distributed monolith": you haven't actually decoupled it, you've just swept the coupling under the rug.
- zokier 6y agoI feel like spring got leapfrogged by plain javaee a bit; I can imagine that in early '00s Spring was big improvement over Java EE 1 .4 or whatever but modern Java EE to at least some degree caught up, JEE 8 and 9 being relatively pleasant to work with, along with Microprofile, while Spring feels more stuck in the 00s feel.
- agumonkey 6y ago> "Gosling".equals("Satoshi") true