This feels like "Mongodb is webscale". What specifically does Spring do better than its competitors?
This feels like "Mongodb is webscale". What specifically does Spring do better than its competitors?
- If I'm building a web service I can choose if I'm using a thread based sync approach or a reactive non blocking approach.
- Extremely opinionated and well thought out configuration management. Think of Viper from Go, or config with Pydantic from Python, just turned to 11.
- I can add support for many different data stores directly with the framework. Psql, Elasticsearch, Cassandra... the list goes on.
- Making critical sections of code, especially around data stores can usually be made transactional with a single annotation and managing the lifecycle of that transaction is similarly convenient.
- Robust caching solutions that are brain dead easy to add. I stress the robust adjective.
- Built in health metrics and ability to refresh configuration while running and rewire itself.
- Can speak OAuth2.0 out of the box.
- You can connect the logger with a little bit extra configuration to additionally spit logs out to something like Kafka with no extra code on your part.
This list alone doesn't seem super impressive but having built on things like Python+FastAPI, Node+Express/Hapi/Apollo, and Rust+Actix, while you can do all of these things, they are not generally just there, ready to use, and suitable for production.
My bread and butter used to be Spring-Boot w/ Lombok and I could take a service from inception to running in prod with fewer lines of code than I currently can with Python and FastAPI.
Extra Note: There will always come a time when developing with spring where you will shout to the high heavens about something the framework does a particular way or something you misunderstood. That is part of the pain of when the framework does so much for you.
Specially it has builtin caching, transaction management, DB access etc. But it connects to many external services for all of those seamlessly. It abstracts all the layers so you can easily replace everything under the hood with full compatibility as your business grows.
Aren't these mostly features of your data layer e.g. Hibernate?
> It abstracts all the layers so you can easily replace everything under the hood with full compatibility as your business grows.
Java is a perfectly capable language for implementing abstractions. What does Spring offer you there that you can't do with plain old Java?
It provides encapsulation for all of these elements that you don't have to do on your own.
A concise framework where all components talk the same language across the full stack.
Spring is many things, but it's not a "concise" framework by any means.
Well nothing. Since Spring it written in Java, anyone else using Java can do all of those things.
The things is Spring already does all these things and it does them well. It's well tested and well supported. Most people don't want to do all of this from scratch. So they need a framework anyways. So they choose Spring because it's the leading framework in Java world.
There are a lot of people who already know Spring and can become productive in a Spring codebase fairly quickly.
Yes. I was talking about Spring Boot there. Yes, that wasn't clear. Spring is a framework and some of the elements within it abstract other tools some of which are frameworks in their own right (e.g. JPA/Hibernate). There are many abstractions but Spring sort of unifies them to a single "story" you can work with. JPA under Spring makes a lot more sense with the JPA Repository etc.
Ofc these aren't all "frameworks" in the traditional sense, but that line is often arbitrary and I think this interpretation of OP's usage of the word is the most generous one.