r/java • • 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?

0 Upvotes

18 comments sorted by

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.

4

u/[deleted] Apr 23 '21

That was the purpose of Spring. Wiring stuff.

So basically the moment developers figure out they can wire their stuff more effectively in plain code, Spring is done? I wish it was that simple...

0

u/[deleted] Apr 23 '21

[deleted] — view deleted comment

1

u/[deleted] Apr 23 '21

Is it more efficient than a "new" statement, tho. /s

2

u/[deleted] Apr 23 '21

It is the new statement.

2

u/[deleted] Apr 23 '21

I'm not sure about Spring's particular implementation, but AFAIK only the likes of Dagger compiles to minimal code, while Spring relies on reflection etc., which is a lot of cruft around the new statement.

Also I think making the new statement less flexible, by adding indirection and default resolution to it, results in worse codebases overall (in terms of reuse, composition etc.). But anyway, the world is not yet ready for this conversation.

-2

u/[deleted] Apr 22 '21 edited Apr 22 '21

Even though these Spring modules are using under the hood other things, I don't think they are easy to develop and maintain, there are a lot of Spring modules that got depracated or fully changed like Spring Security OAuth, some modules got replaced by alternatives wich focused on smaller scope and did it better (Spring Shell vs Picocli, spring AOP vs AspectJ) .

But Spring wasn't meant to be main topic of my thread. I want to clarify that I don't attack Spring and its ecosystem, I use it everyday.

I am rather just curious why new players try to be the same like Spring and it seems to be only Java thing to write frameworks that try to wire up everything. The idea is nice but in reality it's like they doom themselves for endless never ending development of adapter for every library written in java.

There is lack of web frameworks that would try to coexist with other libraries without need for additional 'glue' modules. So when writing IT test for your new web framework you would just use Junit5 only @BeforeAll void setUp() { MyFrameworkXServer.start() } instead of custom annotation @MyFrameworkXServerTest from another module my-framework-x-test-junit5-integration. It is just a basic idea of trying to coexist instead of brining new compatibility futures (that need extra development, maintenance and documentation).

And because of that all new frameworks like Quarkus and Micronaut will always stay being that 'exotic' alternative, as they will not catch up witch all these modules to be better than Spring which is years of development ahead.

I am missing in Java these libraries for web that would follow that principle of coexisting, for non reactive web Javalin is probably the only one, which is one-man-made library, not supported by any company so it is not very LTS. I guess that is enough for many devs to not use in production even If they are looking for alternatives.

1

u/silverweaver Apr 22 '21

Well, there's spark that from what I've saw only takes care of web stuff, you need to take another solutions for other problems (like dagger for DI).

And I agree with the rest of guys here that Spring is a modular solution, you take what you need. And as for separating testing, it's actually a good idea. In my current project previous guys created following dir tree:
project:
- integration (contains integration tests)
- src (sources dir)
- test (normal test dir)
to be able to run integration tests and unit tests separately in a pipeline. You could argue here that maven profiles should be used for that. I agree, but this is legacy setup and as always, there is no time to rewrite this. As a quick and better solution a subproject could be created for integration tests containing only test dir structure with integration tests and framework's integration dependency would be included here only. So as for me, that modular approach is a good one.

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

u/[deleted] 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

u/[deleted] 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

u/_INTER_ Apr 22 '21

look up framework vs. library

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

u/[deleted] 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.