Fundamentals 5 min read

Introducing Wenyan‑lang: A Classical Chinese Syntax Programming Language

Wenyan‑lang is an open‑source programming language that uses only Classical Chinese characters for source code, compiles to JavaScript or Python, and provides a full set of language constructs such as variables, control flow, operations, containers, and functions illustrated with clear code examples.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Introducing Wenyan‑lang: A Classical Chinese Syntax Programming Language

Recently an open‑source programming language called “wenyan‑lang” was released, which uses Classical Chinese (wenyan) characters exclusively for source code and compiles to JavaScript or Python.

The language’s “Hello World” program is written in Classical Chinese and is equivalent to a JavaScript loop that prints a phrase three times.

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

Corresponding JavaScript:

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

Variable declarations in wenyan‑lang map directly to JavaScript assignments: 吾有一數。曰三。名之曰「甲」。

var a = 3;
有數五十。名之曰「大衍」。

var dayan = 50;
吾有一言。曰「「噫吁戲」」。名之曰「乙」。

var b = "alas!"; Control‑flow constructs such as conditional statements and loops are expressed in a natural‑language style: 若三大於二者。乃得「「想當然耳」」也。

if (3 > 2) { return "of course"; }
若三不大於五者。乃得「「想當然耳」」。若非。乃得「「怪哉」」也。

if (3 <= 5) { return "of course"; } else { return "no way"; }
為是百遍。⋯⋯ 云云。

for (var i = 0; i < 100; i++) { ... } Arithmetic operations are written in a literal Chinese form: 加一以二。

1 + 2
除十以三。所餘幾何。

10 % 3 Containers such as arrays start indexing at 1, and common array methods are expressed with Chinese verbs:

吾有一列。名之曰「甲」。充「甲」以四。以二。

var a = []; a.push(4, 2);
銜「甲」以「乙」。以「丙」

a.concat(b).concat(c); Function definitions follow a declarative pattern:

吾有一術。名之曰「翻倍」。欲行是術。必先得一數。曰「甲」。乃行是術曰。乘「甲」以二。名之曰「乙」。乃得「乙」。是謂「翻倍」之術也。

function double(a) { var b = a * 2; return b; } The author notes that the language’s context‑free grammar is still under development, but the language is Turing‑complete, provides an online IDE, and includes many algorithmic examples such as quicksort, the Tower of Hanoi, and Fibonacci sequences.

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.

JavaScriptProgramming LanguageCode Examplesclassical-chinesewenyan-lang
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

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.