Explore Wenyan: The Ancient Chinese Syntax Language You Can Compile to JavaScript
The article introduces Wenyan, an esoteric programming language that lets developers write code in Classical Chinese characters, demonstrates "Hello World" and a prime‑number sieve example compiled to JavaScript, and provides installation, usage, and feature details for this open‑source, Turing‑complete language.
Wenyan: An Ancient Chinese Syntax Programming Language
Recently the Wenyan language project has gained popularity on GitHub, reaching over ten thousand stars. It allows developers to write programs using Classical Chinese characters, which can be compiled to JavaScript or Python.
Hello World in Wenyan
吾有一數。曰三。名之曰「甲」。
為是「甲」遍。
吾有一言。曰「「問天地好在。」」。書之。
云云。Compiled to JavaScript:
var n = 3;
for (var i = 0; i < n; i++) {
console.log("問天地好在。");
}Running the program prints the phrase three times.
Prime Numbers Example (Sieve of Eratosthenes)
The following Wenyan code implements the sieve algorithm for numbers up to 100.
var 埃氏篩 = () => 0;
埃氏篩 = function(甲) {
var 掩 = [];
for (var _rand1 = 0; _rand1 < 甲; _rand1++) {
掩.push(true);
};
var _ans1 = 甲 / 2;
var 甲半 = _ans1;
var 戊 = 2;
while (true) {
if (戊 == 甲半) { break; };
var 戌 = 2;
while (true) {
if (戌 == 甲半) { break; };
var _ans2 = 戊 * 戌;
var 合 = _ans2;
if (合 <= 甲) {
掩[合 - 1] = false;
} else { break; };
var _ans3 = 1 + 戌;
戌 = _ans3;
};
var _ans4 = 1 + 戊;
戊 = _ans4;
};
var 諸素 = [];
var 戊 = 2;
while (true) {
if (戊 == 掩.length) { break; };
var _ans5 = 掩[戊 - 1];
var 素耶 = _ans5;
if (素耶) { 諸素.push(戊); };
var _ans6 = 1 + 戊;
戊 = _ans6;
};
return 諸素
};
var _ans7 = 埃氏篩(100);
console.log(_ans7);Running the program outputs the list of prime numbers below 100:
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97Key Features
Compiles to JavaScript or Python
Turing‑complete
Online IDE and compiler
Open‑source implementation
Installation & Usage
Clone the repository, give the wenyan.js script execution permission, and run it with the desired source file:
git clone https://github.com/LingDong-/wenyan-lang
chmod +x ./build/wenyan.js
./build/wenyan.js examples/helloworld.wy -o helloworld.jsThe CLI supports options such as --eval, --exec, --lang, and others (see the usage section).
Resources
Project repository: https://github.com/LingDong-/wenyan-lang
Project homepage: http://wenyan-lang.lingdong.works/
Online IDE: http://wenyan-lang.lingdong.works/ide.html
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
