logo

A Bold Claim: Java Will Be Abandoned by Many in the AI-Assisted Coding Era

Apr 26, 2025 · 783 words

Recently, I've been working on an MCP-related project at my company. For certain reasons, I needed to create the same demo in both Python and Java. I used Cursor to write both versions, and the process was quite surprising.

I started with the Python version first. Beginning from a working example project, I described my requirements and let Cursor write the code. The whole process went very smoothly. Cursor provided all the code and example instructions. There was one bug in the code, but after describing the bug to Cursor, it quickly fixed it.

After the success with Python, I started writing the Java version. The overall code logic wasn't complex, but writing it in Java was more verbose. To make code review easier, I only asked Cursor to modify a small part at a time based on the current code. Surprisingly, I was quite dissatisfied with the Java code Cursor wrote - sometimes parameters were in the wrong position, sometimes there were extra parameters. And when I asked Cursor to correct the errors, it wasn't very obedient.

Left with no choice, I had to manually modify the code Cursor produced. When asking Cursor to write the next part, I wrote a more detailed prompt, specifying which file to modify, what the modifications should look like, and which code to reference. Only then did Cursor finally write code obediently.

After finishing the code, I couldn't help but think: why does Cursor perform differently with Python and Java code for the same functionality? Although writing good prompts can make Cursor write Java code smoothly, does this mean that certain shortcomings of Java prevent Cursor from handling it easily?

After reflection, I arrived at an immature conclusion:

Java's advantages in traditional software projects may be precisely its disadvantages in AI-assisted programming.

First, Java is verbose to write. This verbosity makes it easier to write and harder to produce weird bugs. Java can easily maintain medium to large projects with tens of thousands of lines of code. However, for AI-assisted programming, large code volume is a disadvantage.

The lifeblood of large language models is context - the more information you can fit into the context, the more the model can understand. For the same functionality, Java code requires much more than Python (rough estimate: what takes ~300 lines in Python requires ~1000 lines in Java for my project). So when reading the same number of tokens, Java code contains much less information, making it harder for the model to understand your intent.

Second, Java tends to spawn various "frameworks," with "interfaces," "inheritance," and "design patterns" everywhere. This is certainly good for traditional team collaboration - everyone follows the same framework, making code easier to maintain. But this is difficult for AI. AI needs to first understand your entire code framework before it can write appropriate code within it. You need to @ all relevant files in Cursor. If you forget to @ a file and Cursor doesn't automatically recognize it needs to reference this file, the code it writes might be wrong.

There's actually a saying that makes sense: "Design patterns are essentially compensating for limitations in the language itself." For example, a strategy pattern that takes five or six classes to implement in Java only requires passing a function object in Python. For AI, Python's approach is obviously easier to understand because it only needs to look at one file. Whereas Java's design pattern requires looking at five or six classes, adding a whole level of complexity.

After this experience, I'll be more cautious about choosing Java in future projects.

If I were to write a full-stack project, I might have previously used SpringBoot for the backend (because I'm most familiar with it), but now considering AI-assisted programming, I'd be more willing to use Python or Node.js because they're more suitable for having Cursor help me write code.

This is why I think Java will be abandoned by many people. Imagine a startup team making technology choices with only a few people - considering AI-assisted programming, they probably won't choose Java. And when the project scales up, they may not migrate to Java either, because if the team uses a Python/Node.js tech stack, it likely won't be compatible with the Java stack.

Of course, there's also the possibility that team members are already in the Java tech stack, in which case choosing Java is fine. But then you need a tech lead to oversee the Java code writing approach - you can't write a bunch of code that looks cool but AI can't understand anymore. Also, use newer versions of Java - the var keyword and multi-line strings can simplify a lot of code syntax. Stop clinging to Java 8.