Live data from Hacker News

Ask HN: What is a modern Java environment?

news.ycombinator.com

81–90 of 153 posts

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

#81

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.

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

#82
Here is what we use and I'd recommend to others.

The most common: - Kotlin for most of the backend code, but Java for shared libs. We still use Java 8 for some libs which may be used in Android, that's an unfortunate reality

- Gradle for build config

- Spring for application architecture

And few things that may significantly improve your dev process, but are not so common:

- Spring Reactor (and Webflux) for processing data and requests. Takes a time to learn, but it worth it

- Thymeleaf for UI

- Spock for testing. Highly recommended for designing tests

- Testcontainers for integration tests

- Micrometer to see what's going on with your app. I.e., to export all internal metrics to use with Prometheus/Grafana/etc

For the environment

- SDKMan to manager the environment

- Gradle Application plugin or Google's Jib to pacakge your app. First prepares a Zip with all binaries, second a Docker container

- IntelliJ IDEA

- Github Actions - turns out to be the most usable CI. Though the Jetbrains TeamCity may be better for a large team

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

#83

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.

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

#85
post #28

Earlier quoted context omitted.

I'm very curious to hear what Eclipse does that IntelliJ does not match.

Elipse keeps a complete Java representation of the source code in memory, (not the classes) that's why it can find compile errors before saving. This comes at the cost of lost of RAM, some projects are just too big for eclipse so IntelliJ is your only option. But that eclipse model can be used for lots of cool tricks, you have access to it in the plugin API, so for example you can enforce coding standards before even…

I would argue that if a project can't fit into Eclipse with 32 GB RAM then perhaps the code base has become too large to manage and ought to be split into separate projects with dependencies.

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

#86

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.

I admit we do miss that part. Instead for us it's `sudo apt -y install app-name`

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

#87
post #33

Earlier quoted context omitted.

Netbeans died an unfortunate death once it moved to the Apache foundation and Sun/Oracle funding died out. https://trends.google.com/trends/explore?date=today%205-y&q=... Unfortunate, because it had (has?) a great Swing and UML editor, built-in for free. Maybe I'm wrong and it's awesome now, but I haven't used it for a while in favor of Eclipse, and now, IntelliJ. This graph illustrates the IDE popularity between Int…

Netbeans was really great, maybe still is, but the noise jetbrains made with the astroturfing advertizing has jetbrains dominating everything. IMHO Netbeans was ahead of idea in many ways. But since they didn't buy commenteers to hype their product it's pretty much nowhere, at least I don't know anyone who uses it.

I know developers who still use it, but they refuse to give IntelliJ a chance.

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

#88
I have been thinking of writing up a series of articles on this. Without going into too much detail:

* IDEA

* Deploy on Google App Engine, Digital Ocean App Platform, Heroku, Elastic Beanstalk, etc - get out of the ops business entirely.

* Guice as the backbone, no Spring/Boot. I wrote a tiny dropwizard-like "framework" to make this easier: https://github.com/gwizard/gwizard but there's a laughable amount of code here, you could build it all from scratch with minimal effort. This is about as lightweight as "frameworks" get because Guice does the heavy lifting.

* JAX-RS (Resteasy) for the web API. IMO this is the best part of Java web development. HTTP endpoints are simple synchronous Java methods (with a few annotations) and you can test them like simple Java methods.

* Lombok. Use @Value heavily. Cuts most of the boilerplate out of Java.

* Junit5 + AssertJ. (Or Google Truth, which is almost identical to AssertJ).

* Use functional patterns. Try to make all variables and fields final. Use collection streams heavily. Consider vavr.io (I'll admit I haven't used it in anger yet, but I would in a new codebase).

* StreamEx. Adds a ton of useful stream behavior; I don't even use basic streams anymore.

* Guava. There's just a lot of useful stuff here.

* For the database, it really depends on what you're building. Most generic business apps, postgres/hibernate/guice-persist/flyway. Yeah, folks complain about hibernate a lot but it's a decent way to map to objects. Use SQL/native queries, don't bother with JPQL, criteria queries, etc.

* Hattery for making http requests (https://github.com/stickfigure/hattery). This is another one of mine. I make zillions of http requests, functional/immutable ergonomics really matter to me.

* Github actions for CI.

* Maven for the build. Yes, it's terrible, except for every other build system is worse. Gradle seems like it should be better but isn't. I'd really love some innovation here. Sigh.

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

#89

Kotlin + Dropwizard. Avoid Hibernate, go with JDBI. If I was starting a new project I'd look at Jooby, which looks pleasant and does very well on TechEmpower benchmarks.

JDBI is pretty slick. We used it as a previous company. Previous experience was with Hibernate, lower level JDBC, and some other half baked proprietary ORMs.

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

#90

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…

> 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

Since dotnet core started this has been front and center in C#. So there are other stacks doing this.

Post reply on HN