Live data from Hacker News

Ask HN: What is a modern Java environment?

news.ycombinator.com

101–110 of 153 posts

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

#101

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 her…

Cool, it is a lot to start researching but you sound like you use a very similar style to things I am used to in other languages. On guice/gwizard/maven, if I understand correctly I would be defining new guice DI for something like a message broker (and gwizard's solutions for similar modules might serve as a template) while probably just using direct dependencies in maven for something that doesn't need to be mocked…

You could make a new guice module for the message broker, but you don't have to. If you want to use a message broker, just bind the service object as an eager singleton in your application module.

The main reason to make a separate guice module for the message broker is if setup requires a lot of boilerplate. You can put it all in a common jar artifact and include that in different services. But that's overkill if you just have one service, or if the broker has a fairly friendly interface to start with.

Guice is just a little bit of structure to bind together Normal Java Code. You don't need to wrap services or do things eg "the spring way". Just use the service; if you find yourself repeating code, consider abstracting it into a separate module.

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

#102
- Language: Java 17/Kotlin

- API Layer: Quarkus (most projects https://github.com/quarkusio/quarkus), Vert.x (small projects https://vertx.io/)

- DB: Postgres, in-memory H2 for simple stuff

- Testing: JUnit 5, Testcontainers to automatically start + stop DB Docker containers with tests (https://www.testcontainers.org)

- Mocking: Mockito (https://github.com/mockito/mockito) or Mockk (Kotlin, https://mockk.io)

- Dependency Injection: CDI (built into Quarkus, for Vert.x you can initalize Weld when the app starts https://weld.cdi-spec.org)

- Build tool: Gradle with Kotlin DSL

- Other tools:

  Kover: automatic code-coverage reports from JaCoCo/IntelliJ (https://github.com/Kotlin/kotlinx-kover)

  Ktlint + Detekt: Kotlin linting/static analysis (https://ktlint.github.io, https://detekt.github.io/detekt)

  PMD, Spotbugs, Nullaway: Java linting/static analysis (https://pmd.github.io, https://spotbugs.github.io, https://github.com/uber/NullAway)

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

#103
post #28
post #7

Earlier quoted context omitted.

I am using it now because the team is using it, but cant figure out in which way it is supposed to be better then Eclipse. It looks somehow better, but it seems strictly inferior in terms of what it does for me.

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

Compilation of everything, how it shows compile errors and warnings. I see them in tree, in list, easily and quickly all of them. All of them for whole project at once and trustworthy. Less bogus warnings and contraproductive suggestions.

I never needed to fiddle with "command line shortener" ridiculousness in Eclipse.

Better code navigation and discovery. Eclipse always finds everything, every called and callee to depth. Same with inheritance. Even where Idea has same views, for some reason they hide it and only former Eclipse users stumble on it.

Actually safe refactorings. Idea occasionally "refactors" by creating bugs.

I had some cases where Idea simply formats code wrong. And it was impossible to configure to formát it right.

Also, Eclipse compile by default. It is ridiculous to have to remember to press shortcut to compile in modern IDE. I know it is configurable, but still ridiculous default.

Square selection.

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

#104

The stack I've seen, used and liked at many clients is: Spring Boot, Kotlin, IntelliJ. Which of course means all the old discussions: Jetty/Tomcat/JBoss/GlassFish, GSON/Jackson, Hikari/C3PO/etc, etc are now mostly moot, since most just use the Boot defaults until they need something else. Kinda nice, actually. Less bikeshedding, can get a project up and running without taking a stand on all these things. Most clients…

This is it. The irony is that the modern Java stack uses the JVM & classlib, but a different language. If you want to go full hipster, there is Micronaut (also Quarkus) and if you'd like to go a bit off-charts, there is Dropwizard. I don't think that they offer anything extra over SB though.

Or for hipsters there's https://www.jhipster.tech/

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

#105
post #7

Earlier quoted context omitted.

I am using it now because the team is using it, but cant figure out in which way it is supposed to be better then Eclipse. It looks somehow better, but it seems strictly inferior in terms of what it does for me.

And what are the functions that you use that work better in Eclipse?

Eclipse shows me all errors in whole project at once. This is biggest one. The hierarchy and callers hierarchy always work, I can rely on them way more then in Idea where they sometimes miss things.

Much much better full text search. I can search through multiple projects. Not just root.

Square selection.

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

#106

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…

"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."

It's exactly the same in the .NET space

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

#107

The stack I've seen, used and liked at many clients is: Spring Boot, Kotlin, IntelliJ. Which of course means all the old discussions: Jetty/Tomcat/JBoss/GlassFish, GSON/Jackson, Hikari/C3PO/etc, etc are now mostly moot, since most just use the Boot defaults until they need something else. Kinda nice, actually. Less bikeshedding, can get a project up and running without taking a stand on all these things. Most clients…

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 wouldn't bother with async unless there's a solid reason. Most Java libraries assume a standard, synchronous model and Java threads are relatively cheap these days. There's no point in going against the grain.

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

#108
post #43

Earlier quoted context omitted.

Is Scala still in trend?

It's Kotlin now. Kotlin has similar expressibility and extensibility, without Scala pitfalls. (Scala pitfalls that people didn't like included new versions having breaking changes, complexity, theoretical/academic features that weren't necessarily useful to consumer applications, and slow build times).

New versions don’t have breaking changes, they are just not binary compatible between major version upgrades which is true of many other languages as well. Regarding complexity - scala has many features due to having a small number of clever primitives. Kotlin special cases many common cases, but imo that will be a more complex language down the line. I really don’t know what do you mean by academic features — one can make haskell libs with scala but they are libs, not language features. And build time-wise it is not that much slower than kotlin.

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

#109
post #50

Earlier quoted context omitted.

With records now being supported in Java, wouldn't Lombok be less needed?

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.

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

#110

Earlier quoted context omitted.

This is it. The irony is that the modern Java stack uses the JVM & classlib, but a different language. If you want to go full hipster, there is Micronaut (also Quarkus) and if you'd like to go a bit off-charts, there is Dropwizard. I don't think that they offer anything extra over SB though.

Or for hipsters there's https://www.jhipster.tech/

One of my first PRs ever was to that project, back in 2013. Then it was a nice starter project, showing how one could move away from the clunky server side rendering frameworks at the time, instead using AngularJS on the frontend and having a backend. And also included a nice simple Spring setup, before Spring Boot existed. So pretty hip, and very lean.

Since then it has.. evolved to something quite big, I feel, where one quickly end up with lots of unknown boilerplate in one's project. I mean, it's probably useful in its own way, almost like a Django alternative or something with batteries included. But not very hipster anymore.

Post reply on HN