

Japanese Programming Syntax - DiabloD3
http://www.xamuel.com/japanese-programming-syntax/

======
mechanical_fish
I've always marveled at the number of synonyms in Ruby. collect() and map()
are the same thing, there are a bunch of ways to make lambdas, etc.

We should start the urban legend that each of these synonyms has a different
degree of politeness.

    
    
       your_lovely_array.collect { |awesomeness| awesomeness.aspect }
    
       my_worthless_array.map { |x| x.thing }
    

Bonus points for anyone who can get this meme propagating on Stack Overflow.

~~~
billybob
I have heard speculation that the abundance of synonyms may originate with the
Japanese language. I was told that in Japanese (which I don't speak), you
might use a different word for "one" when saying "one cat" versus "one house"
or "one country," and that the word choice would be made based on which one
"sounds best" in that context.

IF that's true (can anyone confirm?), it might have seemed fitting to Matz
that using "collect" vs "map" would be an aesthetic choice for the programmer.

~~~
JMStewy
This is true, and it's not unique to Japanese (Chinese does it too). But I'm
not sure the existence of this specific feature in the language supports any
particular generalizations about a "Japanese mindset."

To English speakers, using different counters for different classes of nouns
is a pretty strange feature, but I'd imagine no stranger than the Japanese
might consider our plurals. Japanese (and Chinese) don't inflect nouns for
plural agreement at all. From there, imagine how English's seemingly random
collection of irregular plurals must seem (feet, oxen, halves, deer, women,
mice, children, dice, larvae, alumni, bacteria, etc).

I wonder what features of English-origin programming syntax they might link to
this bizarre collection of special cases :).

~~~
mechanical_fish
_But I'm not sure the existence of this specific feature in the language
supports any particular generalizations about a "Japanese mindset."_

It doesn't, of course!

I thought about making that point explicitly, but eventually decided that the
OP was obviously a big joke so I might as well go along with it. ;)

One of the most fun things to do in linguistics class is to identify the
supposedly-unique features of odd foreign languages and then find them in
English. Using tone to convey meaning? I _think_ you might be able to come up
with _some_ kind of example. Using clicks as phonemes? Tsk, tsk, tsk. And so
on. And English has formal and informal modes. There's studies showing that,
like, people speaking to each other informally, like, use all these, um,
little interjections, for which they are sometimes mocked as inarticulate. But
put them in a different social situation, and their speech tends to become
more formal and those "likes" disappear.

English has lost most of German's fancy gender and case-marking systems, but
there are fascinating residues left over. I forget the detailed examples;
hopefully I kept my notes from that class.

------
rwmj
All good except the very final example. If it was really going to be written
right to left, top to bottom, then that would only make sense if whole
characters were used, roughly equivalent to words in the made-up language, not
equivalent to single English letters.

Something like this:

(

weather

WxRAIN

==

?

etc. (Also I moved == after the object since it's going to be postfix in
Japanese).

But in any case I highly doubt that any language invented for a computer (ie.
recently) would be written top to bottom. Just about every computer in Japan
is using left to right.

~~~
mmastrac
That's probably because the cultures that developed TTY displays developed
them so that the cursor moved from left-to-right, top-to-bottom.

If the Japanese had the same position as the western world, our TTYs would
probably a direction that more closely matched their language.

------
DarkShikari

        rainGear.grab();
        rainGear.wear();
    

Isn't this just Java?

(see also [http://steve-yegge.blogspot.com/2006/03/execution-in-
kingdom...](http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-
nouns.html))

~~~
masklinn
The whole thing really feels a lot like Smalltalk.

Some things don't work as well (can't use `;` for the contexts), but apart
from that, a smalltalk-like language works well:

    
    
        (weather is: #(#rain? #drizzle?)) ifTrue: [
            'rain gear' haveObject: [
                grab
                wear
            ]
            'door' openObject;
                   walkThrough
        ] ifFalse: [
            'house' stayIn
        ]

------
zerosanity
This exact same line of thinking went through my head a few days ago. Since
I'm starting to toy with learning Japanese I wondered how a programming
language with a SOV ordered syntax would look like. I guess now I know.

~~~
merloen
Stack-based languages like forth have a SOV (postfix) order.

An interesting property of postfix languages is that the order of evaluation
of functions is identical to the order of the function names in the source
code:

Functional (prefix, C)

    
    
        f3(f1("") f2(""))
    

OO (infix, Java)

    
    
        "".f1().f3("".f2())
    

Stack-based (postfix, Forth)

    
    
        "" f1 "" f2 f3

------
ahhrrr
Even though Japanese is traditionally written vertically, right to left,
modern Japanese is just as valid written horizontally, top down. Latin
characters are never written vertically – so code wouldn't be either.

------
probablyrobots
the conditional syntax he describes does exist in many mainstream programming
languages

(x==y) ? a : b

~~~
masklinn
No. You can't put statements in this, only expressions. It's a limited special
case instead of a generic tool (and putting a sequence of conditionals and
actions is not going to look good, though I'm sure you can coerce them into it
using the "," operator, as long as you don't need to have an iteration as
well).

There are languages which have pretty much exactly what he describes
(Smalltalk for instance), but "many mainstream languages" don't.

------
mijnpc
don't they have any programming languages in japan? perhaps in japanese?

