Does anybody have experience launching a web application with Java recently as compared to more modern framework and does anyone have any feedback?
Thank you!
Grails has GSP templates, while Spring Boot and Micronaut supports several, but I prefer either Thymeleaf or JTE templates.
Grails and Spring uses Hibernate, which is fantastic to work with. Micronaut has its own orm, which is really fast. In Grails Hibernate is abstracted into something named GORM, Spring Boot's Hibernate abstraction is named Spring Data. Spring Data is more polished than GORM. They're both very well documented and easy to use.
They are all very easy to use with other excellent Java tools/libraries, Kafka, Pulsar, Neo4j and so on.
If time to market is your thing, pick Grails. (This is what I care most about)
If performance (web scale) is your thing, pick Micronaut.
If best documented is most important, pick Spring Boot.
Grails is an abstraction of Spring Boot, basically you can do everything Spring Boot can. But Grails makes Spring Boot a lot easier, especially for inexperienced developers.
My personal impression is that Grails lost much of the momentum it had years ago.
As such I can safely say that anyone that thinks Java is good to use for anything these days, especially with things like Log4Shell, simply doesn't know enough about computer science. Java is a poorly designed language with corporate bullshit throughout, and while it may have been an option in the past given alternatives, is no longer the case.
Python, Rust, C/C++, Golang, and Javascript (and derivatives) cover pretty much every application category in terms of applicability.
It decent for applications, web services. Prefer C++ for embedded programming. Python for scripts and data wrangling and ML.
Sorry but what do I not know about computer science?
What a general purpose programming language choice have to do with knowing computer science?
That being said, I think that there is a great ecosystem of great software and tools written for Java. I like learning new languages and techniques, but I find Java is suitable for many things today.
Depending on your scale/budget they’re a bit more expensive to host due to JVM memory requirements but performance is good. Not a Java issue but a issue if you choose a language other than JavaScript for the frontend is you need to up skill frontend devs with the Java build tools/templating libraries and most frontend devs will have a bias against Java as it’s been bashed by lots of people who haven’t used it, it’s not sexy and they think of Java aplets from the 2000s.
The deeper question is how often you actually benefit from code reuse. There are certainly some areas where you can share things but you also run into a lot of coordination concerns because the environment for JS in a browser is not the same as in Node, which increases the friction of sharing, and a large chunk of the benefits are things like data validation which can also be substantially eased with things like JSON Schema. Simplifying those test matrices and formalizing your boundaries has more value than I tend to assume at first.
With more people working on it, like typical companies, it doesn't hold a ton of water. Every language has its place to where it's best suited. You can get a more performant, better structured, and safer backend in other languages.
Many of the applications you use day to day, are backed by a Java backend. Netflix/Much of AWS/Zillow/LinkedIn/Indeed/Much of Google
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.
For formatting, the only compelling truly framework agnostic option I know is the google formatter (unconfigurable). The other options are either editor specific (IntelliJ and Eclipse configurations are incompatible go figure), cost money or are half-baked (prettier). Now I believe there's a way to use spotless (tied to gradle/maven) to use one of the IDE specific formatters across IDEs at the build tool level, as you point out, but that's kind of a different thing, heavy weight and working around the underlying problem. Compare this to gofmt, rustfmt, scalafmt, black, prettier/eslint, etc. that are fast, framework agnostic and require no boilerplate. Formatting is a solvable problem in Javaland to a degree, but wow is it unnecessarily complicated and fraught with decision points that can end up in bikeshedding committees.
As for boiler plate, I'm talking about language level stuff, like having to make a class and separate file for every simple data structure, then having to implement hashcode/equals for all those classes, etc. Where in other languages, you can just return a tuple or a result or what have you and get on with your life. Again, IntelliJ will just do most of this for you, but supervising my IDE in boilerplate creation is not a joyful experience. And if you skip supervision, you are basically saying the IDE is now a dependency and the correctness of your program depends on the correctness of your IDE. Not super great.
Anyway, IntelliJ is certainly an amazing piece of software that makes Java development more productive, but learning it, configuring it, etc is a whole thing. Other modern languages provide much better QoL features out of the box and have a much less incidental complexity that don't require an IDE to get around. That said Java has the best library ecosystem, the biggest pool of developers and solid performance.
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)
One challenge here though is that many of those libraries are no longer maintained because the original developers moved away or retired years ago. I have a couple of relatively recent projects which require significant maintenance work dealing with unfixable CVEs or forced major updates which require non-trivial migration. That meant that even using an active project like Solr or Keycloak requires a surprising amount of maintenance developer time.
I don’t think we’ve fully gotten used to the changing supply chain trust situation in open source, and that’s going to hit all of the old ecosystems the hardest.
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!
That said, I'd honestly start by ignoring the common frameworks and just use something like Jetty embedded to create some API endpoints.
There's a lot of learning required for the common frameworks like Spring Boot. Browse the documentation and you'll see there's a lot there. Plus, they tend to be a debugging challenge for new people due to use of reflection and the like.
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.
They transpile java code to JavaScript, HTML, and css. They are tightly coupled to their RPC apis.
That said, I wouldn't recommend it for new projects.
== ARCHITECTURE
As for the architecture, I'm still a proponent of separate back end and front end components, say, using Java for your REST/GraphQL API, and something like Vue/React/Angular for your front end (with the latter packaged in a web server of your choice, like Caddy/Nginx/Apache). In my experience, it's just simpler that way, though YMMV.
== BACK END FRAMEWORKS / LIBRARIES
As for Java itself, I'd say that Spring Boot is the boring and dependable choice, it does basically everything you might need and is not too hard to configure. Admittedly, it feels inherently enterprisey and a bit cumbersome, even though it's leaps and bounds easier than regular Spring. This is probably a good starting point: https://start.spring.io/
It will generate starter projects that you can download and open in your IDE, maybe look at the getting started guides on the offical site: https://spring.io/quickstart
Personally, I'd also look at Dropwizard, which is smaller, simpler and still good enough for many use cases, because it combines a variety of "standard" (popular) packages for Java webdev: https://www.dropwizard.io/en/latest/
It won't be as smooth as Spring Boot, but I used recently for a small side project of mine: https://blog.kronis.dev/tutorials/2-4-pidgeot-a-system-for-m...
Some folks might also enjoy Quarkus, which got some hype in the recent years: https://quarkus.io/
Those who like reactive programming, might look into Vert.X: https://vertx.io/ (it doesn't quite feel like idiomatic Java, but is interesting nonetheless)
There's also Jakarta EE (formerly Java EE, formerly J2EE), which can be okay, but personally I'd avoid it in favor of one of the more popular options.
== FRONT END FRAMEWORKS / LIBRARIES (if you want to use Java for these)
For some basic templating, Thymeleaf should be okay: https://www.thymeleaf.org/
There's also Apache FreeMarker, Apache Velocity, JSP and JSF (I've seen it used with PrimeFaces). Those might also be viable, but I've had issues, especially with the latter ones. Regardless, here's an article about some of them (for Spring): https://www.baeldung.com/spring-template-engines
If you really want to do something more interactive but still in Java, you could use something like Vaadin: https://vaadin.com/
It's okay, but in my eyes still probably more suitable for internal admin panels, rather than that many client facing applications.
Personally I'd avoid GWT, my experiences with it were only negative.
== SUMMARY
I'd say that Java is an okay fit for a back end language - if you can get JetBrains tools (IntelliJ), you're going to have a really good time with writing code, thanks to code completion, refactoring and so on. The frameworks that are out there are reasonably stable, widely used and documented. You can also get whatever JDK distributions you want, like Eclipse Temurin. Oh, also JMX for debugging and instrumentation is great, you can see every single DB query that the app does, as well as aggregate that data, maybe get flame graphs, or just look at how GC works. Integration with things like Sentry or Apache Skywalking is also great.
Using it for anything regarding front end is more risky and might be a bit more problematic. Not saying it will, just that it might - serving packaged assets for a Vue/React/Angular app from a web server directly (or maybe through a container) would probably be more simple, especially with a reverse proxy configuration.
Not sure I agree here. One needs to know a good amount about how Spring works before they can start configuring Spring app. Methods annotated with @Bean would look strange to any newcomer, or how about trying to figure out how messaging libs set up works (let's say Kafka) would be very confusing.
Use what you are comfortable with and get the app out there. Way more important than what stack you are using. Now excuse me while I go and look at all the shiny things on HN.
check that out if you want to be single lang but not use js/ts.
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.
The two challenges I’ve encountered basically come back to there being two distinct communities: “Java that doesn’t suck” and “Enterprise Java™”. It is very easy to get people who learned enough Java 6 to get a CRUD job at a bank or government contractor, and they’ll give you an app with a ton of snarled, fragile code and a dependency stack deep enough to make a Node developer wince. It’s harder to find good developers since on paper both of them will look the same to HR — IT or CS degree, 10-15 years of experience, AWS experience, etc. — so you’ll have more work filtering than you would with non-default languages.
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.