Live data from Hacker News

Ask HN: What is a modern Java environment?

news.ycombinator.com

111–120 of 153 posts

Re: Ask HN: What is a modern Java environment?

#111
post #31
post #18

This is my experience. For context I do a lot of contract work mostly in banking, ecommerce and insurance. - Spring Boot - IntelliJ - Gradle or Maven - Java 8 features (for various reasons most of my clients do not use version > 8)

what about lombok? Edit: just curious if you think it's standard

Lombok seems to have a 50/50 split of people who love / hate it. I am firmly in the No Lombok camp! My reasons are;

* IntelliJ is very good at generating boilerplate getters / setters etc

* I found sometimes the annotation processor would get out of sync with the IDE resulting in compilation issues until the processor was run again

* Java 17 records replace a lot of the functionality

Re: Ask HN: What is a modern Java environment?

#112
post #91

Earlier quoted context omitted.

Yes. Perhaps to add to this, use a modern asynchronous IO framework. If you use Spring Boot, ignore some of the legacy stuff that still comes with it and make sure you use webflux with Kotlin co-routines. Also use Asynchronous IO for talking to your database, queues, etc. Kotlin makes all of this easy. Hibernate is something I tend to avoid for various reasons but apparently recent versions of that now also support a…

I really wouldn’t go the async way unless it was deemed absolutely necessary for maximal performance — it makes reasoning/debugging much harder with often not much gain. Also, if one can just wait a few years, loom will make many part of it obsolete - when blocking code will magically get non-blocking while it retains the readibility.

I find the big problem with async is the libraries, not necessarily the async piece itself. I looked at Webflux (Project Reactor)/RxJava/etc. years ago and discovered that the composable async components unexpectedly maintain state, and that's really the piece that makes it hard to reason about.

I've since switched over to Scala + cats-effect. I found that to be a huge learning curve, but the payoff for me has been library support for easy-to-use and easy-to-understand concurrent and asynchronous programming. I cannot recommend it enough.

Re: Ask HN: What is a modern Java environment?

#113

I'll chime in my opinion: Java is getting something right that I don't see much elsewhere: Dependency Injection. Combine this with a mocking framework and you can write _actual_ isolated unit tests for every single part of your stack. We're fans of CDI, it's a more polished Spring framework without the legacy weight. We're developing in Quarkus, MicroProfile, and bigger monoliths in Apache TomEE. We use ActiveMQ exte…

While you are correct that DI is very good in java, DI is needed because of heavy reliance on OOP (i.e, in order to create an instance of an object, you have to lock in functionality with a dependency before you can run that functionality).

If you use a language that doesn't require OOP, you can do the same isolated unit tests without DI.

Re: Ask HN: What is a modern Java environment?

#114

I've been doing Java non-stop since before 1.6. I just started a new project, and it's * IntelliJ * Standard enterprise Java JEE 9.1 (JSP, JPA, EJB) * Payara app server * Twitter Bootstrap * Maven * Test driven development using TestNG + AssertJ * Postgres + Liquibase for schema management Code samples now come from https://www.baeldung.com/

Just curious - you mention JSP. Was that mentioning that yeah, JSP happens to be part of JEE or are you actively using it? I haven’t heard of a new project using JSP for a while.

Yes, my new project uses actual JSPs. Granted, there aren't tons of pages to be built in this project, and certainly nowhere near the scale that might call for a different option. For even a few dozen pages, JSP is still just fine.

Re: Ask HN: What is a modern Java environment?

#115
IMO:

IntelliJ for IDE (Community edition is free). #1 reason is it supports Kotlin and Groovy very well out of the box. Eclipse is still a plugin disaster, and the language support aside from Java is pretty bad, although I haven't bothered to check in a few years since IntelliJ CE was released.

Gradle for builds. It is still copy and paste setup, but at least you can do a lot more things than rigid Maven.

Groovy + CompileStatic (personally) for the actual JVM language but admittedly I haven't tried Kotlin yet. Even with closures and other improvements, base Java can't compete with either of those.

Spring Boot for your enterprisey stuff/REST services which you are likely using it for. It's such a standard at this point.

Unit tests: Spock. Spock is awesome. And very well supported by IntelliJ for autoformat, another BIG reason to use IntelliJ.

Man, web frameworks on Java that don't just use it for an AJAX service layer? Who knows.

Re: Ask HN: What is a modern Java environment?

#116
post #109

Earlier quoted context omitted.

Unfortunately not. Records are not compatible with JPA, so classic beans with getters and setters would still be a choice for many people. Record-friendly ORMs do not exist yet (I’m currently working on one).

Could you please share your ORM? I would really like to use java with much less reflection.

If you can send me an email at oss+hn[at]esoftworks.com, I will let you know when I will have beta quality code on GitHub. This is a personal side project exploring annotation processing and targeting modern Java (17+), some results will be ready probably in 2-3 weeks.

Re: Ask HN: What is a modern Java environment?

#117
Personally, after the log4j fiasco, I wouldn't touch Java.

The standard ecosystem setup is to use all the major 3p libraries for all your functionality (Jaxrs, swagger, log4j, jersey, e.t.c) While this generally works, the ecosystem is full of holes (like log4j), and crappy behavior. You get things like "javax.ws.rs.ProcessingException: Already connected", exceptions which mask underlying issues like not being able to find the endpoint, or SSL certificate error, mainstream clients for things like Redis having issues with multiple connections and unable to switch to master nodes, and so on.

The core language itself is very "dirty" (Integer vs int, requiring a class for the main function, e.t.c). The standard way annotation processors add functionality is to basically write out java files, (or in the case of the ever so popular Lombok, they hack the AST). Because of how annotation processors are run, often times an error during annotation processing with dependency injection will result in very cryptic errors, often about things that were working before that you didnt change.

And on top of everything, jdb debugger is pure garbage, forcing you to use bloated software like IntelliJ for any decent functionality.

Yes, you can learn the ecosystem and its idiosyncrasies, or you could just write the thing in Python or Node with a much more efficient workflow. Network latencies dominate the processing speed these days, and infrastructure is cheap compared to developer time.

Re: Ask HN: What is a modern Java environment?

#118

I'll chime in my opinion: Java is getting something right that I don't see much elsewhere: Dependency Injection. Combine this with a mocking framework and you can write _actual_ isolated unit tests for every single part of your stack. We're fans of CDI, it's a more polished Spring framework without the legacy weight. We're developing in Quarkus, MicroProfile, and bigger monoliths in Apache TomEE. We use ActiveMQ exte…

While you are correct that DI is very good in java, DI is needed because of heavy reliance on OOP (i.e, in order to create an instance of an object, you have to lock in functionality with a dependency before you can run that functionality). If you use a language that doesn't require OOP, you can do the same isolated unit tests without DI.

I want to expand on what you said: It's more than just OOP, or not necessarily OOP in general that needs this type of DI and IOC.

It's a specific category of OO architecture, where effects and state are buried under domain logic and information processing (via DI). If you keep that part data oriented and pragmatically functional, then you get a very testable core. Meaning no mocks, stubbing setup/tear-down (...) are required. No additional interfaces have to be specified that you didn't need in the first place. Tests are way simpler this way.

You can still use objects, interfaces and composition etc. for domain logic and information processing if you want. Point is you lift state and effects up, so this stuff happens at the edge of your program that calls into a simpler core.

Re: Ask HN: What is a modern Java environment?

#119

I'll chime in my opinion: Java is getting something right that I don't see much elsewhere: Dependency Injection. Combine this with a mocking framework and you can write _actual_ isolated unit tests for every single part of your stack. We're fans of CDI, it's a more polished Spring framework without the legacy weight. We're developing in Quarkus, MicroProfile, and bigger monoliths in Apache TomEE. We use ActiveMQ exte…

Containerization is great. It allows you to write all the infrastructure for you Java app as code and then just simply type 'docker-compose up' to get it running (or whatever your orchestrator). This makes it super portable. Just something to think about. I personally think the win's from Containerization are greater than the challenges.

You don't necessarily need containers for that though?

Re: Ask HN: What is a modern Java environment?

#120

Personally, after the log4j fiasco, I wouldn't touch Java. The standard ecosystem setup is to use all the major 3p libraries for all your functionality (Jaxrs, swagger, log4j, jersey, e.t.c) While this generally works, the ecosystem is full of holes (like log4j), and crappy behavior. You get things like "javax.ws.rs.ProcessingException: Already connected", exceptions which mask underlying issues like not being able t…

> Network latencies dominate the processing speed these days

I want to see data on this. It gets repeated over and over but this doesn't match my experience at all. Am I crazy?

Post reply on HN