Support
Blog chevron_right Java

Frank Greco’s Deep Dive into AI and Java

On March 13, Azul gathered Java developers, enthusiasts, and Java Champions to celebrate 30 years of Java. An impressive lineup of luminaries gave presentations, including senior Java consultant Frank Greco. Frank discussed how AI, like programming languages including Java, is based on patterns, and gave specific guidance on AI and Java. 

Computer science. Java programming. Artificial intelligence. If you ask senior Java consultant Frank Greco, these seemingly unrelated things are all based on one thing – patterns. Because they are related, connecting to OpenAI or other AI models is straightforward. However, it’s important to keep in mind that different AI models have unique uses, and that irresponsible use of AI can be dangerous.

Frank started by explaining the fundamentals of AI as a pattern-matching tool. An avid musician, Frank analyzed melodies as his master’s project when he was still in school, studying probabilities. He generated a new melody, but in another style. “So that was generative AI,” he said. “Many, many decades ago, we didn’t call it generative AI. We called it computer science.”

How simple is connecting Java to an AI model? Frank demonstrated how to ask OpenAI to tell a funny joke about programming in Java with less than a page of code. He then used a popular library to connect to an LLM to complete a sentence, but you’ll have to watch his entire presentation to see it. 

IMAGE: How to tell OpenAI to tell a funny joke about programming in Java with less than a page of code.
How to tell OpenAI to tell a funny joke about programming in Java with less than a page of code.

The APIs may be simple, but you have to understand the foundations of AI. For instance, if you have an e-commerce library and you’re building an e-commerce system, you have to understand e-commerce. And you have to know how to use generative AI to use it responsibly and effectively. 

At the most fundamental level, patterns are the basis of everything. Frank talked through patterns in grunge, jazz, and blues music. Animals follow patterns to find food. 

What are AI and ML? 

AI is simulating human intelligence. Machine learning is about patterns. “So you’re not explicitly writing programs for the machine to detect patterns,” Frank said. “The machine is doing that.” 

There’s a subset of machine learning called deep learning, which has two subsets – predictive AI and generative AI. 

  • Predictive AI has been used for about 20 years, and it’s a big revenue generator, especially for companies like Google and Amazon. 
  • Generative AI can learn from and mimic large amounts of data to create new content, and it has been on fire for about the last three years. 

Focusing on generative AI, Frank said he divided things Java developers do on a daily basis into four categories: 

  1. Ideation – coming up with requirements and building prototypes 
  1. Development – writing code and performing unit tests 
  1. Deployment – putting things into production, tracking metrics, and integration testing 
  1. Maintenance – doing vendor updates, tech support, and issue tracking 

Only one of these categories involves code generation, but they will all be affected by generative AI. 

Natural language processing is not new 

Frank referenced a 2017 paper by Google called Attention Is All You Need. The paper focused on how we look at words. In particular, how words relate to one another. 

Relating again to Java, Frank said the transformer architecture the paper introduced allowed language models to be parallelizable. From a deployment perspective, this was the big idea. A neural network is trained. A neural network is full of random probabilities until data trains it. And as you feed more data to it, certain paths get strengthened. Before long, it can finish your text and find the most probable path through the neural network.

IMAGE: When you start to train a neural network, it is full of random numbers.
When you start to train a neural network, it is full of random numbers.
IMAGE: The more appropriate the context, the better the response.
Over time as you put in data, certain paths are strengthened.
IMAGE: As you add more context, you change the probabilities.
As you add more context, you change the probabilities.
IMAGE: As you add more context, you change the probabilities.
The more appropriate the context, the better the response.

Frank explained that you can use Java with AI without a library, since Java doesn’t have libraries built out yet like Python does. However, he warned that switching between AI models, say from Google Gemini to OpenAI, can be challenging. There are tools like Langchain4j that can be helpful, however. 

Frank closed by saying it’s important to be cautious. “Once you’re at a certain point,” he said, “then you have to involve your legal department saying, like, should we go forward with this? Are there ethical issues? Are there compliance issues? Are there regulatory issues?”

There was plenty more in Frank’s presentation. To see the whole thing, visit the Duke Turns 30 section of our website.