Skip to main content

The Japanese Roots of Ruby (Ruby Program pt. 10)

Before starting to learn Ruby I had attempted to learn Python. They're very similar languages in terms of use, both dynamic, object-oriented, scripting languages.

I picked Ruby to learn because when I looked at the code it made sense to me. I didn't have to try to do a mental jump so high from the beginning. At first I could not see any Japanese influence on Ruby. Ruby was created by a Japanese guy and it's very popular in Japan, and I speak Japanese.

But now I'm beginning to see and suspect that it has a lot to do with the readability of the language. Let's contrast a simple statement in Python which is written by Europeans. Recently Python went through a mayor revision (which still hasn't completed) that broke backwards compatibility, because one of the main philosophies behind Python is having only one way to do things.

So in Python 2.6 you could say print "Hello World" now on Python 3 you have to say print( "Hello World"). The purpose of this was to simplify the syntax since all method calls except print used the method(something) form. Now this is clearly a mathematical-driven syntax from f(), which to this day confuses me a little. To me this doesn't make things clearer. But it allows Python to have a verb-object relationship. The method does something on the contents of the parenthesis. For some people I'm sure this looks more like normal language, but to me this looks more like math than language.

On Ruby, where many ways of doing things are allowed, the equivalent command would be puts "Hello World" now you can write it another way too: "Hello World".puts. In fact you can chain commands like "Hello World".chop.puts. And that looks like typical Japanese syntax. You say what you're talking about and then what happens to it. Like "HERO"ga iimashita. (I said "Hello.")

I find this syntax much easier than the more obtuse mathematically driven syntax used in Python and other similar Western programming languages (C, Java). To me that fx(x) or "f" of  "x" syntax is nothing like normal language, unlike Ruby's which can be very much like the Japanese language. Even if you don't know Japanese, it's easier simply because it's more like natural language and less like math.

Comments

Popular posts from this blog

Multiple Assignments in Ruby

In this Rails project I'm running I need to set a whole bunch of individual variables to 'disabled' at once depending on the group the current user belongs to. We can use multiple assignment in this case but with a caveat. Multiple assignments are a quick way of setting a lot of variables at once. h, k = 1,2  => [1,2] h => 1 k => 2 but   h, k = 1      => 1 h => 1 k => nil In that case we can do this: h = k = 1   => 1 h => 1 h => 1  Beware this sets them to the same object. So if you change one you change both. h = k = [] h << 1 h => [1] k => [1] While we're at it here is how to reverse two variables: h = 1 k = 2 h,k = k,h h => 2 k => 1

What Medieval Economics can teach us about tariffs.

As a teen, I used to play Dungeons and Dragons (D&D) with my friends. This started an interest in the medieval period that led to me taking a medieval history class in college just to understand the period more. Over the years I've also read great books like " Dungeon, Fire and Sword " about the crusades (I recommend the book) and yet with all that knowledge it wasn't until recently that it occurred to me I had a completely wrong understanding of economics in the Medieval Period. "Viking helmets, sword and footwear" by eltpics is licensed under CC BY-NC 2.0 In my D&D games, players who are adventures battling monsters and creatures would need equipment and on the trips to town, they'd get resupplied with their adventuring necessities. I'd run these moments referencing my imagination of what it must have been and fantasy books I'd read. There be an inn with a raucous bar, a gruffly black-smith, if a city also a weapon and armor sm...

Setting up the Marble Mouse for Ubuntu

I have a Logitech trackball which I love. I bought it when my wrists started hurting after hours of long Photoshop sessions. The switch to the trackball fixed all that. It allows me to hold my hand in the perfect position and it's great for most browsing with one exception: It lacks a middle-click wheel. This presents a bigger problem than it seems, as design seems to be removing the scroll bars at the edges of windows in favor of small slits. So to get around this you can emulate a scroll wheel or use the middle click to activate a scroll motion on various programs. Logitech has a utility that sets this up in Windows but in Ubuntu you have a better (if more hard-work required) option. The Ubuntu option is better because unlike in Windows you can emulate the wheel with the track-ball by holding down a button. This is the option I like to use. In Ubuntu you write a configuration file to set up the trackball to work the way you want it. I have to re-create this...