Ruby and the Japanese Language

You’re closer than you think to a career in tech. Our grads have launched rewarding new careers — you can too.

View Our Jobs Report

The following is a guest post by Carlos Lazo and originally appeared on his blog. 

こんにちは世界 (Kon’nichiwa sekai!)

The inspiration for this blog post comes from a few places:

  1. My love of languages and world-wide celebration of culture.

  2. This slide deck by Makoto Inoue on Ruby and Japanese.

  3. General curiosity on the topic.

Growing up, my first spoken language was Spanish, followed shortly thereafter by English and French, all three of which I’m fluent in. In the present, I split my time between learning 5 other languages – Japanese, Mandarin Chinese, German, Italian, and Russian.

Interestingly enough, during this same time period, I’ve also worked with a variety of different programming languages – C, C++, C#, Java, Python, Scheme, and MATLAB. I continue to learn languages, like Ruby, JavaScript, and HTML/CSS.

That begs me to ask the question:

Is there a link between programming languages and spoken languages?

Why yes, yes there is – let’s take a look at Ruby and the Japanese Language.

Insight into the Japanese Language

Japanese has a total of three (3) different alphabets, all of which serve their own purpose:

  1. Hiragana – syllabic alphabet for domestic use.

  2. Katakana – syllabic alphabet used for “borrowed” / new words.

  3. Kanji – symbolic alphabet used to import Chinese words.

Most students learn the syllabic alphabets first through memorization and mnemonics, using charts like this one to assist in the memorization:

Blog post image: tumblr_inline_mquygjmOqs1qz4rgp.png

Thousands of Kanji characters are in existence today – an individual in Japanese is considered fluent when they have mastery of the base 2000 characters. These are generally learned through memorization and constant practice.

Cool – so how does the Japanese language relate to the Ruby programming language?

Japanese <=> Ruby – What’s the Deal?

Based on the definitions of the alphabets, we can see the following comparisons between the Japanese spoken language and the Ruby programming language:

  1. Hiragana – syllabic alphabet for domestic use.

In Ruby: built for domestic ease-of-use (focus on programmer happiness).

  1. Katakana – syllabic alphabet used for “borrowed” / new words.

In Ruby: continually evolving and adapting new functionality.

  1. Kanji – symbolic alphabet used to import Chinese words.

In Ruby: merge (import) concepts of Object Orientated / Functional programming.

Furthermore, parts of the Japanese language can be seen as both object oriented (OO) and functional in nature.

Object Oriented Comparison

Thinking back to when we were learning English, our teachers taught us that sentences are formed in the following order: Subject – Verb – Object (SVO). It’s fair to state that English is an “Object-Oriented Language,” where context revolves around the object in question.

Japanese is quite similar, with the “normal” form of expressions being in the following form: Subject – Object – Verb (SOV). For example, take the following sentence:

Blog post image: tumblr_inline_mquyhi3xCr1qz4rgp.png

Ruby’s primary focus, much like the Japanese language, targets the object as the center of attention. Although the grammatical structure may be different, the intention remains the absolute same.

In terms of code, Ruby also allows us to define functionality in both object oriented and procedural ways:

Blog post image: tumblr_inline_mquyiaIUf11qz4rgp.png

The example above shows the flexibility of Ruby to implement the same solution using two different grammatical orders. In most cases, when dealing with a complex problem, functionality is encapsulated within a class. Object Orientation proves to be a great aspect of the Ruby language.

Functional Comparison

Japanese grammar is different in that it is post-positional:

Blog post image: tumblr_inline_mquyjeUKTW1qz4rgp.png

These post-positional words are used to decide the role of the noun which it supports. This would allow a Japanese speaker to change the order of the grammar pretty easily, chaining as many sentences as desired, and even omitting the subject altogether.

Here are some examples:

Blog post image: tumblr_inline_mquyl6zXDF1qz4rgp.pngBlog post image: tumblr_inline_mquym4Hfne1qz4rgp.png

Where do we see this sort of behavior in Ruby?

Blog post image: tumblr_inline_mquyn9jmbX1qz4rgp.pngBlog post image: tumblr_inline_mquyo5ioHX1qz4rgp.pngBlog post image: tumblr_inline_mquyoqt8qg1qz4rgp.pngBlog post image: tumblr_inline_mquyp9vk6n1qz4rgp.png

Functional programming in Ruby allows for hard-core abstraction and meta-programming, which is something that other programming languages do not support as easily.

Ruby in Japanese

One example of a gem that allows you to evaluate Japanese characters and expressions in the Ruby programming language is the japanize gem.

Here’s output to what a command line might look like, along with a test that was written in order to test the interpreter:

Blog post image: tumblr_inline_mquyrj6I631qz4rgp.pngBlog post image: tumblr_inline_mquysalSQm1qz4rgp.png

Note that this gem is outdated (3 years old), and that other gems exist that establish the morphemes (translation patterns) between English and Japanese for Ruby.

Embracing Language Diversity in the World

Too often, I overhear people argue over which language is:

  • Better.

  • Faster.

  • Stronger.

  • More Robust.

  • More Semantically Correct.

As programmers and as citizens of a diverse world, it’s up to us to respect language in general, whether programming or spoken. It should come as no surprise that programming and spoken languages are so similar, as one is used to express the other.

Blog post image: tumblr_inline_mquyw8vnDP1qz4rgp.png

Inspired to make coding Ruby a part of your life? Flatiron School's Software Engineering program teaches you all you need to know to become a professional programmer and is well worth it.

If you're interested in dabbling in some Ruby, we also offer a free introductory Ruby workshop.

If you're thinking about a new career but are wondering how to fund your bootcamp, read "How to Pay for a Coding Bootcamp" or visit out Tuition & Financing page. 

Headshot of Flatiron School

Flatiron School

Blog Post Author

Read More Ruby Articles

Since we opened our doors in 2012, thousands of students have joined Flatiron School to launch new careers in tech.

Explore our Courses

Find the perfect course for you across our in-person and online programs designed to power your career change.

Explore Our Courses
Join a Community

Connect with students and staff at meetups, lectures, and demos – on campus and online.

Join the Community
Schedule a Chat

Have a question about our programs? Our admissions team is here to help.

Schedule a Chat