21 comments

[ 2.9 ms ] story [ 56.8 ms ] thread
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.
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

    rainGear.grab();
    rainGear.wear();
Isn't this just Java?

(see also http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom...)

Good point. Functional programming => verb(subject, object). OOP => subject.verb(object). English => subject verb object (is this some Lisp-like construct?).
(comment deleted)
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
    ]
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.
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.

It probably has more to do with these words (or syntaxes) meaning the same thing in the various languages Matz got inspiration from (Perl and FP languages use `map`, Smalltalk uses `collect`).

One of the personality traits Ruby got from Perl was being a grab-bag of a bunch of stuff.

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 :).

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.

To English speakers, using different counters for different classes of nouns is a pretty strange feature...

Strange, perhaps, but present. To a native Chinese and Japanese speaker like myself, the list of collective nouns for animals in English is staggering, almost mindblowing, and appears absolutely arbitrary: http://en.wikipedia.org/wiki/List_of_collective_nouns_by_sub...

Ah, but they are not synonyms, since you cannot use one for the other: you cannot use the counter for animal for things (except for puns - I let you guess what it means to use the counter for long, thin things to count guys).

I am no specialist in Japanese, but my understanding is that a likely reason for the various counters in Japanese is linked to the absence of singular/plural and male/female distinction in nouns, verbs, etc... I don't know about Chinese, but in Japanese, you can omit a lot of words which would be mandatory in western languages (e.g. the subject).

As for the OP, this is most likely cultural bias: latin has similar traits as far as grammar goes (verbs can go pretty much anywhere, for example).

> 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,"

True, but partially. CJK languages have a property that a numeral alone is not enough to quantify noun and a special "counting suffix" is required.

http://en.wikipedia.org/wiki/Japanese_counter_word

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.

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.

don't they have any programming languages in japan? perhaps in japanese?
the conditional syntax he describes does exist in many mainstream programming languages

(x==y) ? a : b

Moreover, using an arrow operator, the OP almost wrote a Prolog expression:

  ( X==Y -> A ; B)
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.

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.