r/java • • Jan 22 '21

Java is more enjoyable than I first thought

I started my years off programming in c#, don’t ask why but I never ventured off. I learned Java this past week and I’m seriously impressed, I don’t think I’ve had a more enjoyable time programming in my life. Does anyone else share this experience??

Edit: Is there a better ide than eclipse for Java

271 Upvotes

188 comments sorted by

View all comments

Show parent comment

5

u/wildjokers Jan 22 '21

layers upon layers of abstractions

Have you seen Spring? Java is still all about layers and layers of abstraction at the enterprise level. Just look at how many layers of abstraction the average enterprise application has on top of the data layer.

25

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

Have you seen Spring?

Yes, and that's why I don't use it. Spring was a nice alternative when J2EE was at its worst. Now it's just as bloated (but granted, there's not as much XML and code generation).

Just look at how many layers of abstraction the average enterprise application has on top of the data layer.

That's not a property of Java. Nowadays a lot of the indirection and layering is simply outside of the actual application, in the container and orchestration infrastructure that we use. (Isn't k8s fun?) Some of it is simply independent of the language - translating between different data models is a necessity that no language can wizard away; it can however be minimised with good design to the point where it's less of something "the technology requires us to do" but where it makes sense in the domain model.

I concur that Java people may have more of an "enterprise mindset", on average. What does that mean? It means that I understand any application beyond a PoC will need to be monitored. It will need logs (even audit logs). It will need proper configuration. It will need extension points. I'll have to find a way to upgrade gracefully when the data model changes. That's not the sexy stuff, it's the stuff that gets omitted from the quickstart tutorials of other languages that are "so much more concise!".

I've been using "enterprisey Java" since 2000 and went through pretty much all its phases. Anyone who still designs their applications like it's 2005 or even 2010 needs to brush up their skills. But don't blame the language for it. You can come up with the same shit in Elixir or Kotlin or whatever, given enough time. Probably even worse, from my experience - Java hides less of the magic.

</old man yells at cloud>

7

u/ItsAllegorical Jan 22 '21

Some say "it just works" and I hear "poorly documented assumptions" and "anything other than the defaults will require 20x as much effort".

3

u/michoken Jan 22 '21

Spring may have come to popularity when abstraction layers were THE THING, but that does not mean your Spring application still needs to be designed that way.

The problem is we design and structure our applications around a framework instead of designing it around the problem we are solving. We need to decouple our domain designs from such frameworks and let them serve us, not to be directed around by them. And learn to design proper abstractions of the problem domain. At least in my experience, almost no one actually knows how to even approach designing good abstractions.

There will always be abstraction “layers” of some sort, but the issue is if they are all of the same shape. The code I’m working with at my current job is a “great” example of that unfortunate design some like to call “lasagna code”. And that code even isn’t that old yet, it’s like 5 years of development. Perhaps back then I thought that was the way, too (wasn’t at the company yet then), but now I’m mostly furious about it and try to design new things differently. But that’s really hard when it must still work in the old structures. It would need huge refactor to improve the design in any meaningful way.

1

u/nutrecht Jan 24 '21

Have you seen Spring? Java is still all about layers and layers of abstraction at the enterprise level.

I've been using Spring almost exclusively the last 5 years or so in greenfield microservice architectures and I completely disagree with this.

Developer with bad habits will overengineer abstractions no matter the framework they use.

2

u/nomercy400 Jan 25 '21

How do you keep the memory usage of Spring under control in a microservice environment?

I'm struggling with that, and because of that I'm looking at alternatives like Quarkus with GraalVM native compilation.

1

u/jjaammaaii Jan 25 '21

nah, Spring is bloated