What’s the best programming language for AI?

The video explains that the best programming languages for AI code generation are those with clear syntax and strong, standardized documentation, rather than just popularity or training data volume. Elixir and C# outperform more mainstream languages like Python and JavaScript in AI benchmarks because their ecosystems enforce high documentation standards and code clarity, making them more accessible for AI models.

The video explores the question of which programming language is best for AI, specifically focusing on how large language models (LLMs) perform when coding in different languages. The creator references the Autocodebench benchmark by Tencent, which evaluates how well AI models handle various programming languages. Contrary to popular belief, the top-performing languages are not the usual suspects like Python, TypeScript, or Rust. Instead, the benchmark reveals surprising results, with languages like Elixir and C# outperforming more mainstream choices in terms of AI code generation and problem-solving accuracy.

The presenter discusses what makes a programming language “good” for both humans and AI. For humans, subjective preferences such as readability, simplicity, and personal comfort play a significant role. For AI, however, factors like the amount and quality of training data, simplicity of syntax, token efficiency, feedback mechanisms (such as type safety), and especially the quality and accessibility of documentation are crucial. The video highlights that languages with strong, standardized documentation and fewer ways to solve a problem tend to be easier for AI models to handle effectively.

A deep dive into Elixir reveals why it scores so highly in AI benchmarks. Elixir’s syntax is clear and concise, with features like piping and pattern matching that make code both readable and expressive. More importantly, Elixir’s ecosystem, particularly its package manager Hex, enforces high standards for documentation. Every package comes with built-in, up-to-date documentation that is tightly coupled with the source code, making it easy for both humans and AI models to understand and use libraries correctly. This collocation of code and documentation is a major advantage for AI code generation.

The video also compares Elixir’s strengths to those of C#, another high-scoring language in the benchmark. C# similarly benefits from excellent documentation standards, with XML comments and auto-generated docs being common practice. The presenter theorizes that languages with fewer, well-documented solutions to common problems, and with clear external dependencies, are more accessible to AI models. In contrast, languages like TypeScript and JavaScript, despite having vast amounts of training data, suffer from too many possible solutions and inconsistent documentation, making it harder for AI to consistently generate correct code.

In conclusion, the video suggests that the best programming languages for AI are not necessarily the most popular or the ones with the most data, but those with clear syntax, strong documentation practices, and a culture of code clarity. Elixir, in particular, stands out due to its readable syntax and enforced documentation standards, making it exceptionally AI-friendly. The presenter encourages viewers to consider these factors when choosing languages for AI-driven development and expresses hope that languages like Elixir might gain more recognition in the AI era.