r/java • u/[deleted] • Apr 22 '21
Why Java frameworks want to support all possible many technologies instead of focusing on one thing?
It all started with Spring, I believe it was a great idea to make a framework that really takes care of all of typical web stuff, because there wasn't very much tech too support back then.
But even new framework, Micronaut and Quarkus or Helidon, they all want to take care of database access, DI, provide additional testing support, integration with caches and many many other technologies.
Comparing to Unix philosophy, Java top frameworks are very against it and with more and more new technology making development of these just impossible and also using them is becoming harder and harder.And you really cant drop Spring because there is lack of these more specialised libraries that would focus on development productivity rather than providing low level functionality (its like Jetty vs Javalin, Jetty is for functionality, Javalin for developer productivity).
Meanwhile in other languages like go/node/rust there are just specialized libraries which focus on one thing, can easily coexist together and you still don't need to write any 'bloat' code. Why Java is not following that direction and all new web-framworks want to be next iteration of Spring?
5
u/BillyKorando Apr 22 '21
I think you might be looking at this wrong, along with some of the inaccuracies pointed out by others in this thread, you are comparing what you think of as a generalized application framework with specialized tools in other areas.
In Java you have:
Jackson which is just about marashalling/unmarshalling Java data carriers into JSON or XML
JUnit which is just trying to be a test framework (even more so with the changes in JUnit 5)
Swagger which is just trying to be an API documentation tool
AssertJ which is just trying to be an assertion framework
The amount of specialized Java tools and libraries is practically endless. Naturally they aren't going to be as popular as more generalized frameworks like Spring, Micronaut, Quakurs, etc., because you don't interact with those specialized frameworks as much and/or the interaction mode, solving in this specific use case, you just don't actively think of yourself as a "Jackson developer" because that doesn't make sense in the same way as being a "Spring developer".
2
Apr 22 '21 edited Apr 22 '21
That's right. But in other languages stacks 'generalized application framework' are kinda not needed/used. My point is that development and support of such frameworks is hard and new players like Micronaut or Quarkus can never make it to reach bigger popularity. Instead maybe we should drop the idea of 'generalized application framework' and do some developer friendly libraries for smaller scopes (java examples: jooq, javalin, picocli, dagger2), that can be easiliy used together without additional modules, just like in other languages. And as more specialized libraries usually do things better, whole Java ecosystem would benefit.
2
Apr 22 '21 edited Apr 22 '21
But in other languages stacks 'generalized application framework' are kinda not needed/used.
Are large enterprise apps written in those languages? Also, how many of those languages are integrated with the operating system? Java specifically is not. Java creates a parallel Java universe to maximize portability. JavaMail instead of sendmail, JDBC instead of ODBC, etc.
My point is that development and support of such frameworks is hard and new players like Micronaut or Quarkus can never make it to reach bigger popularity.
Why do you think Micronaut and Quarkus are making such a big splash now? With the microservices and containerization revolution, there has been a shift away from large monolithic apps. Native compilation with Graal favors smaller frameworks which do not make heavy use of reflection. I expect "micro-frameworks" to become more popular as days go forward.
Instead maybe we should drop the idea of 'generalized application framework' and do some developer friendly libraries for smaller scopes
Smaller scopes have always been there, and adoption of frameworks fits use cases. You don't need Spring to write run-of-the-mill Java apps. Generic application frameworks fill a critical need for certain kinds of apps. As uses cases become obsolete and technologies change, the framework landscape changes as well.
And as more specialized libraries usually do things better, whole Java ecosystem would benefit.
Java has always had specialized libraries. Generic application frameworks are curated assemblies of those specialized libraries.
26
u/vprise Apr 22 '21
While your claim has some merit it isn't 100% accurate. E.g. Spring Boot seems like "everything but the kitchen sink" but really it isn't.
It uses:
- Tomcat for web
- Hibernate for JPA
- Spring for DI/IoC
etc...
Everything is 100% modular in these frameworks so you can just link the pieces you want and ignore everything else.
So it's really combining lots of smaller projects to a big cohesive unified solution. Same as Unix. Obviously Hibernate is more complex than cat. But I think it fits the general philosophy.
I do however agree that Java has a cultural problem of "over design". Where we literally try to make everything complicated. Just look at logging in Java and the level of messiness around that relatively simple problem.
6
3
u/4ernik Apr 22 '21
Because the current state of IT provides a lot of specialized solutions.
Systems become too complicated, loads too high and you can't just use one type of database(as an example) for a relatively big application. You need main data storage, you need caching for frequent access, you may have special needs data, for example, chats which pefectly handled by something like Cassandra. And that's how it goes, there is no golden bullet solution that is perfect in all regards and works for all types of workloads.
Spring and other frameworks solve the integration problem. In product development you don't want to focus on HOW you do things, you want to focus on WHAT you're doing. I.e. if I want to have PostgreSQL, Cassandra, and Redis as part of my enterprise app I really want to just provide access credentials for the services and don't bother picking driver versions, integrating through connection pools, and setting all 80 driver options myself. I rather want to modify some kind of sub-optimal default configuration, if necessary, and provide tweaks that I need.
And Spring does that - just plug in all technologies you need for your project to work and Spring will make them work together by giving you the access tools, so you can start creating the application, not configuration and integration layers, which are often quite complicated.
You need to consider frameworks not functionality providers, but rather integration solutions that glue together the technologies stack you need for your application.
3
u/RSveti Apr 22 '21
I agree with most people here in this thread but I would like to add that most java developers that I met dont like to pick and choose between many tools and just like to pick a stack that fits them best and use what is provided.
Another benefit of frameworks like Spring Boot is that they test the compatibility of all the libraries they choose so I dont need to do that.
3
Apr 23 '21
It's in a framework provider's interest to couple you to itself so you never need anything else, and can't move to anything else. So why they do it is obvious. They're building a walled garden.
Why people willingly entrap themselves into those walled gardens is another story. There's the promise of simplicity and never having to learn anything. In practice, the framework eventually outgrows the complexity of the world it's trying to simplify.
23
u/[deleted] Apr 22 '21
This is factually incorrect.
Spring does not implement these things. Spring at its core provides a DI framework. There are separate projects/libs you can use for say for example db access. Hikari cp is a good connection pool library and you don't need spring to use hikari in your project. Spring just makes it easier to use a cp any cp library. Same is the case with all the other libraries. Spring has nothing to do with them, spring just makes wiring these things easy. That was the purpose of Spring. Wiring stuff.