HACKER Q&A
📣 fragmede

Is Java the ideal language for LLM-assisted coding?


Which programming language to use, now that LLMs are writing code, is at the forefront of everybody's minds when they start a new project.

Python, Rust, C++, Golang, and Swift come to mind for me, depending on the project, but I'm starting to think Java is actually the ideal LLM language, especially with LLM-driven sysadmin-ing making it easier to set up and run Java.


  👤 mullingitover Accepted Answer ✓
Like humans, I’ve never seen an LLM write Java voluntarily.

They write python as readily as people breathe, though.


👤 armada1122
The argument that Java is LLM-friendly because its specifications enforce these four factors makes sense, but conversely, other languages that satisfy these four criteria—such as TypeScript, Kotlin, and Rust—fall into the same category.

In my own Python code, after tightening up Pydantic + strict mypy + pytest, I’ve noticed a significant increase in Claude’s first-pass accuracy. I believe which conventions you adopt within a language is more important than the language itself.

Additionally, a pitfall specific to Java is that the training data still contains a large amount of Spring XML/AbstractBeanFactoryAware-style patterns from the old Java 7–8 era. To elicit modern Java 21+ idioms, you need to specify them explicitly in the prompt. Conversely, Python tends to produce the latest idioms by default.

I understand the OP’s intuition (that Java is being reevaluated due to improvements in infrastructure tools), but the essence lies in “language design that enforces LLM-friendly coding styles.” In that sense, my personal conclusion is that Java is one of the good fits.