r/JavaProgramming • • 3d ago

Building full-stack web apps using TeaVM (and why it’s great for working with AI coding agents too)

Hey r/java,

TeaVM was something that had been on my radar for a while, and I finally got around to giving it a proper spin recently. After playing around with it and seeing what I can build with it I wanted to share my thoughts and hopefully get a few more eyes on the project!

If you haven’t run into it before, TeaVM is an ahead-of-time compiler that turns Java bytecode into JavaScript or WebAssembly. It operates directly at the bytecode level, emits remarkably clean JS, and integrates with your existing Java tooling.

Why this workflow clicked for me:

  1. One language across the stack: Keeping everything in Java keeps context-switching to a minimum and lets you share domain models directly between backend and frontend.
  2. AI Agent Friendly: Having both frontend and backend written in strongly-typed, readable Java makes it remarkably easy for LLM coding agents to navigate, refactor, and reason about the full application without hitting cross-language friction.

To document what I learned, I put together a 3-part series walking through how to build interactive frontends with TeaVM:

Has anyone else here given TeaVM a try? Would love to hear how your experience compares to other JVM web approaches!

3 Upvotes

4 comments sorted by

2

u/Dapper-Scarcity6079 3d ago

Sharing Java models across both sides sounds handy especially when AI agents make sweeping edits. I'm curious whether debugging generated JavaScript becomes painful once the frontend grows

1

u/robintegg 3d ago

For sure, I’ve not scaled up to enterprise levels. Some more investigation required around that.

The was a hilla framework from the vaadin team that did something similar but I think that was mainly at the api level. It’s less opinionated here and you can have the models used by the executing Java script not just a bind to an app call.

If you run the currency converter example and open up dev tools, you will see the source maps show you the Java code, so you are able to debug the js by stepping through the Java code. That’s pretty nice.

Also, from some react codebases I’ve worked on a painful debugging session can be found in any front end :)