Classical Chinese programming is on fire, but I don't understand it at all

After all, there is an easy language ahead. Some people think that Chinese can lower the threshold for Chinese people to learn programming, and also enhance the international status of Chinese. However, the recent popular classical Chinese programming language makes you understand what "Chinese is more difficult than English".

Hello wenyan

Recently, a GitHub project has become popular - classical programming language / wenyan-lang.

Now this project has exceeded 10K Stars (it was 9K yesterday, but it has risen by 1K overnight), let's study it quickly.

To learn a language, of course, start with "Hello world" and see how the classical Chinese version is written:

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

I don't understand, compile it into JavaScript:

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

run:

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

There is no complete Chinese programming, it uses ancient Chinese grammar, has Turing completeness, and can be compiled into JavaScript or Python.

Just like the seal script of the ancients, after a meal, the program has been written!

Basic grammar

Hurry up and learn, the first chapter variable starts, Chinese programming must not use abc, but fortunately we have A, B and C:

wenyan JavaScript
吾有一數。曰三。名之曰「甲」。 var a = 3;
有數五十。名之曰「大衍」。 var dayan = 50;
吾有一言。曰「「噫吁戲」」。名之曰「乙」。 var b = "alas!";

true/false We also have corresponding yang/yin (traditional yang/yin), and the type is called "yao" (the basic symbol of the hexagram):

wenyan JavaScript
吾有一爻。曰陰。名之曰「丙」。 var c = false;

If judgment is no problem:

wenyan JavaScript
若三不大於五者。乃得「「想當然耳」」。若非。乃得「「怪哉」」也。 if(3<=5){return "of course"}else{return "no way"}

The loop is more concise, directly declaring the number of times, and finally ending with something like this:

wenyan JavaScript
為是百遍。⋯⋯ 云云。 for (var i = 0; i < 100; i++){ ... }
恆為是。⋯⋯ 云云。 while (true) { ... }
乃止。 break;

Addition, subtraction, multiplication and division are readily available, and even logical operators are supported:

wenyan JavaScript
加一以二。乘其以三。 (1+2)*3
除十以三。所餘幾何。 10%3
減七百五十六以四百三十三。名之曰「甲」。 var a = 756-433;
夫「甲」「乙」中有陽乎。 `a

The container type is also supported, and respects Chinese habits. The first subscript is from the beginning:

wenyan JavaScript
吾有一列。名之曰「甲」。充「甲」以四。以二。 var a = []; a.push(4, 2);
夫「寶劍」之長。 sword.length;
夫「甲」之一。 a[0]
夫「玫瑰」之「「名」」。 rose["name"]

The following is the advanced syntax,define a functionI have a trick:

wenyan JavaScript
吾有一術。名之曰「吸星大法」。是術曰。⋯⋯是謂「吸星大法」之術也。 function f(){...}
吾有一術。名之曰「六脈神劍」。欲行是術。必先得六數。曰「甲」。曰「乙」。曰「丙」。曰「丁」。曰「戊」。曰「己」乃行是術曰。⋯⋯是謂「六脈神劍」之術也。 function f(a,b,c,d,e,f){...}
吾有一術。名之曰「翻倍」。欲行是術。必先得一數。曰「甲」。乃行是術曰。乘「甲」以二。名之曰「乙」。乃得「乙」。是謂「翻倍」之術也。 function double(a){var b = a * 2; return b;}
施「翻倍」於「大衍」。 double(dayan);
吾有一數。曰五。書之。 console.log(5);

code example

The author provides classical Chinese version codes for classic program topics, such as Sieve of Eratosthenes, Quick Sort, Mandelbrot Sets, Tower of Hanoi.

In addition, the author also provides an online IDE, which can directly compile and execute the code.

Quick row

click to view bigger image

Mandelbrot Collection

click to view bigger image

After reading this code makes me feel:

"Nine Chapters on Arithmetic" is an introduction to algorithms;

"Sun Tzu's Art of War" is a security attack and defense;

"Book of Changes" is probably a binary reverse...

some digression

The author of the project is Huang Lingdong, a senior in computer science at Carnegie Mellon University (CMU). For such a top university leader in the world, doing this project is actually just a final assignment or a hobby.

Clicking on issues, the majority of Chinese programming enthusiasts also expressed their admiration for the author:

However, when I was also amazed at the brain hole and creativity of this project, I still saw some topics that made me very unhappy in the issues:

This brother's brain hole seems to be bigger than the author...

Otherwise, how do you connect a programming language to VCs...

This brother is right in the first half of the sentence, but there seems to be some contempt and disdain in the second half?

I reply to him with an expression below:

Of course, the "meaning party" is indispensable everywhere:

It’s true that there are people who are on the line everywhere. The author wrote an open source project for his own amusement. For this purpose, he consulted a large number of ancient Chinese materials, and he won thousands of Stars without seeking fame and fortune, and he became the mouth of some people. Just bad money, pointless, garbage projects.

And when I clicked on the avatars of these people, I found that they were all hanging fork and unknown repo, and I didn't know what they meant by hanging these...

Of course, I can see from the source code that this project may be more aptly called "interpreter", but the author never said how serious this is a formal project that can be used in a production environment.

Esolang

If you have similar ideas to them above, then I will popularize a programming term for you:

Esoteric programming languages , or Esolang for short, are designed to test the limits of computer language design, as a proof of concept, or just as a joke. Esolang creators usually don't intend to make it a mainstream programming language, they hardly care about the usability of the language, or even on the contrary, deliberately make it difficult to use.

For example, Brainfuck, a programming language created in 1993, has only eight symbols and no words. It prints Hello world like this:

++++++++++[>+++++++>++++++++++>+++>+<<<<-]
>++.>+.+++++++..+++.>++.<<+++++++++++++++.
>.+++.------.--------.>+.>.

Another example is MarioLANG, which also can only use symbols and needs to be written in a syntax similar to Mario levels:

++++:       >       >  +:+:+:+:+:+:+:::::
====+      >^===    """=================
    +:-):(:^=   =                       !
    =========    =                      #
                  = !             .+.,:-<
                   =###           ======"

Parenthesis Hell, as its name suggests, parenthesis hell, can only be written using parentheses:

(()()(()()(()()()()((()()(()(()((()((()()()((()((()()()((()((((()()(()(
)()()()()(((()(((()((()((((()(((()()(()()((()((()()()((()()(()()()()(()
()()()(()()()()(()(())))))))))))))))))))))))))))))))))))))))))))))))))

So wenyan-lang actually belongs to Esolang, not a language for production. You look for meaning in these languages, I think your behavior is quite meaningless...

wenyan-lang GitHub: https://github.com/LingDong-/wenyan-lang


This article is original and first published on the WeChat public account "Programming for Life". If you need to reprint, please leave a message in the background.

{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324119409&siteId=291194637