TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Using Java for a web application in 2023

43 点作者 drum超过 2 年前
Hi HN,<p>Does anybody have experience launching a web application with Java recently as compared to more modern framework and does anyone have any feedback?<p>Thank you!

25 条评论

olavgg超过 2 年前
I highly recommend either Grails, Spring Boot or Micronaut. There are several others, but they lack documentation, has confusing documentation or is over-engineered. Of these 3, Grails is convention over configuration, and the two others configuration over convention. Micronaut is the most performant and use least memory.<p>Grails has GSP templates, while Spring Boot and Micronaut supports several, but I prefer either Thymeleaf or JTE templates.<p>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&#x27;s Hibernate abstraction is named Spring Data. Spring Data is more polished than GORM. They&#x27;re both very well documented and easy to use.<p>They are all very easy to use with other excellent Java tools&#x2F;libraries, Kafka, Pulsar, Neo4j and so on.<p>If time to market is your thing, pick Grails. (This is what I care most about)<p>If performance (web scale) is your thing, pick Micronaut.<p>If best documented is most important, pick Spring Boot.<p>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.
评论 #34722947 未加载
评论 #34718851 未加载
twodayrice超过 2 年前
Honestly hacker news is the wrong place to ask questions about Java. There is lots of biased opinions with little experience using Java.
评论 #34719098 未加载
BFLpL0QNek超过 2 年前
Java web applications I’d describe as “boring technology” if you want typical rest applications with SPA frontend or a full stack server side rendered (SSR) app. By boring I mean it works with little fuss or churn.<p>Depending on your scale&#x2F;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&#x2F;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.
评论 #34718217 未加载
syspec超过 2 年前
Everything is already running on Java in 2023.<p>Many of the applications you use day to day, are backed by a Java backend. Netflix&#x2F;Much of AWS&#x2F;Zillow&#x2F;LinkedIn&#x2F;Indeed&#x2F;Much of Google
zumu超过 2 年前
By many metrics it&#x27;s an excellent choice, but I kind of loathe working with it. However, if you don&#x27;t mind living in IntelliJ it&#x27;s significantly better. For example, there&#x27;s a ton of stuff that doesn&#x27;t exist, except in IDEland like basic formatting support (this blows my mind). You&#x27;ll also want an IDE to help you refactor since there&#x27;s a ton of boilerplate cruft and footguns to avoid. Nonetheless, library support for most business use cases is nearly unparalleled, performance is strong if you can deal with GC and there&#x27;s a million Java developers to hire from.
评论 #34720372 未加载
japhib超过 2 年前
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.<p>The main advantage of Java in my mind is how old, mature, and stable the ecosystem is. Everything has a library for it.<p>Also, if you later decide to use a cooler&#x2F;more expressive language, you can actually keep your Java code and use one of the other popular JVM languages with interop. (Scala, Kotlin, Clojure)
评论 #34723361 未加载
andy800超过 2 年前
Unlike many others here, I would highly recommend writing backend services&#x2F;APIs on the JVM, with the caveat that you use Kotlin, not Java. Every server project I&#x27;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.<p>Second point, while the frameworks can be helpful (Spring, VertX, Micronaut, Quarkus, etc) you don&#x27;t actually need one. Ktor or http4k as your http&#x2F;routing engine (&amp; client), jooQ for DB access, H2 as a caching database if necessary -- these will take you a long way.<p>The only downside I experience is fewer deployment options -- can&#x27;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!
nitwit005超过 2 年前
The Java frameworks are &quot;modern&quot;. They&#x27;re common to use in new projects, and the Javascript frameworks often mimic them.<p>That said, I&#x27;d honestly start by ignoring the common frameworks and just use something like Jetty embedded to create some API endpoints.<p>There&#x27;s a lot of learning required for the common frameworks like Spring Boot. Browse the documentation and you&#x27;ll see there&#x27;s a lot there. Plus, they tend to be a debugging challenge for new people due to use of reflection and the like.
karmakaze超过 2 年前
Unless you want a job, there are more lightweight&#x2F;interesting frameworks than Spring&#x2F;Boot. e.g. Javalin+JDBI, Quarkus, Micronaut.
评论 #34720385 未加载
评论 #34722981 未加载
brianmcc超过 2 年前
While I love Java for backend, API, DB integration, and a bunch of other stuff, it&#x27;s not a full stack technology.<p>What&#x27;s your web front end going to be? Do you have something in mind which can make clean calls to a Java backend?<p>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.
aprdm超过 2 年前
It&#x27;s 2023, it still just works and much of the internet&#x2F;world runs on top of it. Take it as you wish :)
rlawson超过 2 年前
Spring Boot&#x2F;Spring MVC&#x2F;Thymeleaf&#x2F;htmx. Use the spring dev tools for autoreload.
4RealFreedom超过 2 年前
If you&#x27;re looking at Java, I highly recommend taking a look at Kotlin. I&#x27;ve worked with Java for far too long and my main project now is Kotlin with Spring Boot. It&#x27;s a fairly powerful combination and a joy to write in.
gardenfelder超过 2 年前
I am preparing to return to the JVM, this time experimenting with Eclipse Vert.x
评论 #34722999 未加载
Jaepa超过 2 年前
While I would highly highly recommend against it there is GWT, &amp; Vaadin.<p>They transpile java code to JavaScript, HTML, and css. They are tightly coupled to their RPC apis.
评论 #34719420 未加载
bootify超过 2 年前
Recently there is a trend back from SPA to server side rendering to avoid complexity, which isn&#x27;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&#x27;s pros and cons, Java has some overhead here and there but very mature and lots of libraries.
downvoteme1超过 2 年前
I think Java is a solid choice for a data heavy application in 2023. As many have mentioned spring boot is a man excellent choice for the Java backend . You should also take a look at JHipster. It combines the strengths of Java with a modern front end like React or Vue or anything else of your choice to make a modern front end .
luhego超过 2 年前
It&#x27;s boring tech but it gets the work done. Recently, I have found joy deploying Lambdas using only Dagger.
plaguepilled超过 2 年前
I can only offer sentiment, but I really like Spring Boot. It&#x27;s not perfect but it does what I want it to.
KronisLV超过 2 年前
Personally, I&#x27;d say that either Kotlin or Java are okay language choices (and the JVM runtime is good too), not unlike something like modern .NET. The performance is good, the type system is passable, you have bits of FP and OOP to use at your leisure, there&#x27;s a rich ecosystem of a variety of libraries out there.<p>== ARCHITECTURE<p>As for the architecture, I&#x27;m still a proponent of separate back end and front end components, say, using Java for your REST&#x2F;GraphQL API, and something like Vue&#x2F;React&#x2F;Angular for your front end (with the latter packaged in a web server of your choice, like Caddy&#x2F;Nginx&#x2F;Apache). In my experience, it&#x27;s just simpler that way, though YMMV.<p>== BACK END FRAMEWORKS &#x2F; LIBRARIES<p>As for Java itself, I&#x27;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&#x27;s leaps and bounds easier than regular Spring. This is probably a good starting point: <a href="https:&#x2F;&#x2F;start.spring.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;start.spring.io&#x2F;</a><p>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: <a href="https:&#x2F;&#x2F;spring.io&#x2F;quickstart" rel="nofollow">https:&#x2F;&#x2F;spring.io&#x2F;quickstart</a><p>Personally, I&#x27;d also look at Dropwizard, which is smaller, simpler and still good enough for many use cases, because it combines a variety of &quot;standard&quot; (popular) packages for Java webdev: <a href="https:&#x2F;&#x2F;www.dropwizard.io&#x2F;en&#x2F;latest&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.dropwizard.io&#x2F;en&#x2F;latest&#x2F;</a><p>It won&#x27;t be as smooth as Spring Boot, but I used recently for a small side project of mine: <a href="https:&#x2F;&#x2F;blog.kronis.dev&#x2F;tutorials&#x2F;2-4-pidgeot-a-system-for-millions-of-documents-the-application" rel="nofollow">https:&#x2F;&#x2F;blog.kronis.dev&#x2F;tutorials&#x2F;2-4-pidgeot-a-system-for-m...</a><p>Some folks might also enjoy Quarkus, which got some hype in the recent years: <a href="https:&#x2F;&#x2F;quarkus.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;quarkus.io&#x2F;</a><p>Those who like reactive programming, might look into Vert.X: <a href="https:&#x2F;&#x2F;vertx.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;vertx.io&#x2F;</a> (it doesn&#x27;t quite feel like idiomatic Java, but is interesting nonetheless)<p>There&#x27;s also Jakarta EE (formerly Java EE, formerly J2EE), which can be okay, but personally I&#x27;d avoid it in favor of one of the more popular options.<p>== FRONT END FRAMEWORKS &#x2F; LIBRARIES (if you want to use Java for these)<p>For some basic templating, Thymeleaf should be okay: <a href="https:&#x2F;&#x2F;www.thymeleaf.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.thymeleaf.org&#x2F;</a><p>There&#x27;s also Apache FreeMarker, Apache Velocity, JSP and JSF (I&#x27;ve seen it used with PrimeFaces). Those might also be viable, but I&#x27;ve had issues, especially with the latter ones. Regardless, here&#x27;s an article about some of them (for Spring): <a href="https:&#x2F;&#x2F;www.baeldung.com&#x2F;spring-template-engines" rel="nofollow">https:&#x2F;&#x2F;www.baeldung.com&#x2F;spring-template-engines</a><p>If you <i>really</i> want to do something more interactive but still in Java, you could use something like Vaadin: <a href="https:&#x2F;&#x2F;vaadin.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;vaadin.com&#x2F;</a><p>It&#x27;s okay, but in my eyes still probably more suitable for internal admin panels, rather than that many client facing applications.<p>Personally I&#x27;d avoid GWT, my experiences with it were only negative.<p>== SUMMARY<p>I&#x27;d say that Java is an okay fit for a back end language - if you can get JetBrains tools (IntelliJ), you&#x27;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.<p>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&#x2F;React&#x2F;Angular app from a web server directly (or maybe through a container) would probably be more simple, especially with a reverse proxy configuration.
评论 #34718666 未加载
abrookewood超过 2 年前
Of course you shouldn&#x27;t ... instead you should look at PHP, or Elixir, or maybe we should move it to SQLite ... hmm, maybe TypeScript is the way to go? What about Terraforming all the things - wait, what was the question? &#x2F;s<p>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.
whb07超过 2 年前
Would be interesting to see how far a J2EE app will take you on this!
评论 #34723049 未加载
nathants超过 2 年前
kotlin can do js with react!<p>check that out if you want to be single lang but not use js&#x2F;ts.
Allyedge超过 2 年前
I wouldn&#x27;t recommend JVM for web in 2023, but if you really want to use it, I would at least recommend Kotlin.<p>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.
评论 #34717989 未加载
评论 #34720973 未加载
评论 #34717461 未加载
acdha超过 2 年前
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.<p>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.
评论 #34720395 未加载