12 ms·
Wenyan-lang: Classical Chinese Programming Language
- bmn__ 7y agoFTA: > World's First Classical Chinese Programming Language This is false. There is at least one prior art, first published 18 years ago: http://p3rl.org/Lingua::Sinica::PerlYuYan http://p3rl.org/Lingua::Sinica::PerlYuYan
- deleted 7y ago[deleted]
- dang 7y agoTwo recent related threads: https://news.ycombinator.com/item?id=21840924 https://news.ycombinator.com/item?id=21840924 https://news.ycombinator.com/item?id=21840101 https://news.ycombinator.com/item?id=21840101 Also https://medium.com/syncedreview/cmu-senior-develops-worlds-first-classical-chinese-programming-language-7ffe7fca75ad https://medium.com/syncedreview/cmu-senior-develops-worlds-f... via https://news.ycombinator.com/item?id=21864706 https://news.ycombinator.com/item?id=21864706 (but no comments there).
- 5- 7y agoSee also: Perl in Classical Chinese in Perl: https://metacpan.org/pod/Lingua::Sinica::PerlYuYan https://metacpan.org/pod/Lingua::Sinica::PerlYuYan
- yorwba 7y agoThe syntax is slightly cumbersome. For example, the function header of the mandelbrot snippet at https://wenyan-snippets.netlify.com/ https://wenyan-snippets.netlify.com/ reads: 吾有一術。名之曰「曼德博」。欲行是術。必先得二數。曰「寬」。曰「高」。乃行是術曰。 Decomposed: 吾有一術。I have a function. 名之曰「曼德博」。 Named "mandelbrot". 欲行是術。必先得 Who wants to run this function, must first get 二數。two numbers. 曰「寬」。Called "width". 曰「高」。Called "height" 乃行是術曰。 Then run this function as follows: Essentially, what gets expressed using punctuation in mainstream programming languages is instead described by a short sentence. This would be terribly verbose in English, but it's kind of bearable in Classical Chinese, because each word is only a single character.
- Guthur 7y agoYour description reminds me of Cobol.
- microcolonel 7y agoIt is a lot like COBOL, but oddly with more punctuation (probably because of the lack of consistent use of whitespace in Chinese). I think it may be a fun way to practice my 漢字.
- Ericson2314 7y agoImperial Chinese COBOL is very natural sounding concept. That's for sure civil service exam material right there.
- knolax 7y agoThe punctuation seems extraneous to me. They all come either before or after keywords so they don't seem to be needed to parse the script. IIRC it's very similar to actual Classical Chinese, which relied on words like 曰、乃、也 to indicate when a clause or sentence starts or ends. IIRC typically the punctuation was added as a part of the excercise of reading.[0] [0] https://zh.m.wikipedia.org/zh-hant/%E5%8F%A5%E8%AE%80 https://zh.m.wikipedia.org/zh-hant/%E5%8F%A5%E8%AE%80
- colorincorrect 7y agonot sure if serious but this sounds like trying to learn english via python syntax
- Aardwolf 7y agoI learned English words like while, for and next from qbasic, for real (it had good help in your local language)
- wrboyce 7y agoOk but that is three words, what about the rest? Leaning three words is somewhat far removed from leaning a language. (Btw: I can’t grok your final statement in the parenthesis — it doesn’t make sense in English, what were you trying to say?)
- tacheiordache 7y agoLooks very interesting but I don’t understand chinse so I’d be curious what chinese programmers think about it. I think a scheme lisp in chinese would be quite efficient in terms of visually parsing the code.
- Aperocky 7y agoIt's a fun project in that you can write something that feels like classical Chinese and run it. It will always be just a hobby like the latin perl script.
- sandoooo 7y agoIt's an esolang. I don't think it has much practical application over, say, Brainfuck.
- yen223 7y agoThis is the equivalent of building a programming language in the style of Mediaeval English. Fairly sure it's not meant to go mainstream.
- Igelau 7y agoI like this idea. Where's the Chaucerian English programming language?
- gabordemooij 7y agoThis is a very cool language. We are working on a generic localized programming language (https://citrine-lang.org/ https://citrine-lang.org/) and we are looking for help with the Chinese language, maybe the creators of this beautiful language want to help us out with the Chinese version?
- scarmig 7y agoFYI, you write that the language is for "every man," which would be off-putting for some contributors.
- big_chungus 7y agoIt seems that he's specifically trying to make it accessible to a wider audience; why would that be off-putting?
- macintux 7y agoParticularly in a field which is known for a less-than-enthusiastic embrace of female contributions, “every man” is less inclusive than “every person” or “everyone”.
- dang 7y agoHN has a lot of users (millions, most likely) whose native language is not English, so it's a good idea to remember that not everyone here is familiar with the standards that we may take for granted.
- scarmig 7y agoOf course. The intention was to provide information so that they could improve their copy, not to preen.
- hhas01 7y agoAt risk of giving HN’s more delicate male readers their daily attack of the vapors: Such thoughtless dismissal of half the human race is not a good look for a product claiming to improve accessibility.
- auvi 7y agoCan someone familiar with Chinese language clarify one thing please: What does "Classical" mean in this case? And are the characters Simplified Chinese or Traditional Chinese?
- Aperocky 7y agoClassical are refined Chinese used in official communication/literary record in imperial China/Korea/Japan. The grammar etc haven't really changed over 2 millenia, it is much like how Latin is to Italian/French/Spanish. Historically, they are all obviously written in traditional Chinese characters, However, you can write it in Simplified Chinese since there's usually a 1-1 mapping between Simplified Chinese / Traditional Chinese characters.
- auvi 7y agoMany thanks. So the characters shown in the IEEE Spectrum article, are they in Traditional Chinese? I wonder whether the implementation of the programming language covers both characters or not.
- Aperocky 7y agoThose are traditional Chinese characters, I have no idea if simplified characters are also supported (shouldn't be hard as it would be another symbol set, so probably) but if you're going to write classical Chinese, might as well have the full immersion.
- colorincorrect 7y agoyour last sentence is inaccurate: an english reader cannot read any latin at all naively, but a modern chinese reader can interpret little/some/most of classical chinese, depending on the specific text in question
- sansnomme 7y agoEnglish is a weird Romantic-Germanic hybrid (Germanic by linguistic classification but with a tremendous/predominant vocabulary of Romantic origin). A more apt comparison would be with respect to a French/Italian/Spanish reader. See: Interlingua
- 5- 7y agoAs others have noted, the choice of both syntax (extremely elaborate, to the point of reeking of esoteric languages like Shakespeare) and semantics (scalar imperative language, JavaScript) seem to be a poor match for Classical Chinese, known for the brevity and tacitness of its texts. I always thought that if for some reason one wanted to map an existing programming language into Classical Chinese (instead of coming up with something semantically closer resembling the latter), one could do worse than start with the likes of APL. Consider the Fibonacci example: https://github.com/wenyan-lang/wenyan/blob/master/examples/fibonacci.wy https://github.com/wenyan-lang/wenyan/blob/master/examples/f... Is this really how you would like to use Classical Chinese to convey the idea of a Fibonacci number? Indeed, this form maximises the number of words one can use in a single definition; is there anything else for which it is good? Here's an equivalent program in APL (also naively recursive, that's not necessary how I'd implement Fibonacci sequence): {⍵<2:⍵⋄+/∇¨⍵-1 2} If the argument is below 2, that's the answer; otherwise, compute sum of the function applied, in turn, to the argument less 1 and 2.
- pollinia 7y agoaddio
- tvb12 7y agoCan you recommend an APL interpreter? I'd like to fiddle with that.
- 5- 7y agoDyalog APL is a mature, modern, and well-supported implementation of APL. https://www.dyalog.com/ https://www.dyalog.com/ It's also powering https://tryapl.org/ https://tryapl.org/ and available on https://tio.run/ https://tio.run/ You might also find K interesting -- an APL descendant with somewhat different aesthetics, though Dyalog has recently done a lot of catching up to it. https://code.kx.com/q/ https://code.kx.com/q/
- tvb12 7y agoIt looks like there's a Jupyter kernel for dyalog. I'll give this a try. Thanks!
- fctorial 7y agoThe thing that makes english good for computers is the small alphabet size (smallest of any language I know), and the fact that a phrase is just a sequence of characters. These characteristics make it easy to get started with as well. What is the situation with this language?
- thaumasiotes 7y ago> The thing that makes english good for computers is the small alphabet size (smallest of any language I know) Compare Greek at a standard 24 characters to English's standard 26.
- GordonS 7y agoScots Gaelic uses only 23 latin letters, or only 18 if you don't count accented letters (e.g. it uses both "e" and "è").
- thaumasiotes 7y agoHawaiian has 13 (including the ').
- srik 7y agoIMO that's kind of a survivor syndrome though. The origins of modern comp science was heavily intermingled with latin languages and english in the form of ASCII just didn't get in the way. The entire alphabet of 52 main characters not including punctuation is not even close to being a small set. The world has adapted and considers it a non-issue anyway but personally I'd still like to see a lot more localization so people don't have to learn a second language in the form of english first, as it is now.
- deleted 7y ago[deleted]
- deleted 7y ago[deleted]
- dwohnitmok 7y agoThere's a fun example in the GitHub repo for calculating the square root of a number based off of a real algorithm found in a real ancient Chinese text (九章算術). https://github.com/wenyan-lang/wenyan/blob/master/examples/zh_sqrt.wy https://github.com/wenyan-lang/wenyan/blob/master/examples/z... I don't have the time to translate at the moment but I'll just leave the two here for others to see just how different they read (and for those who can read Chinese, what similarities they have). The Wenyan language: 吾有一術。名之曰「增乘開平方」。欲行是術。必先得一數。曰「實」。乃行是術曰。 注曰。『增乘開平方法,以商數乘下法遞增求之。』。 吾有四數。名之曰「果」曰「商」曰「餘」曰「廉」。有數一。名之曰「法」。 恆為是。施「取底除」於「實」於「法」。若其之『商』小於百者乃止也。 乘「法」以百。昔之「法」者。今其是矣云云。 恆為是。若「法」不大於零者乃止也。 乘「果」以十。昔之「果」者。今其是矣。 加「廉」以「商」。乘其以十。昔之「廉」者。今其是矣。 施「取底除」於「實」於「法」。名之曰「甲」。 昔之「實」者。今「甲」之『商』是矣。 昔之「餘」者。今「甲」之『餘』是矣。 昔之「商」者。今零是矣。 恆為是。加「廉」以「商」。乘其以「商」。若其不小於「實」者乃止也。 加「商」以一。昔之「商」者。今其是矣云云。 加「廉」以「商」。乘其以「商」。若其大於「實」者。 減「商」以一。昔之「商」者。今其是矣云云。 加「廉」以「商」。昔之「廉」者。今其是矣。 加「果」以「商」。昔之「果」者。今其是矣。 乘「商」以「廉」。減「實」以其。乘其以「法」。加其以「餘」。昔之「實」者。今其是矣。 施「取底除」於「法」於百。昔之「法」者。今其之『商』是矣云云。 注曰。『商第一位。上商得數以乘下法為乘方。命上商除實。上商得數以乘下法入乘方。一退為廉,下法再退。』。 注曰。『商第二位。商得數以乘下法為隅。命上商除實訖。以上商乘下法入隅,皆名曰廉。一退,下法再退,以求第三位商。』。 注曰。『商第三位。用法如第二位求之。』。 乃得 「果」。 是謂「增乘開平方」之術也。 The original Chinese: 開方術曰:置積為實。借一算步之,超一等。議所得,以一乘所借一算為法,而以除。除已,倍法為定法。其復除。折法而下。復置借算步之如初,以復議一乘之,所得副,以加定法,以除。以所得副從定法。復除折下如前。若開之不盡者為不可開,當以面命之。若實有分者,通分內子為定實。乃開之,訖,開其母報除。若母不可開者,又以母乘定實,乃開之,訖,令如母而一。 Note the original Chinese is based off the rod calculus. https://en.m.wikipedia.org/wiki/Rod_calculus https://en.m.wikipedia.org/wiki/Rod_calculus
- deleted 7y ago[deleted]
- KhoomeiK 7y agoDefinitely a cool concept, but I think the core idea is relatively similar to English-based programming languages because both Chinese and English are highly analytical languages (they don't inflect/change words based on case, tense, etc too much). I'm working on an "inflectional" programming language at the moment, where word order and a whole bunch of other "traditional" features of analytical-language-based programming languages are discarded in favor of word inflection. For example, rather than expressing variable assignment with the '=', we use the ablative case for the source expression and the nominative for the target variable. Traditional: foo = bar Inflectional: foo barFrom I'm not sure whether it would be useful, but it's just an interesting idea to play around with. There's already perligata (Latin) but it doesn't use a lot of the constructs in Latin and doesn't take the inflectional idea too far, so I'm implementing this in Classical Sanskrit. The core idea could be applied to pretty much any highly inflectional language though, like Arabic or Finnish.
- ngcc_hk 7y agoKnow chinese (abd currently studied classical text like zhungzi) and doing IT many years ... come on one is hard enough and joining two. You are crazy.
- ur-whale 7y agoKind of reminds me of something I was subjected to in another life, called LSE (a frenchified BASIC) [1][2]. Here's an example: * Quelques déclarations * Suivies d'une boucle BOOLEEN A←.VRAI.,B←.FAUX. ENTIER U,W,X←200 NOMBRE PI←3.14159 CHAINE CHN TABLEAU DE ENTIER TBL[3,3] QUEUE DE CHAINE Q[8] ENSEMBLE DE NOMBRE NPREMIER←{1.0,2.0,3.0,7.0} CHN←'Salut' X ← SELON X ALORS 1,2,3,7,11 SINON 0 POUR U←0 JUSQUA 2 FAIRE POUR W←0 JUSQUA 2 FAIRE TBL[U,W]←X BOUCLER BOUCLER TERMINER Needless to say, the thing was an absolute dead-end. The only thing I still feel it had going for it is that assignment to variables were done via the ← sign and not the dreaded '=' so common to modern languages. [1] https://en.wikipedia.org/wiki/LSE_(programming_language) https://en.wikipedia.org/wiki/LSE_(programming_language) [2] https://fr.wikipedia.org/wiki/LSE_(langage) https://fr.wikipedia.org/wiki/LSE_(langage)
- jiyinyiyong 7y agoI got a tiny projected inspired by Wenyan https://github.com/Cirru/jiuzhang-lang https://github.com/Cirru/jiuzhang-lang if anyone is interested.