Guide · Open source
How to use Wenyan: install the CLI and run your first program
Updated · written with AI from the project's own documentation and checked against our catalogue data
Wenyan (文言) is a programming language whose syntax follows Classical Chinese grammar, so programs are written in literary Chinese characters instead of English keywords. This guide shows how to try it in the browser, install the command line compiler with npm, and run the included example. After reading, you will be able to run a Wenyan program and understand where to look next.
Quick start
- 1Open the Online IDE. Go to ide.wy-lang.org and try a small program in the browser. No installation is needed.
- 2Check Node.js and npm. Make sure Node.js with npm is available in your terminal, since the install uses npm.
- 3Install the compiler. Run npm install -g @wenyan/cli as shown in the README.
- 4Run the example. Run wenyan examples/helloworld.wy from a copy of the repository and check that it prints 問天地好在。.
- 5Read the syntax cheatsheet. Open the Syntax Cheatsheet on the project wiki to learn the grammar before writing your own program.
Try Wenyan in the browser without installing anything
The fastest way to start is the Online IDE at ide.wy-lang.org, which the README describes as a way to try small programs in the browser. You do not need to install anything to use it.
The project homepage is wy-lang.org, which links to the IDE and project resources.
Install the Wenyan command line compiler
Wenyan's command line compiler is distributed as the @wenyan/cli package. The README gives one install command. You need Node.js installed, since the install uses npm. The README does not state a required Node.js version, so use a current LTS release of Node.js and check the project's repository if the install fails.
- Prerequisite: Node.js with npm available on your terminal
- Install command from the README: npm install -g @wenyan/cli
npm install -g @wenyan/cliRun the included example program
After installing, the README suggests running one of the included examples. Pass a .wy file to the wenyan command. The README says this example prints the line shown in the comment.
The examples folder in the repository contains more programs, including the Sieve of Eratosthenes, Quicksort, a Mandelbrot set and the Tower of Hanoi.
- Run the example: wenyan examples/helloworld.wy
- Expected output according to the README: 問天地好在。
wenyan examples/helloworld.wyUnderstand the syntax basics
The README's Hello World program declares a number with 吾有一數。曰三。名之曰「甲」。, runs a loop with 為是「甲」遍。 and prints text with 書之。. It is equivalent to a short JavaScript loop that prints the same phrase three times.
Punctuation and newlines are optional, as in Classical Chinese. The README shows the same program written as one unbroken line, so the syntax is more flexible than typical code. The Syntax Cheatsheet on the project wiki lists the full grammar.
- Variables are declared with 吾有一數 (number) or 吾有一言 (text), then named with 名之曰
- Loops use the form 為是 ... 遍
- Output uses 書之
Compile to JavaScript, Python or Ruby
The README says Wenyan compiles to JavaScript, Python, or Ruby. The README's example shows the JavaScript equivalent of its Hello World program, which is useful for seeing how the Wenyan code maps to ordinary code.
The README does not describe the exact compiler flags for choosing a target, so check the Compiler API and Syntax pages on the wiki for those details.
Find documentation, packages and editor plugins
The README links to a Wiki with a Syntax Cheatsheet, a Standard Library Cheatsheet, a list of library packages and a Known Issues page. Wenyan also has a package manager called wyg (文淵閣) and a list of community packages, but the README does not detail how they work.
For editing, the README lists plugins for VSCode, Vim and Sublime Text.
- Syntax Cheatsheet and Standard Library Cheatsheet on the project wiki
- Plugins: VSCode, Vim and Sublime Text
- Decompiler: wenyanizer, which translates JavaScript to Wenyan
What people use it for
- Exploring how a programming language looks when its grammar comes from Classical Chinese
- Showing students how language design choices change code, using the README's JavaScript comparison
- Running the included examples such as the Sieve of Eratosthenes or Tower of Hanoi
- Trying small programs in the browser with the Online IDE
Frequently asked questions
Is Wenyan free to use?
Yes. The project is licensed under the MIT License, as stated in the listing. The MIT License permits use, and the README does not mention any paid tier.
What do I need to install Wenyan?
The README's install method uses npm, so you need Node.js with npm. The README does not state a specific Node.js version. You can also skip installation and use the Online IDE in your browser.
How do I install the Wenyan compiler?
Run npm install -g @wenyan/cli in your terminal, as shown in the README. Then run wenyan followed by a .wy file to execute a program.
Do I need to read Classical Chinese to use Wenyan?
Yes, the syntax is written entirely in Classical Chinese characters. The README's examples are the best place to see how the grammar looks.
What are the alternatives to Wenyan?
Comparable projects that are also playful or unusual languages include Brainfuck, Piet, Whitespace and Malbolge. Wenyan is different because its keywords come from Classical Chinese grammar rather than English.
Is Wenyan good for production software?
The README does not describe production use. The listing also notes the latest release is v0.3.4 with a last push in October 2023, so it is better suited to learning and experimenting.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Wenyan suits developers, Classical Chinese readers, teachers and students who want a novelty language to explore, especially through the browser IDE. Teams building production software or anyone who needs a large ecosystem should choose a mainstream language instead.
Install options & downloads