Japanese Programming Syntax
xamuel.com
xamuel.com
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.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.
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).
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 :).
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.
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...
One of the personality traits Ruby got from Perl was being a grab-bag of a bunch of stuff.
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.
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.
If the Japanese had the same position as the western world, our TTYs would probably a direction that more closely matched their language.
rainGear.grab();
rainGear.wear();
Isn't this just Java?(see also http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom...)
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
]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(x==y) ? a : b
There are languages which have pretty much exactly what he describes (Smalltalk for instance), but "many mainstream languages" don't.
( X==Y -> A ; B)