AI-Driven Program Generation―Possibilities and Challenges
In recent years, generative AI has advanced to the point where it can generate source code from natural language prompts. This has enabled partial automation of what was previously manual implementation, raising expectations for improved development efficiency.
However, when applying code generation in actual development environments, issues such as "accuracy," "deviation from specifications," and "maintenance cost" are expected to arise. This article focuses on areas such as UI programming and DSL design, organizing the challenges and potential of generative AI.
Issues with Natural Language Prompts
AI-based code generation often starts with specifying requirements through natural language prompts.
However, natural language has the following characteristics:
-
Ambiguity and polysemy
-
Omission and vague conditions
-
Difficulty in maintaining structured consistency
As a result, the generated code may have low fidelity to the intended specification.
When corrections are needed, developers must experiment with rephrasing the prompts and rerunning them, which reduces efficiency.
UI Programming and Code Generation
On the other hand, there are fields where code generation tends to succeed more easily, with UI programming being a prime example.
From the perspective of code generation, UI programming has the following characteristics:
-
Boilerplate code is abundant
-
Highly patterned structures, easy to abstract
-
Relatively clear separation between structure and presentation
In the past, tools called "GUI builders" emerged, enabling developers to visually compose screen layouts. Examples include the form designers of Visual Basic and Delphi, as well as the GUI builder of NetBeans.
However, these tools had practical limitations. For example, fully automating the connection between screen code and application logic proved difficult.
Now, by combining them with generative AI, new possibilities are emerging to reduce the gap between specifications and implementation that was previously difficult to overcome.
Three Key Factors for High-Precision Generation
The following are three factors that contribute to achieving high-precision UI code generation.
-
UI Mockups
-
Serve as a clear and visual specification
-
Can be treated as a type of DSL
-
-
Behavioral Patterns
-
Typical actions such as button clicks, list selections, and form submissions can be categorized into patterns
-
-
Application Logic Specifications
-
Can be defined in a machine-readable way using IDLs (Interface Definition Languages) such as OpenAPI or gRPC
-
Traditionally, the integration between these elements required manual creation of boilerplate code, which was a bottleneck. However, generative AI now offers the possibility of automating this integration.
Improving Accuracy with a DSL Approach
Beyond UI programming, introducing a Domain-Specific Language (DSL) for each problem domain is an effective way to eliminate ambiguity in specifications and achieve high-precision code generation.
-
The process of designing a DSL enables modeling of the domain’s structures, concepts, and rules
-
By using a model compiler, executable code can be generated directly from specifications
-
AI can be leveraged to assist in DSL design and provide auto-completion of DSL descriptions
Developing a model compiler requires significant effort, but generative AI can substantially reduce the workload by generating code skeletons and transformation logic.
With both a DSL and a model compiler in place, code consistency is ensured at the specification level, preventing variations in generated results. In this case, the object of review shifts from the prompt to the DSL document itself. Needless to say, AI can play a major role in both authoring and reviewing DSL documents.

Practice in SimpleModeling
In SimpleModeling, SmartDox is adopted as the meta-language for DSLs. SmartDox is a text-based documentation format for technical writing that combines features of Markdown, org-mode, and Asciidoc. It is also used for writing the articles on this site.
When SmartDox is used as a meta-language for DSLs, its structured part is called ModelDox. ModelDox represents the model description core within a SmartDox document and serves as the foundation of the DSL.
By embedding structured elements into ordinary text and extracting them as a modeling DSL, SimpleModeling realizes literate modeling. CML (Cozy Modeling Language) is a DSL for object model descriptions, using ModelDox as its meta-language.
Cozy is a model compiler that generates source code such as Scala from CML, enabling literate model-driven development while keeping documentation and code synchronized.
Literate model-driven development with Cozy has the following advantages:
-
Allows natural language explanations and structured specifications to coexist
-
Structured parts are machine-readable, enabling precise processing by generative AI and compilers
-
Documents and code remain closely aligned, making it easier to adapt to specification changes

Conclusion
Generative AI demonstrates significant power in program generation when combined with well-structured specifications. In particular, in areas such as UI and DSLs, high-precision specifications like mockups or IDLs, together with model compilers, enable more accurate and maintainable code generation than before.
Generative AI is not all-powerful; it becomes practical and sustainable only when combined with structured DSLs.
An approach like SimpleModeling—which integrates natural language documentation with structured specifications and combines generative AI with model-driven development—will likely become a powerful option for future development styles.