If you're not familiar with Japanese language, here is a rough
English translation of the first code example:
The book is
Lambda is x times x times x.
Numbers are 88, 7100 and 55.
A, B, C and null are Numbers.
NewNumber is the sum of A and B.
Display NewNumber.
Result is <apply Lambda to 741> plus 919.
Display [sum of Result and NewNumber].
End.
If it feels to you like a riddle poem, it's exactly what the
original program sounds like in Japanese.
In case anyone is wondering, here is an equivalent Python code:
def main():
f = lambda x: x * x * x
numbers = [88, 7100, 55]
a, b, c = numbers
new_number = a + b
print(new_number)
result = f(741) + 919
print(result + new_number)
Thanks to homonyms, haku is a lot of things.
- 吐く is to vomit, but also to emit, confess, etc.
- 履く is to wear
- 掃く is to sweep
- 拍 is a beat or a mora
and there are plenty more.
Another I know offhand is that "haku" is a reading of the kanji for "white" (白). What might not be apparent to most English-speakers is that "haku" is just two characters in Japanese (はく), which seems like it could mean practically anything in different contexts.
"Haku" is an unusual string in Anglophone culture, so it makes sense that people would mentally associate it strongly with the first (or most frequent, or most recent) meaning they encounter. For a native Japanese speaker, I imagine that it would be viewed as any common prefix or two-letter word would be in English — if not as even more generic, because Japanese seems to have so many more homophones than English (based on my very limited knowledge of the language).
It's not that it's generic, it's that it has several different, partly unrelated meanings, just like some short English roots that may coincide with some Latin, Greek or Old Norse loan.
Both of the reasons for the many homophones in Japanese are related to Chinese:
1. Japanese use both native Japanese words, like はく (ha-ku), and Chinese loanwords, like 白 (HAKU). Due to the very limited phonology of Japanese, these often coincide.
2. Again due to the limited phonology, a lot of sounds that in Chinese sounded different will coincide in Japanese.
By the way, HAKU and all other single character sounds that come from Chinese were originally single syllables, but since a syllable can't end in K in Japanese they add a U to it.
People might object that Mandarin also doesn't allow syllables that end in K, but the Chinese spoken when these words were borrowed did, just like Cantonese still does.
HAKU in Japanese is BAI in Mandarin and BAAK in Cantonese.
Hakka's most obvious archaic feature is the syllable-final stops, as in Yue/Cantonese and Min. I know Yue dissimilated some of them (details fuzzy in my memory, possibly -t went to -k with a dental initial). I don't know of any changes to them in Hakka.
Hakka retains the -m final, instead of merging it to -n. It retains distinct 'round' and 'sharp' (velar and dental) onsets in positions where some Mandarin varieties (including Standard) merge them to the new palatal j/q/x.
The Middle Chinese palatal ny- is lost in Hakka as it is almost everywhere. It merged with r- in Mandarin, y- in Yue, and ng- in Hakka. So you can't read the archaic form directly off any one of those varieties, but you can detect it by comparing any two.
Hakka tonal developments are middle-of-the-road. Like every variety of Chinese, it had the four Middle Chinese tones altered by the voicing feature of the syllable onset, and like every variety outside of Wu/Shanghainese, it then lost the voicing feature itself.
Hakka splits the ping/level tone in two by voicing, like almost every variety does. It splits the ru/entering 'tone' (the syllables with final stops) by voicing, like almost every non-Mandarin variety does, instead of disintegrating it like Mandarin.
In the shang/rising tone, Hakka agrees with Mandarin against Wu and Yue that you don't just split the tone down the middle by voicing; you split off voiced obstruent onsets and leave voiced sonorant onsets alone. It agrees with Mandarin and Wu against Yue that the split-off voiced onsets (whether all of them or just the obstruents) merge into the qu/departing tone.
Hakka agrees with Mandarin against almost everybody else that the qu/departing tone does not split.
Proper nouns are usually 2-3 letters long, as in 白紙, 鶏白湯, 赤子, etc. Kun-yomi(Chinese borrowed) single letter nouns e.g. 碁, 本, 金 are rare so two-letter matches sort of take priority by heuristics, most common of which is 吐く…
The spoken language encodes hints in tones so homophones aren’t necessarily “homo” phones - Haku used as verb and as a name, or kuma as in bears and as in black spots under eyes, are pronounced slightly differently. If you listen really closely you might notice “ha” in Hali’s name is pronounced slightly stronger.
"書類を読むために開ける" sound to me that it follows subject-object-verb model. When I was taught English, early learner materials would contrast the grammatical difference from Japanese as one is SOV and the other is SVO with subjects frequently omitted, but Wikipedia article[1] today mentions Japanese language has "topic-comment" sentence structure, which seems to make sense to me.
A more natural form of those sentences would be "メッセージ/文書を送信(Send message/text)" and "書類を開いて読む(open and read document)" or "書類を読み込む(read-ingest document)", than implied imperative "[You] must send message" or "[You] open document for the purpose of reading" which don't feel to me that they follow this topic-comment logical structures.
This topic-comment model is also seen in Nadesiko Japanese programming language, as quoted below from "open file" function reference page:
> 「ファイル.txt」を開いて、Sに代入。
> Sを表示。
(my attempt at translation:)
> "file.txt" be opened, S it assign to.
> S be displayed.
As clearly seen, the object such as filename or variable are brought up first, then subsequently augmented, with subject simply missing.
I was wondering the same. I'll also note I went to the page to contribute and be a member since it looks like a non-profit supporting F/OSS. If they check out, I'd like to support them. Unfortunately in order to pay for a membership outside of the Eurozone it takes some extra steps.
As a non-Japanese speaker I can’t make much sense of this, but this looks super cool! At the same time I can’t stop wondering if this is how English-dominant programming is perceived by “non-roman-alphabet” speakers. Imagine if the Japanese dominated the invention of programming languages, and we all had to learn Japanese to be productive at our jobs.. we’re lucky that ruby was written in English
> At the same time I can’t stop wondering if this is how English-dominant programming is perceived by “non-roman-alphabet” speakers.
It isn't. Few people in the world are unfamiliar with the Latin alphabet, definitely not the Japanese or any other wealthy nation. And since most really poor countries use the Latin alphabet, often for colonial reasons, I don't really think there is any large group of people that aren't familiar with it.
There are varying degrees of familiarity. I can technically read Japanese kana, for example. Only a few dozen to memorize, after all. But using a programming language with all its keywords in Japanese is a rather daunting prospect. I still tend to mix up some of the kana visually, for example. And I don't know much Japanese vocabulary so most or all of the terms would be opaque to me. It seems it would be a lot more mental heavy lifting than programming in my native English, especially at the start.
Sure, my point was that this is not the case for Japanese, probably not for anyone. They are vastly more familiar with Latin characters and English words than you are with Japanese.
But yeah, programming will be slightly harder for them than for you or me.
An old Japanese programmer told me that when he started out, they attempted to translate everything into Japanese. My memory is fuzzy (this conversation was 8 years ago) so take this as more of an example then exactly what he said. For example, "string" was translated by its rope-like meaning, you used that kanji to write it in comments/docs, and when talking to other programmers you'd use the Japanese word. Anyway they gave up on that for the most part.
All the numbers have secondary forms with extra strokes. (In Chinese too.) It's originally an anti-fraud/legibility technique. But they sometimes get used in formal/legal contexts just because. (One stroke turns 十 10 into 千 1000 otherwise, which is problematic on something like a cheque.)
There's actually a Japanese programming language (created around 2005) that is highly readable and natural - Nadesiko. Here's the first tutorial in Japanese, with executable snippets:
「こんにちは」と表示
Display 「Konnichiwa」
5に6を掛けて5を足して7で割って表示。
Multiply 5 by 6, then add 5, then divide by 7, then display it.
Sample program:
「身長は何センチですか」と尋ねる。
Ask "What is your height in cm?"
身長Mはそれ÷100
heightM is that divided by 100.
標準体重は22×身長M×身長M
optimalWeight is 22 x heightM x heightM.
「標準体重は、{標準体重}kgです。」と表示。
Display "Your optimal weight is {optimalWeight} kg."
Since it's basically natural language, it's a really nice language for introducing Japanese speakers to programming!
吾有一數。曰三。名之曰「甲」。
We have a number. It is 3. Its name is n.
為是「甲」遍。
Done n times:
吾有一言。曰「「問天地好在。」」。書之。
We have a phrase. It is "問天地好在". Write it.
云云。
End.
Equivalent JavaScript:
var n = 3;
for (var i = 0; i < n; i++) {
console.log("問天地好在。");
}
"I call it 'haku' because I like the sound of it, and also because that word can be written in many ways and mean many things in Japanese. I was definitely thinking about Haku from Spirited Away. Also, I like the resemblance with Raku, the implementation language. I would write it 珀 (amber) or 魄 (soul, spirit)."
If you guys didn't read the readme then here's the reason why did the author named it "Haku".
"I call it 'haku' because I like the sound of it, and also because that word can be written in many ways and mean many things in Japanese. I was definitely thinking about Haku from Spirited Away. Also, I like the resemblance with Raku, the implementation language. I would write it 珀 (amber) or 魄 (soul, spirit)."
35 comments
[ 3.6 ms ] story [ 84.1 ms ] threadIn case anyone is wondering, here is an equivalent Python code:
A lambda of x is x times x.
(X de X kakeru X desu)
At the end of the readme the author says it’s partly from the male protagonist in Spirited away, who is also named Haku.
So if Ghibli can get away with it …
"Haku" is an unusual string in Anglophone culture, so it makes sense that people would mentally associate it strongly with the first (or most frequent, or most recent) meaning they encounter. For a native Japanese speaker, I imagine that it would be viewed as any common prefix or two-letter word would be in English — if not as even more generic, because Japanese seems to have so many more homophones than English (based on my very limited knowledge of the language).
Both of the reasons for the many homophones in Japanese are related to Chinese:
1. Japanese use both native Japanese words, like はく (ha-ku), and Chinese loanwords, like 白 (HAKU). Due to the very limited phonology of Japanese, these often coincide.
2. Again due to the limited phonology, a lot of sounds that in Chinese sounded different will coincide in Japanese.
By the way, HAKU and all other single character sounds that come from Chinese were originally single syllables, but since a syllable can't end in K in Japanese they add a U to it.
People might object that Mandarin also doesn't allow syllables that end in K, but the Chinese spoken when these words were borrowed did, just like Cantonese still does.
HAKU in Japanese is BAI in Mandarin and BAAK in Cantonese.
Mandarin really feels like a streamlined variant of Chinese, probably the classic lingua franca affliction. The tone system is also impoverished.
Hakka preserves some archaic features though, would be interesting to learn more about that.
Hakka retains the -m final, instead of merging it to -n. It retains distinct 'round' and 'sharp' (velar and dental) onsets in positions where some Mandarin varieties (including Standard) merge them to the new palatal j/q/x.
The Middle Chinese palatal ny- is lost in Hakka as it is almost everywhere. It merged with r- in Mandarin, y- in Yue, and ng- in Hakka. So you can't read the archaic form directly off any one of those varieties, but you can detect it by comparing any two.
Hakka tonal developments are middle-of-the-road. Like every variety of Chinese, it had the four Middle Chinese tones altered by the voicing feature of the syllable onset, and like every variety outside of Wu/Shanghainese, it then lost the voicing feature itself.
Hakka splits the ping/level tone in two by voicing, like almost every variety does. It splits the ru/entering 'tone' (the syllables with final stops) by voicing, like almost every non-Mandarin variety does, instead of disintegrating it like Mandarin.
In the shang/rising tone, Hakka agrees with Mandarin against Wu and Yue that you don't just split the tone down the middle by voicing; you split off voiced obstruent onsets and leave voiced sonorant onsets alone. It agrees with Mandarin and Wu against Yue that the split-off voiced onsets (whether all of them or just the obstruents) merge into the qu/departing tone.
Hakka agrees with Mandarin against almost everybody else that the qu/departing tone does not split.
The spoken language encodes hints in tones so homophones aren’t necessarily “homo” phones - Haku used as verb and as a name, or kuma as in bears and as in black spots under eyes, are pronounced slightly differently. If you listen really closely you might notice “ha” in Hali’s name is pronounced slightly stronger.
Although I’m not sure what meaningful function it would have.
Maybe some async system? Or lazy vs eager eval? E.g
Would evaluate before assignment, while Would evaluate lazily.I think I would have said "送りなさい" and "読む為に". Hopefully, Haku is or can be made flexible enough to handle that.
A more natural form of those sentences would be "メッセージ/文書を送信(Send message/text)" and "書類を開いて読む(open and read document)" or "書類を読み込む(read-ingest document)", than implied imperative "[You] must send message" or "[You] open document for the purpose of reading" which don't feel to me that they follow this topic-comment logical structures.
This topic-comment model is also seen in Nadesiko Japanese programming language, as quoted below from "open file" function reference page:
> 「ファイル.txt」を開いて、Sに代入。
> Sを表示。
(my attempt at translation:)
> "file.txt" be opened, S it assign to.
> S be displayed.
As clearly seen, the object such as filename or variable are brought up first, then subsequently augmented, with subject simply missing.
1: https://en.wikipedia.org/wiki/Japanese_grammar
2: https://nadesi.com/v3/doc/index.php?plugin_node%2F%E9%96%8B&...
You can’t have suru work on a verb, so the author turns the verb “to read” into a noun by adding the no.
The kanji for suru and the lack of a wo kinda hides what is going on.
読むのをする→読むのをしに→読むのを為に→読むの為に
For the other one, I agree with you. Basically the only real looking result on google for “送なさい” is this thread and haku’s homepage….
It isn't. Few people in the world are unfamiliar with the Latin alphabet, definitely not the Japanese or any other wealthy nation. And since most really poor countries use the Latin alphabet, often for colonial reasons, I don't really think there is any large group of people that aren't familiar with it.
But yeah, programming will be slightly harder for them than for you or me.
This was driving me nuts because I could see 740 in it, but not 741 like the translation.
It turns out that 壱, 弌 and 壹 are used as 'one' in legal documents instead of the more common 一.
I've still got a long way to go learning Japanese.
https://nadesi.com/v3/doc/index.php?%E3%83%81%E3%83%A5%E3%83...
Sample program: Since it's basically natural language, it's a really nice language for introducing Japanese speakers to programming!====
There's also this language, Wenyan-lang, that imitates classical Chinese: https://github.com/LingDong-/wenyan-lang Sample:
Wenyan:
Equivalent JavaScript:"I call it 'haku' because I like the sound of it, and also because that word can be written in many ways and mean many things in Japanese. I was definitely thinking about Haku from Spirited Away. Also, I like the resemblance with Raku, the implementation language. I would write it 珀 (amber) or 魄 (soul, spirit)."
https://docs.raku.org/language/grammars
https://codeberg.org/wimvanderbauwhede/haku/src/branch/main/...