I'm diving into programming and have been experimenting with creating simple HTTP-based APIs using both FastAPI in Python and Spring Boot in Java. I've noticed some key differences in how these frameworks work, and I'm curious if others feel the same way.
When I'm using FastAPI, I mainly write functions that are either called directly or passed around, which feels quite intuitive to me. For example, I create an endpoint like:
```python
@APIRouter().get("/blah")
def get_blah():
return "blah"
```
Here, I include the router through `.include_router()`, and I can easily envision how the objects interact.
Conversely, with Spring Boot, I find myself defining classes that are never explicitly instantiated in my code:
```java
@RestController
public class TextController {
@GetMapping("/texts")
public List getTexts() {
return service.getTexts();
}
}
```
It feels like I have less control over my application compared to FastAPI. Is this a common feeling among developers? Are these differences just how the frameworks were designed, or is there something deeper at play?
2 Answers
I get what you mean! Understanding how those frameworks work can take some time, and it might just be a skill you build over time. With Spring Boot, it's about different design philosophies—some frameworks prioritize help and automation, while others give you raw control.
It sounds like you're noticing the concept of Dependency Injection (DI) and Inversion of Control (IoC) in Spring Boot. Essentially, Spring manages object creation for you when the application starts, which can feel abstract since you don't see the instantiation yourself. It makes things more modular but can seem like you're losing control upfront unless you grasp how it operates.

That makes sense! So, it's more about letting Spring handle the heavy lifting, right?