Can a New Programming Language Make AI-Generated Code More Reliable?

June 18, 2025

A thought-provoking Hacker News discussion initiated by a user named Baijum explored the intriguing question: do we need a programming language specifically designed for AI code generation, with human review as a key part of the workflow? The original poster envisioned a language prioritizing absolute, unambiguous clarity over common developer conveniences to improve the reliability and reviewability of AI-generated code.

The Vision: An AI-First Programming Language

The initial proposal suggested several core features for such a language:

  • Reduced Syntactic Sugar: For instance, having only one explicit way to write a for loop to make AI output more predictable.
  • Extreme Explicitness: Mandating constructs like fn foo(none) if a function takes no parameters, removing potential ambiguity.
  • Built-in Safety Guarantees: Features like mandatory visibility modifiers (pub/priv) and explicit ownership annotations for FFI calls, making safety aspects instantly clear to human reviewers.

The central question was whether such a language, while potentially challenging for direct human use in day-to-day tasks, could provide higher confidence in the code generated by AIs like Copilot.

Core Challenges: LLM Nature and the Training Data Dilemma

User dtagames quickly pointed out fundamental hurdles. Firstly, Large Language Models (LLMs) operate probabilistically, making predictions rather than retrieving exact answers like a database. A new language, regardless of its design, wouldn't alter this core characteristic or eliminate the inherent unreliability of LLMs.

Secondly, for an LLM to effectively generate code in a new language, it would need to be trained on a vast quantity of code written in that language – a classic chicken-and-egg problem, as this corpus wouldn't exist initially.

Reframing the Goal: From Error Elimination to Error Transformation

In response to these valid criticisms, Baijum (the original poster) offered a compelling reframing of the objective. If eliminating LLM errors is unfeasible, perhaps the nature of these errors could be changed. The hypothesis then became: could a language's grammar be designed to make an LLM's probabilistic errors fail loudly as obvious syntactic errors, easily caught by a compiler, rather than manifesting as subtle, hard-to-detect semantic bugs at runtime?

This reframing suggests that extreme explicitness and a lack of default behaviors could force an LLM's failure to generate a required token into a straightforward compile-time error, acting as a safer "harness" for AI output.

The Human Element: Usability and Existing Analogies

dtagames countered this by noting that highly explicit languages already exist in the form of machine code or assembly. While these languages meet the criteria of explicitness and lack of ambiguity, they are notoriously difficult and tedious for humans to write, which is precisely why higher-level languages were developed.

This highlights a fundamental tension: the utility of LLMs often comes from their ability to understand and process natural language prompts (e.g., "What is the difference between 'let' and 'const' in JS?"). This natural language understanding capability is intrinsically linked to their predictive, and thus somewhat unreliable, nature. Sacrificing this for a rigid, formal system might undermine the very benefits LLMs offer.

Alternative Perspectives on Language Design for LLMs

User muzani introduced an interesting, somewhat counter-intuitive point. Instead of extreme conciseness and removal of syntactic sugar, LLMs might actually perform better with languages that are more verbose and human-readable, akin to spoken languages with built-in redundancies. The example given was that LLMs often handle YAML (more verbose, human-readable) better than JSON (more compact, stricter). This suggests that increasing token count (often associated with verbosity) isn't just a cost factor but can impact output quality, potentially favoring languages that are easier for the LLM to "reason" about in a human-like way.

Learning Beyond Source Code: Documentation, Formalization, and Current Tools

The discussion also touched upon how LLMs might learn or be guided beyond just being trained on massive source code datasets.

  • FloatArtifact questioned why LLMs couldn't be trained to code primarily from documentation, mapping logical concepts to symbols.
  • dtagames responded that tools like Cursor can already leverage documentation or user-provided descriptions (e.g., in Markdown) to generate code conforming to new or project-specific syntax, even if that syntax wasn't in the original training set. FloatArtifact acknowledged this but noted it's not the primary training method.
  • theGeatZhopa emphasized the need for formalization and for LLMs to be trained on these formalizations, expressing skepticism that system prompts alone could enforce the required level of exactness.

Baijum later shared a link to the GenLM Control project, suggesting it as a potential avenue for exploring new languages or language control mechanisms for LLMs.

Conclusion: A Complex Balancing Act

The debate underscores that while designing a programming language with AI generation in mind could offer benefits in terms of code predictability and error manifestation, it's not a silver bullet. The inherent probabilistic nature of LLMs, the substantial challenge of training data, and the crucial factor of human usability present significant obstacles. The most promising path forward may involve a combination of thoughtful language design that aims to make errors more obvious, alongside advancements in how LLMs are trained and prompted, perhaps incorporating more formal specifications and documentation directly into their learning process. The ideal solution will likely need to strike a delicate balance between machine generatability, human readability and reviewability, and the fundamental strengths and weaknesses of AI.

Get the most insightful discussions and trending stories delivered to your inbox, every Wednesday.