Prompt engineering is evolving rapidly. We’ve moved from simple sentences to complex JSON structures, but why stop there? Today, I want to share a fascinating experiment: using Object-Oriented Programming (OOP) and Clojure S-expressions to control Google’s “Nano Banana” (Gemini-based) image generation logic.

Contents
The Spark: From JSON to Logic
It all started with a viral post on X by @siennalovesai. The post featured a highly structured JSON prompt designed for the “Nano Banana” engine to achieve near-perfect photorealistic consistency.
While JSON is great for data, as a developer, I wondered: Can we make this even more “programmable”? Could we use the strictness of Java or the elegance of Clojure to define a visual scene?
The Experiment: Coding a Scene
I took the core logic of the Nano Banana prompt and refactored it into two different programming paradigms.
1. The Java Approach (OOP Prompting) In my Java Gist
, I defined the scene as a class: RetroEditorialScene. By using objects like Subject, Pose, and Environment, the prompt becomes a set of strict definitions.
Subject subject = new Subject();
subject.face = new Face("soft oval", "light hazel", "closed");
pose.arms.left = new ArmState("bent", "forearm support on carpet", 95);
This method forces the AI to treat each attribute as a class property, reducing “pose drift” and ensuring that anatomy and lighting constraints are handled with high priority.
2. The Clojure Approach (Functional Blueprints) Next, I explored Clojure S-expressions. Clojure’s nested map structure is incredibly powerful for AI “Rendering Engines.”
(defn generate-retro-editorial [ctx]
(-> ctx
(nb/init-scene "PX-LOCK-EDITORIAL" "1.0")
(nb/apply-constraints constraints)
(nb/define-subject {...})))
Using a functional pipeline (->) to “build” the image step-by-step mimics how a rendering engine processes a scene. It feels less like telling a story to the AI and more like writing a deployment script for a visual asset.
Why “OOP Prompting” Works
The “Nano Banana” engine responds remarkably well to code-like structures. Here’s why this is exciting:
- Strict Constraints: Code structures signal the AI to minimize “hallucination” and follow the provided parameters precisely.
- Modularity: You can easily swap out a
Wardrobeobject or change aLightingfunction without rewriting the entire prompt. - Developer Workflow: For those of us who live in IntelliJ or VS Code, writing prompts in Java or Clojure feels natural and organized.
Wrapping Up
Prompting is no longer just “talking to a bot.” It’s becoming a form of Visual Scripting. By applying software engineering principles—like OOP and functional programming—to AI instructions, we can achieve levels of detail and consistency that were previously impossible.
What do you think? Would you rather “write” or “code” your next AI masterpiece?
Check out my full code experiments here: