Article 4YQR4 World's First Classical Chinese Programming Language

World's First Classical Chinese Programming Language

by
Charles Q. Choi
from IEEE Spectrum on (#4YQR4)

The world's first programming language based on classical Chinese is only about a month old, and volunteers have already written dozens of programs with it, such as one based on an ancient Chinese fortune-telling algorithm.

The new language's developer, Lingdong Huang, previously designed an infinite computer-generated Chinese landscape painting. He also helped create the first and so far only AI-generated Chinese opera. He graduated with a degree in computer science and art from Carnegie Mellon University in December.

After coming up with the idea for the new language, wenyan-lang, roughly a year ago, Huang finished the core of the language during his last month at school. It includes a renderer that can display a program in a manner that resembles pages from ancient Chinese texts.

MzU2MjM5OQ.jpeg Lingdong Huang

"I always put it off and tried to read more books in classical Chinese. Eventually I decided that reading more books might be just a euphemism for procrastination, and I needed to just implement it," Huang says. "It was finals week and there were no classes. So instead of studying, I used the bulk of free time to implement wenyan-lang, finishing the core functionality within three or four days."

Growing up in Shanghai, Huang learned basic classical Chinese in school. "I got quite fascinated by the language and read more books in classical Chinese on my own as a teenager," he recalls. "Currently I'm reading the Huainanzi," an ancient Chinese exploration of philosophy and statecraft compiled at the court of the king of Huainan in the 2nd century BC.

There are already dozens of programs written in wenyan-lang, about half of which others wrote, Huang says. "Many of them are implementations of mathematical algorithms found in ancient Chinese math books. For example, pi_liuhui.wy recreates how 3rd-century AD mathematician Liu Hui calculated pi. Crt.wy is the Chinese remainder theorem. Pascal_triangle.wy computes Pascal's Triangle, which was described in Chinese books prior to Pascal's discovery."

MzU2MjM0OA.jpeg Image: Lingdong Huang A rendering of the divination.wy program written in wenyan-lang.

One of Huang's favorite programs in wenyan-lang, he says, "is divination.wy. It is the fortune-telling algorithm described in the I-Ching," the oldest of the Chinese classics. He adds: "I was going to implement it myself, but an enthusiastic contributor beat me to it."

Wenyan-lang uses both traditional Chinese characters and classical Chinese grammar. One challenge in developing the language was how classical Chinese does not use spaces to divide sentences into words, "so how to split a sentence is a task of the reader and not the writer," Huang says. For example, if readers literate in English saw "pancakebatter," they would have to rely on their prior knowledge to decipher that as "pancake batter" and not "pan cake batter."

To overcome this challenge, Huang notes that programming languages only possess a set amount of keywords. As such, wenyan-lang goes from the longest keyword to the shortest keyword in each program to decipher what the programmer wants, "and it works," Huang says.

Huang was surprised and excited by the amount of attention wenyan-lang has received. "I thought I made a lot of cool projects before, but this one somehow became especially popular in China," he says.

"Before this I largely worked on my own at my own pace, but now collaboration has become crucial," Huang says. "In addition to co-authoring code, I have to review other people's code, carefully evaluate every suggestion, and decide if they're indeed valuable features for the language, or write friendly responses to explain why I don't think so if otherwise. But I think I'm enjoying the experience, especially since I've got a gang of amazing contributors."

MzU2MjM1OA.jpeg Image: Lingdong Huang Wenyan-lang programming window and corresponding JavaScript.

Currently wenyan-lang contributors are working on transpilers for Python, Ruby, JavaScript, C++, and Java, libraries for graphics and the graphical user interface (GUI), as well as a snippet site where people can author and share bits of code. "Most importantly, we're seeking ways to build a community around the language," Huang says. "I think this might be a critical moment for its survival. People have the initial enthusiasm, but to keep the language alive, there needs to be a community of users."

In addition, Huang is currently working on an introductory guide to programming in wenyan-lang that is itself written in classical Chinese. "It is about 40 percent done," he says. "The target audience of the book can be someone with no prior experience with programming at all. However I'll need to test it with the aforementioned audience to make sure, as I believe some ideas that are natural to me might not be obvious to someone new to programming."

All in all, "now I have a programming language of my own, a language that is exactly how I want it to be, and in classical Chinese, which I very much enjoy," Huang says. "I think inventing one's own programming language is an idea that pops up in the mind of every programmer. (This best explains the plethora of programming languages today.)"

U5HknxiRrjE
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/IeeeSpectrum
Feed Title IEEE Spectrum
Feed Link https://spectrum.ieee.org/
Reply 0 comments