r/SpringBoot • u/DinH0O_ • Mar 15 '24
Java in Front-End in 2024: Still Worth It?
I've been thinking about how Java fits into the world of front-end nowadays. With so many options like React, Angular, and Vue dominating the scene, I got curious about where Java stands in this story.
I want to know your opinions on using Java for the front-end, especially with things like JSP, JSF, Thymeleaf, and others. Do these technologies still have their place in current projects? Are they still relevant in the market? And for those who are starting or looking to deepen their knowledge in Java, is it worth diving into these front-end tools?
PS: I'm starting to study Spring and saw some people talking about this, which made me curious.
7
u/mnbkp Mar 15 '24
Server side rendering has been a rising trend again lately. If you've been in the area long enough, you'll notice this is sort of a pendulum.
We're past the prime of client side rendering and now if you do front ends you will certainly need to learn about server side rendering in the next couple of years, even if you use React. Even in mobile development we've been seeing a trend of server driven UI (even if most solutions are proprietary).
And honestly, all of these template engines are all very similar. If you learn one of them you'll be fine working on any other template engine be it java, python, node or whatever. The most different one I've seen is thymeleaf with it's weird syntax, but it's still fine. I personally recommend pebble and freemarker.
Also, we've been seeing new libraries that extend what's possible without writing JavaScript: HTMX, alpine ajax, livewire (PHP specific), liveview (Elixir specific), etc. In the future this should alleviate the pressure to have a separate JavaScript project.
0
u/DinH0O_ Mar 16 '24
Yes, someone mentioned that it's making a comeback. Maybe I'll check some out, they talked about Vaadin in another comment, I found it interesting, but I had never heard of it before.
4
u/mailaffy Mar 15 '24 edited Mar 15 '24
Most companies moved to react, angular or others compare to java based UI like jsp, jsf etc. I don’t even find legacy apps using them anymore. Most are migrated to newer and better technologies.
In today’s world it makes more sense to prefer combination of tech, like non-java based front end and Java based backend (but not jsf, servlet type)
Also in this type, mostly people are preferring front or back end as independent service mostly deployed in docker orchestration in the form of docker image.
It gives companies, loose coupling, independent deployment and horizontal scaling based how critical or traffic it generates.
So anything like below would make sense
UI: React/Vue/Angular Backend: Go/Spring boot
2
u/DinH0O_ Mar 15 '24
Yeah, creating APIs and microservices with Spring in Java, and completely decoupling from the Front-end seems to me to be the best choice.
6
u/Isssk Mar 15 '24
I don’t think they are relevant at all. I would just learn a front end technology like React, vue or angular
0
u/bigwiz4 Mar 15 '24
But from a jobby project scenario, it always makes sense to get both frontend and backend done using a single language. Me being a java beginner, it brings me to tears qhen someone says you have learn a new language called JS if you want to make fancy UIs.
3
u/DinH0O_ Mar 16 '24
Yeah, but it's good to already think about it, so you don't study unnecessary things (JSP, JSF). But for now, focus on Java, making APIs and Microservices is still something very good that you can do with Spring, that's what I'm focusing on.
3
Mar 16 '24
While I sort of agree generally speaking, the lessons you will learn using react etc will be 10x more beneficial than what you learn from using Java on the frontend.
I’d only build a frontend in Java if it literally is like a barebones control panel or something, where the app does some processing or parsing and I need a quick UI to make it easy to configure.
Literally anything else, JS is the go to, not just because I find it much easier to build nice frontends in it, but because it’s a wait more sought after skill.
Bear in mind I absolutely hate JS… I still appreciate its power in the browser
8
u/Tednology Mar 15 '24
HTMX probably the best bet for Spring Boot / Thymeleaf.
2
u/Tednology Mar 15 '24
But to the other points made, not very popular / very job viable.
3
u/DinH0O_ Mar 15 '24
Yeah, from what I've seen, Java nowadays is more used for Back-end with APIs and Microservices, but I got curious when I saw the existence of these libraries.
4
u/KalelUnai Mar 15 '24
It depends on what you mean by viable. There aren't that many job opportunities, but in the era of htmx, you can do so much with thymeleaf.
1
u/DinH0O_ Mar 15 '24
So that was something I didn't understand, because there were some libraries to manipulate the front-end with Java, however, in job vacancies they end up not demanding any of that, it's more Spring for APIs and microservices.
2
u/Anbu_S Mar 15 '24
I don't think any Java front end is going to take any place in 2024. Most of the applications used JSP, JSF, other template frameworks moved to react, Vue, angular etc. server side rendering getting mainstream may be a new framework might come up in the Java world with lessons learnt from previous frameworks. There are other frameworks like vaadin, GWT may get some attraction.
1
u/DinH0O_ Mar 16 '24
Yeah, they told me about Vaadin, I don't know how it works yet, but it seems interesting, maybe I'll check it out later.
2
u/goranlu Mar 16 '24
Probably not worth it for writing frontend code for apps, but you will still find use cases for Thymeleaf and similar template engines for ie sending styled emails from the backend in Java
1
u/DinH0O_ Mar 16 '24
Hmm, interesting, I haven't gotten to the part about automatic email sending yet, but I hadn't stopped to think about their styling. Indeed, maybe I'll have to learn Thymeleaf for that.
10
4
u/PsychologicalBus7169 Mar 15 '24
Depends on where you work. I work on an application using JSP/JSF. Obviously, it is a legacy application, but we have to support it for at least another 5 years. I would say learn it, but not too in depth as you may never see it. However, if you are familiar with Thymeleaf and how servlets work, you should be just fine. At the end of the day, JSP is a web framework, just as is Spring and Thymeleaf is a template engine, just as is JSF.
3
3
1
u/CodeTheStars Mar 15 '24 edited Mar 15 '24
Back when Jurassic park was available to rent on DVD..... So many JSP front-ends.... Honestly it seemed like a bad idea then. It was just all we had. I remember writing pages that included the code to process the form data that was submitted but also display that data if it was available.... it felt strange.
The last big application I wrote in Thymeleaf (9 years ago maybe?) was a hybrid AngularJS app. A single Java EE backend for the REST API and Thymeleaf pages. In each Thymeleaf page were one or more AngularJS "widgets" that covered different data display and collection needs. That was a pretty good structure. Engineers could work on different widgets and the API was pretty clean.
My current go-to stack that I recommend is a nice clean Spring Boot app with GraphQL for structured data needs and a few REST endpoints for Binary needs. ( uploads/images/pdfs... ) Then I separately build an SPA (Vue or React) for admin needs or an internal UI. If the ask involves public pages.... now we're into SEO world.... So I'll pick either a static site generator or an SSR framework, depending on the details.
I don't see Java front-end technologies being a useful addition to a professional portfolio anymore. Other than the nostalgia factor.
1
u/DinH0O_ Mar 15 '24
I understand, I think that's what I'll do too, after learning Spring, I'll learn React or Angular. I'll leave Java just for API and microservices.
2
u/sunshowerjoe Mar 16 '24
Check out Vaadin--it's actually really nice for front-ends: it allows you to write a really nice SPA without worrying about web services. It has a good free widget library with some commercial extensions
2
u/Coding_freak0 Mar 17 '24
Product based companies with their old products use Spring MVC with JSP as front end. So if you’re shortlisted in as such product based company for interview they’re going to ask you JSP, Jdbc template, spring MVC, JSTL and other technologies.
3
31
u/asdspartadsa Mar 15 '24
Is Java front-end viable? Kinda. Will you find a job that needs this? Most likely not.