Why Python isn't the only way to build AI

Everyone says AI means Python. That is true for training models, and even there Python is only the remote control. But most developers will never train a model. They will build apps around one, and that is backend work in whatever language your backend already speaks.

An AI app equals a model plus a backend. A small dark card labelled Model, the brain, one API call, sits next to a much larger yellow sheet labelled Backend, everything else, listing log in and permissions, fetch the right data, check the answer, fall back to a human, log and audit, and plug into orders, payments and tickets. Beneath, callers in Python, Java, JavaScript, Go and C# all send the same HTTPS request to the model.
Fig. 1 — The model is one API call. Everything around it is the app, and that part is yours.

Open any AI tutorial and the first line is pip install. Every demo is a Python notebook. Every course starts with NumPy. So it is easy to believe the shortcut everyone repeats: AI = Python. And if you write Java, C#, Go or JavaScript for a living, it is easy to feel left behind.

The shortcut is half true. To see which half, you need one idea that clears up most of the confusion: there are two very different kinds of AI work.

Two kinds of AI work

Kind 1: training the model. You teach a model from data. That means a lot of maths, run on GPUs, for days or weeks. The result is a file of numbers called weights.

Kind 2: building the app around the model. You take a model that already exists and use it inside a product: a support bot, fraud alerts at a bank, a résumé screener in an HR portal, a search box that understands questions.

These two jobs need different skills, different tools and, often, different languages. Most of the “Python vs everything else” argument comes from mixing them up.

Kind 1: training is maths, and Python rules here

Training a neural network means multiplying and adjusting billions of numbers, again and again. The whole ecosystem for this lives in Python: PyTorch, JAX, NumPy, Jupyter notebooks, and almost every research paper’s code. If you want to train or fine-tune models, learn Python. There is no serious argument against that.

But here is the plot twist. Even during training, Python isn’t doing the maths.

Three layers of model training. Top, Python, a thin layer where you write model.train(). An arrow labelled tells it what to do leads to the middle layer, C++ and CUDA, a thick layer that does the actual number crunching. Another arrow leads to the bottom layer, the GPU, which runs it fast. Python is the remote control.
When you call model.train(), Python gives the orders. Compiled C++ and CUDA code does the heavy lifting on the GPU.

Python on its own is slow at number crunching. Libraries like PyTorch are thin Python layers over a core written in C++, which hands the heavy work to CUDA code running on the GPU. When you write loss.backward(), Python is pressing a button; the work happens far below it.

So Python won training not because it is fast, but because it is a great remote control: easy to write, quick to experiment with, and surrounded by the best libraries. That is a real strength. It just isn’t the whole story of AI.

Kind 2: most developers will use a model, not train one

Training a large model costs a fortune and takes a team of specialists. Only a handful of labs train the big models you hear about. Everyone else picks a finished model, from a provider like OpenAI, Anthropic or Google, or an open model they run locally, and builds something with it.

One model can sit behind many products: a support bot for a shop, fraud alerts for a bank, résumé screening for an HR portal, smart search in almost any app. In each case, the model is the brain. The app is everything else.

Let’s build one real feature: a support bot

A customer on an online shop opens the help chat and types:

Where is my order?

A good bot replies: “Order #4821 ships tomorrow and arrives Friday.” Simple, right? Now count the work behind that one reply.

  1. Call the model. Send the question to an LLM and get text back. One API call.
  2. Give it the right data. The model doesn’t know this customer’s orders. Your code has to fetch order #4821 from the database and put it in the prompt. (Do this at scale with documents and you have RAG.)
  3. Check what it said. LLMs can make things up. If the reply invents a delivery date that isn’t in the order record, don’t send it.
  4. Keep it safe. Make sure the user is logged in and can only ever see their own orders, never someone else’s, even if they try a clever prompt.
  5. Plug into what exists. Orders, payments, support tickets, logs: the bot has to work with systems the company already runs.

Five jobs. One is AI. Four are backend.

“Almost none of the work is the model. It is backend work.”

In code, the model is one line

Here is that bot as a backend endpoint. It is simplified Java to show the idea, but it would look much the same in any language:

@PostMapping("/help")
Reply help(User user, String q) {
    auth.check(user);                       // SAFE:     right user, right permissions
    var order = orders.find(user);          // DATA:     fetch their order from the DB
    var ans = llm.ask(q, order);            // AI:       the one line that calls the model
    if (!guard.ok(ans, order))              // CHECK:    no made-up dates or order numbers
        return tickets.human(q);            // FALLBACK: hand over to a person
    audit.log(user, q, ans);                // LOG:      who asked what, what we answered
    return Reply.of(ans);
}

One line is AI. The rest is login, database, checks, logging, and a fallback to a human. Those are the parts that decide whether the bot is safe to put in front of real customers, and none of them needs Python.

Backend work is what Java (and friends) already do well

Look at that list again: APIs, databases, security, permissions, audit logs, transactions, thousands of users at once, connecting to old systems. That is the home turf of backend languages, and Java has been doing it for decades in banks, airlines, e-commerce and telecom. C#, Go and Node.js teams have their own long track records too.

If your company’s orders, payments and logins already live in a Java (or C#, or Go) backend, the AI feature belongs next to them, written by the people who already know those systems. Rewriting everything in Python just to make one API call would be the expensive way round.

The model doesn’t care who calls it

A hosted model is just an API: you send an HTTPS request with some JSON, and you get JSON back. Any language can do that.

Language How it calls the model
Python requests.post(...) or the provider’s SDK
JavaScript / TypeScript fetch(...) or the provider’s SDK
Go net/http
C# HttpClient
Java java.net.http.HttpClient

It is the same request every time. The same is true for a local model served by Ollama: see calling Ollama from Python and calling Ollama from Java side by side.

And Java now has its own AI libraries that handle the plumbing for you:

  • Spring AI, from the Spring team, for Spring Boot apps. See Spring AI ChatClient.
  • LangChain4j, a Java library for prompts, memory, tools and RAG.

Both let you switch between model providers, get structured answers back as Java objects, add chat memory and give the model tools, without leaving the language your backend is written in.

So pick by the job

  • Training or fine-tuning models? Learn Python. That is where the libraries, papers and people are.
  • Building AI apps? Use the language your backend already speaks: Java, Python, JavaScript, Go or C#. The model will answer all of them the same way.

Python is a fine choice for the second job too, especially for prototypes and small teams. The point is not that Python is wrong. It is that Python is not the only way, and it is rarely a reason to throw away a backend that already works.

Key takeaways

  • There are two kinds of AI work: training models and building apps around them.
  • Training is maths-heavy and lives in Python, but even there Python is the remote control; C++ and CUDA do the heavy lifting on the GPU.
  • Most developers will use a model, not train one.
  • In a real AI feature, the model is often one line. The rest is backend: data, checks, security, logging and integration.
  • A model is just an API. Any language can call it, and Java has Spring AI and LangChain4j to make it easier.
  • AI app = model + backend. The model is the brain. Everything else is your job.

Frequently asked questions

Do I need Python to work in AI?

Only if you want to train, fine-tune or research models. To build products that use AI, you can work in the language your team already uses, because hosted and local models are reached through an API.

Is Python faster than Java for AI?

For training, the speed comes from C++ and CUDA code running on GPUs, not from Python itself. For apps that call a model, most of the waiting is the model’s response time, so the language of your backend makes little difference.

Can Java call ChatGPT, Claude or Gemini?

Yes. They are HTTPS APIs, so Java’s built-in HttpClient works, and Spring AI and LangChain4j wrap them with a friendlier interface. The Java for AI Engineers series walks through it step by step, starting with why Java for AI.

Should a beginner learn Python or Java for AI?

If your goal is data science or machine learning research, start with Python. If your goal is building software that uses AI, start with whichever backend language you are learning or using at work, and pick up enough Python later to read examples.

Comments

LEAVE A COMMENT
No sign-up. Comments appear after a quick review.