Live data from Hacker News

Ask HN: Using Java for a web application in 2023

news.ycombinator.com

41–50 of 69 posts

Re: Ask HN: Using Java for a web application in 2023

#41
Hacker News is very biased towards the cool new thang. But if you look on StackOverflow Developer Survey 2022, Java is one of the top languages that professional devs actually use in their day to day — far more than Go, Rust, Zig, Elixir, and so on, the more trendy languages that get talked about a lot.

The main advantage of Java in my mind is how old, mature, and stable the ecosystem is. Everything has a library for it.

Also, if you later decide to use a cooler/more expressive language, you can actually keep your Java code and use one of the other popular JVM languages with interop. (Scala, Kotlin, Clojure)

Re: Ask HN: Using Java for a web application in 2023

#42
post #27

By many metrics it's an excellent choice, but I kind of loathe working with it. However, if you don't mind living in IntelliJ it's significantly better. For example, there's a ton of stuff that doesn't exist, except in IDEland like basic formatting support (this blows my mind). You'll also want an IDE to help you refactor since there's a ton of boilerplate cruft and footguns to avoid. Nonetheless, library support for…

What do you prefer instead of IntelliJ? It's great even for other languages e.g. in Goland and Webstorm.

There is formatting support via Gradle and Maven. You can even run prettier via prettier-java.

Boilerplate more exists in frameworks especially the older the 1s. You don't have to use it.

Re: Ask HN: Using Java for a web application in 2023

#44
post #18

The JVM is very robust and the language has improved considerably if your prior experience was a while ago. By now there are robust libraries for most things, IDE support, etc. but you’ll find odd gaps around packaging, formatters, etc. because there are so many entrenched groups with different goals who haven’t coalesced on common answers the way, say, much of the Python community has settled on Black. The two chall…

Don't see how your challenges relate to Java. What you describe about slow moving large organisations happen regardless of the language or framework. I've seen the same whether it's PHP, NodeJs or Java.

Re: Ask HN: Using Java for a web application in 2023

#45
Unlike many others here, I would highly recommend writing backend services/APIs on the JVM, with the caveat that you use Kotlin, not Java. Every server project I've started in the past 3-4 years has been Kotlin, and I have never been more productive. Last year I switched from JS SPA (I preferred Vue to React) to HTMX and Jte templates and it was like adding a turbo boost to an already-humming engine.

Second point, while the frameworks can be helpful (Spring, VertX, Micronaut, Quarkus, etc) you don't actually need one. Ktor or http4k as your http/routing engine (& client), jooQ for DB access, H2 as a caching database if necessary -- these will take you a long way.

The only downside I experience is fewer deployment options -- can't natively deploy to Fly.io, Railway, etc except via Docker. With that said, setting up a simple VPS with Adoptium JVM is pretty easy. Hope this helps -- good luck!

Re: Ask HN: Using Java for a web application in 2023

#46
Recently there is a trend back from SPA to server side rendering to avoid complexity, which isn't needed for most kind of apps. Htmx is a good addition in this scenario, which describes ajax calls as html attributes. You may have a look at bootify.io for generating such an application setup. Every language has it's pros and cons, Java has some overhead here and there but very mature and lots of libraries.

Re: Ask HN: Using Java for a web application in 2023

#47
post #2

I wouldn't recommend JVM for web in 2023, but if you really want to use it, I would at least recommend Kotlin. It has a better syntax, more up to date tools and is officially supported by JetBrains too. It also has the Ktor framework which is really fun to work with.

Kotlin is nothing without the JVM ecosystem, written in Java.

Re: Ask HN: Using Java for a web application in 2023

#49
post #44
post #18

The JVM is very robust and the language has improved considerably if your prior experience was a while ago. By now there are robust libraries for most things, IDE support, etc. but you’ll find odd gaps around packaging, formatters, etc. because there are so many entrenched groups with different goals who haven’t coalesced on common answers the way, say, much of the Python community has settled on Black. The two chall…

Don't see how your challenges relate to Java. What you describe about slow moving large organisations happen regardless of the language or framework. I've seen the same whether it's PHP, NodeJs or Java.

It’s certainly not unique to Java but it’s especially common there because it’s a default language many people are taught in classes, and the demand from large moribund organizations means there are more people in total with that kind of experience. If you put out an ad for Rust or Scala developers, you’re not getting applications from plodders whose counselor told them they could get a decent indoor job at a bank with a basic understanding of the language.

JavaScript/NodeJS certainly has a similar version of the problem but a couple decades earlier in the process, and not being the choice of enterprise it’s less common to see people who’ve been doing the same thing for a decade.

Again, as in my previous comment, this isn’t a problem with Java the language but rather a sampling problem with the massive community.

Re: Ask HN: Using Java for a web application in 2023

#50
While I love Java for backend, API, DB integration, and a bunch of other stuff, it's not a full stack technology.

What's your web front end going to be? Do you have something in mind which can make clean calls to a Java backend?

If so then Java remains a safe, trustworthy choice, and is relatively productive once you know it reasonably well. As per other commentors, Spring Boot is a good framework.

Post reply on HN