Description

What if there was a language built directly for LLMs? Programming languages today are designed for human use, which doesn't always line up with efficient LLM use. As humans read less code every day at the same LLMs generate more code, human readability becomes a primary limitation. Codon is a radical JS flavour that prioritises token efficiency above all else. Inspired by J, an array based programming language with mathematically compact properties, Codon turns the philosophy of programming languages from a question of taste to one of information-theoretical optimal design, employing mathematical, statistical, and iterative techniques such as first-class Level 2 AST Subtree Hashing and Code Deduplication to approach the optimal design. It is a language with evolution at its core, learning from its own mistakes to improve itself and incorporating continual statistical analysis of other languages guide approaches to shrink token count. And eventually, it will come to represent the smallest unit of meaningfully distinct living information: the codon.

Inspiration

When looking for an initial starting point to design information-optimal languages, we looked to older languages such as J and Lisp. The compact prefix notation of Lisp defined the early, naive design choices we made, but the array-based functional approach of J came to dominate our later mature design decisions.

What it does

Just like the three base pairs that make up a biological codon, three strategies form our approach to maximize token-efficiency: reinterpreting J's syntax for JavaScript, statistically driven modularization, and an iterative evolutionary approach that continually fine-tunes design decisions. Javascript is inherently a verbose language and continually evolves towards increasing verbosity with modern typed approaches to development. Thus, though Javascript is what Codon ultimately compiles to, we chose to foundationally diverge from the object-oriented design philosophy and logic of Javascript. We looked towards unconventional approaches of computing such as prefix notation, infix notation, and symmetry. As the demands for programming languages evolve, the philosophy of these languages should evolve with them. Thus, as Codon develops, we continually statistically analyse datasets of JavaScript applications to map the most commonly-occurring program blocks and patterns to single-digit token representations. Finally, acknowledging the limitations of our own intuition and ingenuity, we continually run a neural network to analyse the syntax and grammar of Codon to poke holes and weaknesses in our existing approach.

How we built it

Codon is built on 3 core concepts: Abstract Syntax Trees, modularity, and evolutionary refinement. Abstract Syntax Trees is the primary tool we use to interpret and manipulate code as concepts rather than a series of keywords. Since we can view a program as a tree, we can modularly search for automorphic structures in other programs, symbolising equivalent logical modules. Thus, we can find the large common modular code that can be shared to . It's difficult as human beings to set aside our human preferences when designing a language for optimal LLM use. To minimize human design bias, we set up an automatic evolutionary system where:

  1. An LLM proposes a revision to Codon's syntax and implements it in a new branch
  2. Another LLM uses revised syntax to write many benchmark applications
  3. If the revised syntax results in lower token usage, keep the revision and repeat the process. Otherwise, reset the branch to the previous revision, save the attempt for future iterations to avoid, and repeat the process.

Challenges we ran into

Coming into the project, we were strong believers in the efficiency and simplicity of Lisp languages and wanted to make Codon merely a Lisp representation of Javascript. However, after already coding a full transpiler that read and wrote directly into a Javascript Abstract Syntax Tree standard (ESTree), we realised that though Lisp was deeply character efficient, it was not token efficient. In most cases, it was hard for us to make our Lisp representations as token-efficient as standard Javascript. We came back to the drawing board and find a completely new foundation to build our language on. After research and intense internal debate on the philosophy of languages, we eventually decided to use J, the most token-compact programming language, as our foundation even though it was deeply unintuitive for us not only to write in, but also to simply wrap our heads around.

What's next for Codon

Codon is a project that is inherently designed with its own continual evolution in mind. Beyond its daily syntactical micro-iterations, we plan to eventually sever Codon's ties to Javascript and expand the standard to have equivalent representations in all of the largest languages in the world such as Python, C++, and Rust. Additionally, we plan to fine-tune Gemini to write Codon at an expert level without wasting tokens reading the Codon codebase or documentation.

Share this project:

Updates

Submission history