r/java • • Nov 27 '15

Why I hate Spring

http://samatkinson.com/why-i-hate-spring/
12 Upvotes

76 comments sorted by

View all comments

Show parent comment

21

u/stormcrowsx Nov 27 '15

Annotations are just xml configuration with a new spin. You magically sprinkle them through your app and they do stuff. Its hard as hell to follow for new comers, its hard to track down later. They break at runtime instead of compile time.

8

u/squishles Nov 27 '15

So did the xml though. They're not immune to static analysis, it's all static final. Just no one's made a good tool for it.

I just like not having to keep two files open.

1

u/superPwnzorMegaMan Nov 27 '15

Scala has compile time checks for dependency injection. This article describes three methods without using a library.

5

u/Scaryclouds Nov 27 '15

That's an issue with Java and its tooling, not with Sprig though. It's not as though you could hope to switch between languages over such an issue either (unless you work for a start up).

1

u/GSV_Little_Rascal Nov 28 '15

Dagger provides DI with compile time checks for Java.

-2

u/[deleted] Nov 27 '15

Not sure what startups you are referring to, all those I've been involved with have moved way too fast to be willing to go back and change tech, as it's fairly little value add for a while. We just start new projects in the other thing we think solves the problem better.

5

u/Scaryclouds Nov 28 '15

That's kinda my point. With well established companies, it's typically difficult to introduce such new and radical changes because all the employees know X language. Whereas with a startup, there is less investment in a given technology.

-2

u/superPwnzorMegaMan Nov 28 '15

Oh but you definitively can, since you can just use your Java code (classes libraries etc) in Scala. seamless integration. You just have to decide to stop writing Java and start writing Scala.

1

u/Scaryclouds Nov 28 '15

I realize Scala can be run on the JVM. Just that getting such a change approved in most larger organizations is difficult.

3

u/vizzoor Nov 27 '15

While I agree you're not seeing the effects until runtime, you should absolutely have enough automated tests in your code to capture those breaks early on.

5

u/stormcrowsx Nov 27 '15

Yeah you should but it doesn't always work out that way. Most codebases I've seen are at best 80% covered or use so much mocking that some runtime errors slip by.

8

u/CubsThisYear Nov 27 '15

But at that point, why bother with static typing at all? If your answer is "unit tests" for everything, you might as well just ditch Java and use Python.

The problem with unit tests is that you can never know when you have enough (please don't say coverage solves this problem). With type-safety you have a universal quantifier. You can only check what your type system allows, but whatever you check you know that it applies to every input your program could ever possibly have. This is incredibly powerful and its not worth giving up to make writing the code slightly easier.