Purpose
English Compiler aims to directly compile Markdown functional specifications written in English (or other natural languages) into functional code. It attempts to validate an idea: AI can become a new abstraction compilation layer on top of existing modern programming languages, just as modern programming languages abstract operating system APIs.
Main capabilities
- Convert Markdown-format
.spec.mdspecification files into code files in the corresponding language. - Support generating complete cross-file applications, such as a Twitter clone without login authentication (including UI and API endpoints).
- Support generating large Java classes exceeding 4000 tokens in length, which is difficult to do by directly calling the OpenAI API.
- Bypass OpenAI model input and output length limits through complex prompt chain engineering to achieve large file generation.
- Optionally generate JavaScript test scripts (avoiding contamination of source code through a separate process).
- Provide a command-line tool that can build for a single specification file or an entire project.
Usage
- Install via NPM: specific commands are not yet provided, but the official statement says the simplest installation method is to install from NPM.
- Create a
specsfolder and asrcsource code folder in the project, and set up aenglish-compiler.jsoncconfiguration file, which needs to include settings such as the OpenAI API key. The official reminder is not to commit the API key to a public repository. - Specification files are placed in the specification folder, named
$NAME.spec.md, corresponding one-to-one with individual code files. - Specification files contain at least Markdown frontmatter, in which the
typeparameter specifies the target language; the optionaltestparameter (only JavaScript is supported) will attempt to generate related test scripts. - Command-line examples:
- Ask the AI for suggestions on a specification file:
EnglishCompiler spec suggest spec/ui/index.spec.md - Build a single specification file:
EnglishCompiler build file spec/core/db.spec.md - Build all specification files:
EnglishCompiler build all
- Ask the AI for suggestions on a specification file:
- Provide demo projects:
demo/twitter-clone(Twitter clone) anddemo/java-class(Large Java class), the demo has pre-built caches and specification files for the AI compilation process, as well as pre-built code output.
Applicable scenarios
- Experimentation and proof-of-concept by developers interested in AI-driven code generation paradigms.
- Scenarios that require automatically generating code prototypes from detailed functional specifications.
- Scenarios where you want to generate large code files that exceed the usual API limits (for example, large Java classes); this project provides an example of bypassing the limits.
Limitations
- Explicitly a "proof of concept" (POC), far from production-ready.
- The output code may contain a small number of errors; developers trying to fix these errors take a long time, and the write-compile-test loop is slow.
- Low performance: generating a large code file requires multiple calls to the AI process (possibly more than 10 calls per file), and the overall process is very slow.
- When ChatGPT is overloaded, compilation may fail.
- Depends on the OpenAI API, requires providing an API key, and the key must not be made public.
- The test generation feature only supports JavaScript.
- It is officially described as inefficient, and the current iteration may have no practical commercial value.
- The project already has a successor, smol-dev-js (https://github.com/PicoCreator/smol-dev-js),但本仓库仍作为独立 POC exists.