Fundamentals 6 min read

What Is Lingdong? The Classical Chinese Programming Language That Compiles to JavaScript and Python

Lingdong is a novel programming language based on Classical Chinese, created by a CMU senior, that can compile to JavaScript or Python, features an online IDE, showcases examples like Hello World and prime sieves, and has gained rapid popularity on GitHub with thousands of stars and forks.

21CTO
21CTO
21CTO
What Is Lingdong? The Classical Chinese Programming Language That Compiles to JavaScript and Python

Recently, a programming project written in Classical Chinese (文言文) has attracted widespread attention on Chinese social media. Even Liu Qun, a senior researcher at the Institute of Computing Technology, Chinese Academy of Sciences, praised the project, calling the new developers "formidable".

The project, named Lingdong , was developed by a senior Carnegie Mellon University student. It can compile to JavaScript or Python and provides an online editor. On GitHub it has earned over 7 K stars and 324 forks, topping the daily GitHub Trending list with more than 4 000 stars in a single day.

Below are some usage examples. The classic "Hello World" program in Wenyan looks like this:

吾有一數。曰三。名之曰「甲」。
為是「甲」遍。
    吾有一言。曰「「問天地好在。」」。書之。
云云。

When compiled to JavaScript, it becomes:

var n = 3;
for (var i = 0; i < n; i++) {
    console.log("問天地好在。");
}

The output is:

問天地好在。
問天地好在。
問天地好在。

A more complex example implements the Sieve of Eratosthenes to find all primes below 100. The Wenyan source (truncated) is:

var 埃氏篩 = () => 0;
埃氏篩 = function(甲) {
    var 掩 = [];
    for (var _rand1 = 0; _rand1 < 甲; _rand1++) {
        掩.push(true);
    };
    // ... (algorithm continues) ...
    return 諸素
};
var _ans7 = 埃氏篩(100);
console.log(_ans7);

The compiled JavaScript prints the list of primes up to 97.

Several syntax tables are provided in the original article (shown in the images below), illustrating variable definitions, operators, arithmetic, and function definitions in Wenyan.

Installation is straightforward: clone the repository, give the built wenyan.js executable permission, and run it. Example commands:

chmod +x wenyan.js
./build/wenyan.js examples/helloworld.wy -o helloworld.js

The project also offers an online IDE at http://wenyan-lang.lingdong.works/ide.html , where users can experiment without installing anything.

The author, a senior at Carnegie Mellon University graduating in 2020 with a Computer Science degree, has several other open‑source projects related to Chinese culture, such as generative Chinese landscape painting, age‑progression videos, and calligraphy conversion tools. More information can be found on his personal site https://lingdong.works/ .

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonProgramming Languageopen-sourceSyntaxWenyan
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.