
文言 – A programming language for the ancient Chinese - doppp
https://github.com/LingDong-/wenyan-lang
======
tasogare
In the same spirit, Kanbun (Japanese annotations for reading Classical
Chinese) can be described in a mathematical way:
[https://researchmap.jp/?action=cv_download_main&upload_id=24...](https://researchmap.jp/?action=cv_download_main&upload_id=24891)

I personally tried to make a virtual machine for transforming texts (texts are
code and data) in kanbun before I found the paper but failed because it's a
bit more difficult than I excepted.

~~~
lioeters
That paper is mind-blowing..

It seems to be describing a mapping from Chinese to Japanese, using
algebraic/functional transformations (a few mentions of monoid) - and the
equivalence of this projection is proven using the inductive method. (A bit
confusing how the lambda symbol is used to represent a null string.)

The concept of a "mathematical structure of language" is quite intriguing.
Maybe I'm a bit biased (Japanese is my mother tongue) but I get the impression
that the Chinese language is particularly suited for mathematical
representation?

Like in this 文言 programming language, the sentences seem to read naturally
(not sure if they're grammatically correct though).

My favorite take-away from this post: in the Turing machine example, the
program is titled 「圖靈機」. I see that 圖靈 is a phonetic spelling of Turing ("tú
líng"), but the literal meaning of these characters combined feels like
"map/scheme/plan of a spirit machine" (I guess that would be more correct as
霊機図).

~~~
tasogare
Frankly I didn't understand everything in the paper because of the
maths/language involved but yes it's a super interesting read. The author has
other papers (including new ones!) on his website:
[http://www.wasanjyorin.com/](http://www.wasanjyorin.com/) (under section
漢文訓読関係 of course).

I don't think that Chinese is more suitable for maths representation per se
than other any other natural language. It's the difference between Chinese SVO
and Japanese SOV that gave birth to kaeriten and the crazy idea of reading a
text in a foreign language in it's own mother tongue by reordering the words.
It gives this assembly-like feel to the whole thing, where kanji=memory cells
and kaeriten=instructions.

My Classical Chinese game is not too strong, but from what I understand the
programming language presented is indeed very well crafted.

~~~
lioeters
Thanks for the link to the author's site - most of it's over my head, but I
love how deep he's into this particular topic.

Browsing the papers, like 数理漢文学への道 (the road to the "mathematical study of
Chinese literature"..?), I see that the reality of working with a natural
language is fraught with exceptions and ambiguities, requiring more and more
logical rules to be added in order to closely represent the real-life usage of
grammar.

So I think you're right that Chinese is not necessarily easier than any other
language, to diagram this way. It's due to my lack of knowledge, that I
imagined Chinese grammar to be more strictly logical than, say, English which
is well-known for its quirks and idiosyncracies.

In a way, the approach of mathematically representing a natural language
reminds me of earlier years of AI research before machine learning - like
expert systems and inference engines - to manually build models of knowledge
and mental processes.

(Well, in the case of this kundoku research, it looks like it's concerned with
the syntax structure only, and not about the content/meaning of the words and
characters.)

> It gives this assembly-like feel to the whole thing, where kanji=memory
> cells and kaeriten=instructions.

Wonderful imagery - I can see why you were working on "a virtual machine for
transforming texts (texts are code and data) in kanbun".

I didn't get it before, but when you said "texts are code" \- now I see that
you were feeding kanbun text into a VM that interpreted it as code..!?

A somewhat related topic I'm interested in is mathematical representations of
music. It feels like a similar endeavor, to build up a set of logical rules to
attempt to model the real-life usage of musical "grammar". There are so many
exceptions and "illogical" (i.e., strangely dissonant) ways that people
express themselves, that will always be "one step ahead" of any set of rules.
(On the other hand, there are some fascinating examples of algorithmic music,
beyond what humans are able to create.)

Anyway, thank you for an introduction into a thought-provoking topic.

~~~
tasogare
> I didn't get it before, but when you said "texts are code" \- now I see that
> you were feeding kanbun text into a VM that interpreted it as code..!?

I don't remember the exact details of my thoughts at the time, by I still have
the code. I put it online here for you:
[https://dotnetfiddle.net/Q0kiXU](https://dotnetfiddle.net/Q0kiXU)

As you can see, it works well on small samples but fails for the most complex
examples present in the paper. This is because the way I handle ㆑ which is not
enough to deal with its real complexity.

Edit: reading that
[https://ipsj.ixsq.nii.ac.jp/ej/?action=repository_uri&item_i...](https://ipsj.ixsq.nii.ac.jp/ej/?action=repository_uri&item_id=137405&file_id=1&file_no=1)
I thing I was very close. The paper mention three stacks. I'm using 5 in my
code, but maybe not in the good way. I don't have too much time to spend on
the matter, but I might read a few papers and maybe contact/go meet the author
because it's fascinating and nothing is published in an European language.

~~~
lioeters
Cool, a Kanbun parser and interpreter! That's a really interesting approach.

I'm not so familiar with C# but I get the general picture, as I've worked with
mathematical expression parser/evaluator before in a couple other programming
languages.

Indeed, after reading the linked paper, I see how the handling of "㆑" has
complex rules.

The complete algorithm is beyond my understanding, and I imagine getting it to
a practical level would be years of work..

Sounds like it would be fun for you to contact the author, I'm sure he'd
appreciate that someone had the courage to dive into the depths of his
obsession/expertise in this topic. :)

------
lioeters
The Mandelbrot example, as well as the Fibonacci one, I find quite beautiful.

[https://github.com/LingDong-/wenyan-
lang/blob/master/example...](https://github.com/LingDong-/wenyan-
lang/blob/master/examples/fibonacci.wy)

I think ancient Chinese people would be proud and awed by seeing how language
becomes a living thing, performing logical operations.

Maybe because my only attempts at studying Chinese was the Tao Te Ching, the
programs written in 文言 feel like they're expressing universal truths.

------
tvvocold
歪个楼，欢迎朋友们加入 Hacker News 中文社群：[https://t.me/hn_china](https://t.me/hn_china)

------
pascoej
The author is prolific, having made ton of amazing projects over the past few
years. [https://lingdonh.itch.io/](https://lingdonh.itch.io/)

------
sequoiar6868
穿越时空来的 诗人。有趣。

------
k_sze
It would be even more amazing to have a TypeScript extension, as in adding
more syntax so that 文言 transpiles to TypeScript first, then to JS.

------
duschang27
Thank you for this. I never thought a javascript compiler could help me
improve my Chinese reading skills.

------
vxxzy
與C語言相比，它的性能如何

------
forkLding
这是哪路大神写的？

