文言文編程語言 A programming language for the ancient Chinese
January 24, 2020 6:36 AM   Subscribe

文言, or wenyan, is an esoteric programming language that closely follows the grammar and tone of classical Chinese literature. Moreover, the alphabet of wenyan contains only traditional Chinese characters and 「」 quotes, so it is guaranteed to be readable by ancient Chinese people. You too can try it out on the online editor, download a compiler, or view the source code. Wenyan can also render wenyan scripts into the format of ancient printed books.
posted by daisyk (20 comments total) 34 users marked this as a favorite
 
The language spec makes it look like this was implemented in a way akin to the Typescript type checker, which I think makes it more interesting than I usually find esolangs to be - usually they boil down to an awkward wrapper around assembly.
posted by PMdixon at 6:58 AM on January 24, 2020 [1 favorite]


now we just have to teleport this back in time, and Chinese mythology is going to get even more interesting than it already is
posted by Merus at 7:28 AM on January 24, 2020 [2 favorites]


Oh, I saw this go by somewhere recently! It's very cool, I love the look of it and I love that it's leaning into the orthography/morphology and structural tropes of a natural language instead of just being another Befunge-like abstract symbolic prank.
posted by cortex at 7:35 AM on January 24, 2020 [2 favorites]


On the one hand: cool!

On the other, the fact that the source files are ".wy" files is maybe a little too on the nose?
posted by gurple at 8:06 AM on January 24, 2020


Too cool, the IDE and formatted output take it the extra mile.
Tangentially, Damian Conway wrote a Perl module (Lingua::Romana::Perligata) that implements Latin if you really like this sort of thing: Perl for the XXI-imum Century. Worth a peek because Damian Conway is always worth a peek.
posted by zengargoyle at 8:15 AM on January 24, 2020 [1 favorite]


OK, I had to check out what it says. I won't molest you with the readings, but the Hello World program translates as:
I have a number. Called 3. The name, call it "A".
Do this "A" times.
    I have a word. Say, "Ask the world, is it good." Book it.
Thus.
Using 甲 as the variable name is cute. It's the first of the Heavenly Stems, which are often used to name things in a sequence.

書 for "log" is pushing it. Old Chinese is not quite as forgiving about verbing nouns as English it— so far as I can see 書 is only used as a noun. It could be the word for "(console) log", sure, but making it a verb seems questionable.

I'd really expect 吾有一數也, but this may not be necessary.
posted by zompist at 8:19 AM on January 24, 2020 [21 favorites]


I would like to try to write actual useful code for English language users in this, because I've always found it frustrating that everyone else in the world has to use the English words for "if", "else", etc. and I'm kind of curious what it's like to be on the other side of that fence.
posted by phooky at 8:26 AM on January 24, 2020 [3 favorites]


One link that allows me to confront my inadequacies in both programming and 文言文, so great!

zompist, '書' used as a verb here doesn't strike me as odd. I do find it a bit strange to assign the value of the variable before naming the variable.
posted by em at 8:28 AM on January 24, 2020 [2 favorites]


Lol it's implemented in Typescript which is why the spec looks like a Typescript type hierarchy.
posted by PMdixon at 8:44 AM on January 24, 2020 [1 favorite]


I've always found it frustrating that everyone else in the world has to use the English words for "if", "else", etc. and I'm kind of curious what it's like to be on the other side of that fence.

Wikipedia has quite a broad list of Non-English-based programming languages to peruse and try out. Very few of them are based on historical languages, besides Wenyan and Lingua::Romana::Perligata mentioned above.
posted by polytope subirb enby-of-piano-dice at 9:39 AM on January 24, 2020 [3 favorites]


Imagine if there were a parallel version of the language. It could be implemented by a roomful of scribes!
posted by sjswitzer at 9:42 AM on January 24, 2020 [3 favorites]


I do find it a bit strange to assign the value of the variable before naming the variable.

At least three languages (R and its predecessor S; TI-BASIC) allow or require right arrow assignment, such as

3 -> a

in R and S and

3 → a

in TI-BASIC. But it's unusual for sure.
posted by jedicus at 9:52 AM on January 24, 2020 [2 favorites]


I love everything about this. There's an elegance to 文言文 that would translate in really interesting ways to code. I like how the creator, Lingdong Huang talks about code and wenyan in terms of beauty and communication.
posted by storytam at 10:01 AM on January 24, 2020 [1 favorite]


now we just have to teleport this back in time, and Chinese mythology is going to get even more interesting than it already is

Not just mythology. Ancient China had philosophers, including logicians. Where would we be today if computer science as a field of study began more than 2000 years ago?
posted by justsomebodythatyouusedtoknow at 10:37 AM on January 24, 2020 [2 favorites]


Thanks, polytope, that's a great list! It's a little disappointing that so many of them are Logo/BASIC in X, but now I'm pretty curious about the old Soviet ones.
posted by phooky at 10:50 AM on January 24, 2020 [1 favorite]


storytam, thank you for sharing that link for context!
posted by daisyk at 2:04 PM on January 24, 2020 [1 favorite]


Oh no, I spent three years of my life studying 文言文, that's enough for anyone.
posted by 1adam12 at 9:59 PM on January 24, 2020


zompist Book it.

Interesting translation! I'm working with a custom db written by Germans - 'Book it' appears often, as a "this is now irrevocable" option/ command.

Is there a particular meaning to "Book" something?
posted by porpoise at 9:56 PM on January 26, 2020


Where would we be today if computer science as a field of study began more than 2000 years ago?

I feel that teleporting a computer 2000 years into the past would have a seismic effect on philosophy even if it didn't have a programming language that resembled ancient Chinese
posted by Merus at 11:25 PM on January 26, 2020


Interesting translation! ...Is there a particular meaning to "Book" something?

Do you mean in English, or Old Chinese, or computerese..?

I used it as a fairly literal translation for 書之 (book+it). The compiler treats it as "write it to the console log".

I was a little hasty in my dictionary lookup and thought that 書 (OC *lha, Mandarin shū) was only used as a noun. But em is right, it could be a verb too, so "Record it" would probably be a better translation. (Of course we do have "book it" for "write it in a book"— e.g. recording an arrest at the police station.)
posted by zompist at 6:29 AM on January 27, 2020 [2 favorites]


« Older Crowdsource Bad Drivers   |   Enhance 34 to 46. Pull back - wait a minute. Go... Newer »


This thread has been archived and is closed to new comments