Live data from Hacker News

Ask HN: What is a modern Java environment?

news.ycombinator.com

141–150 of 153 posts

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

#141
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

As far as I can tell the lombok is certainly less used than say 5 years ago.

Java records can help somewhat but as others point out, theay are not compatible with JPA, sometimes you get real value from Lomboks @Builder etc.

On the other hand if you combine lombok and JPA entities you can easily shoot yourself in the foot (autogenerated hashcode and equals can cause issues in some cases)

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

#142

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…

> We avoid the fanfare of Docker, as really it's not needed for Java apps; they're somewhat self-contained anyway and it created more problems than it solved. What does this mean?

Java apps have been "cloud ready" in a sense for about 20 years. JavaEE had a "WAR" or web archive file format that packaged an entire app up into a single file that could be deployed in an "Web Application Server". IBM wanted web servers to be mainframes, but for webapps. You could even deploy multiple apps in a single JVM, because the server would load each app in a separate classloader, meaning the apps were internally isolated from each other. The JVM even had an attempt at a cgroups like concept, called a Security Manager (that was abandoned, thank goodness), long before cgroups existed. Think WAR file = docker container.

Now, a lot of complicated bits were inherited that didn't need to be there when they brought over the mainframe thinking into Java apps, but the WAR format was actually something kind of cool they got right.

We in particular, take that WAR format, turn it into an executable, and we have a program that can execute on any hardware on any person's computer, with no pre-reqs except a JVM being installed. We test the _exact_ war file on a ARM RPI , developed on a Mac m1 or x86, and CI on a Linux x86.

Alright what does this mean? Lets take a look at another language...say a PHP application.... which may require extension Unix utilities of certain versions installed on the host system. You may need a certain version of PCRE grep, a certain version of curl, etc. This theme carries over to multiple languages, your python or ruby implementation may not support the latest version of libressl, or it might not even support your ABI at all. Docker solves these problems gracefully, by providing a fully configured virtual operating system tuned for running exactly one app.

The JVM... well doesn't need that, if written properly. Generally all the libs it uses are written in Java, they include all of their dependencies already, apps can be isolated with classloader boundaries (if that's your thing), you can download a single file and launch it if you use the "one-jar" technique.

So yeah, Docker loses a lot of it's luster with Java. It's not that you _cant_ use it, but it you can solve all the problems it does otherwise. Long rambling explanation but there you go.

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

#143

Earlier quoted context omitted.

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

do you have a 'sudo apt uninstall app-name' to clean everything up?

Yes! In fact, an upgrade path too in the script.

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

#144
post #85

Earlier quoted context omitted.

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.

In eclipse java code is generally already split into projects, in a workspace, you can close projects to save ram.

When you can get it all in memory, you get the benefits of eclipse refactoring, when you can't you don't.

Ability to write code that is safe to refactor is one of the great things about Java, so it's a shame if you can't benefit from that.

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

#145
post #54

Earlier quoted context omitted.

Eclipse immediately tells you what is broken when you change an api. IntelliJ does not. You can't stop IntelliJ from saving work. I like to kick of a build, and work on some new stuff while it's going on without saving until the build completes. That workflow is impossible in IntelliJ. You have to down tools, for a long build with lots of tests that can make IntelliJ slower over all. IntelliJ generally more responsiv…

It just takes two check boxes to uncheck to disable that in IntelliJ. I agree it is disturbing that it is a default at first. But it is at least configurable.

Which version? It wasn't possible last time I checked and Jetbrains had close-no-fix on various related bug reports.

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

#146
post #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 processin…

> 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 Considering Kotlin is a supported, first-class language on Android, why not write your shared libs in Kotlin as well?

I'm talking about open-source libs, i.e., I don't know who is going to use the lib, which env and target language they have, etc.

So I think that Java is the best middle ground here because it guaranties the full support of JVM features and 3rd party tools. I mean just avoiding a risk that it would be incompatible with something.

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

#147
post #28

Earlier quoted context omitted.

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

Incremental and partial Java compilation. Partial compilation is the notion that partially compiled software is still usable and something you can debug or introspect on. The IDE compiles while you type, it will detect syntax problems and as soon as you fix them they go away. Error markers in intellij are nowhere near as fast and you can't trust their presence or absence to be correct either. Intellij does that a lit…

Thanks, that sounds very cool. As you say, intellij basically hands this off to gradle or maven. Does Eclipse interpret those natively or do you have to reproduce your maven build in the Eclipse gui?

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

#149

Earlier quoted context omitted.

do you have a 'sudo apt uninstall app-name' to clean everything up?

Yes! In fact, an upgrade path too in the script.

Sounds great as long as you either put work into multi OS compatibility or stick to the same OS.

Depending on your situation that sounds like you have a good solution that's working and you're happy with.

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

#150
post #119

Earlier quoted context omitted.

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?

Containers offer a lot of advantages, portability, IaC, OS abstraction, common predictable environments, etc.

I personally like them a lot but it's definitely not the only way to do things.

Post reply on HN