• Redkey@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    1 年前

    I’m no linguist, but I have some Japanese language ability, and Japanese seems to be pretty different, grammatically, from English, so I’ll draw on it for examples. I also had a quick look at some Japanese-centric programming languages created by native speakers and found that they were even more different than I’d imagined.

    Here’s a first example, from an actual language, “Nadeshiko”. In pseudo-code, many of us would be used a statement like the following:

    print "Hello"
    

    Here’s a similar statement in Nadeshiko, taken from an official tutorial:

    「こんにちは」と表示
    

    A naive translation of the individual words (taking some liberties with English) might be:

    "Hello" of displayment
    

    I know, I know, “displayment” isn’t a real English word, but I wanted to make it clear that the function call here isn’t even dressed up as a verb, but a noun (of a type which is often used in verb phrases… it’s all very different from English, which is my point). And with a more English-like word order, it would actually be:

    displayment of "Hello"
    

    Here’s another code sample from the same tutorial:

    「音が出ます!!」と表示。
    1秒待つ。
    「プログラミングは面白い」と話す。
    

    And another naive translation:

    "Sound comes out!!" of displayment.
    1 second wait.
    "Programming is interesting" of speak.
    

    And finally, in a more English-like grammar:

    displayment of "Sound comes out!!."
    wait 1 second.
    speak of "Programming is interesting".
    

    And here’s a for…in loop, this time from my own imagination:

    for foo in bar {  }
    

    Becomes:

    バーのフーで {  }
    

    Naively:

    Bar's Foo with {  }
    

    More English-y:

    with foo of bar {  }
    

    You may have noticed that in all of these examples, the “Japanese” code has little whitespace. Natural written Japanese language doesn’t use spaces, and it makes sense that a coding grammar devised by native speakers wouldn’t need any either.

    Now, do these differences affect the computer’s ability to compile/interpret and run the code? No, not at all. Is the imposition of English-like grammar onto popular programming languages an insurmountable barrier to entry for people who aren’t native English speakers? Obviously not, as plenty of people around the world already use these languages. But I think that it’s an interesting point, worth considering, in a community where people engage in holy wars over the superiority or inferiority of various programming languages which have more in common than many widely-spoken natural languages.