Talks

Writing Ruby, just not in English!

My talk shows how to write Ruby in a non-English language and the benefits of doing so. This will certainly be a great help for people who don’t speak English. It also helps get a better programming perspective for seasoned developers who don’t have English as their first language. I will also demo the tooling that I have developed, using which one can quickly create a new spoken language variant of Ruby and start programming in Spanish, Portuguese etc.

RubyConf 2022

00:00:00 Ready for takeoff.
00:00:16 Hello everyone, my name is Ratnadeep.
00:00:19 The topic we are going to discuss is writing Ruby, just not in English.
00:00:24 You can find me as @rtdp on Twitter, so we can connect there. I am also a digital nomad.
00:00:30 Being a digital nomad involves working from amazing places, like this one, which is at 18,000 feet—the highest motorable road in the world.
00:00:37 I went there, sat in a café, and coded some Ruby. I even claimed to have made the world’s highest altitude Ruby commit from there.
00:00:46 I also travel quite a bit in the Himalayas, working from these breathtaking locations, which I proudly refer to as my office.
00:00:52 These are some views from the window of my office. Additionally, I created an open-source Rails application called "Why Love Ruby."
00:01:06 The idea is that you can log in and post your reasons for loving Ruby. Please check it out! As you might have guessed, the most upvoted answer there is obviously about the community.
00:01:15 Moving on, I want to start with a dialogue from Mads, who stated that Ruby's main purpose is to be productive, enjoy programming, and be happy.
00:01:26 So, this is a piece of code. Do you understand what it is? I'm sure you do, as it's syntax highlighted and is indeed code itself.
00:01:42 For those familiar with Ruby, do you see any problems understanding this code? It's just Ruby, after all. Any problems?
00:01:55 The reality is that the barrier to understanding this code isn't the logic or the programming language itself. The barrier is the English language.
00:02:13 Remember how it feels when you can't understand the code? This is the kind of feeling that 95% of the world experiences, especially those who don't have English as their first language.
00:02:24 That feeling inspired me to create the Ruby vernacular—a way to write Ruby in various languages.
00:02:34 Today, I will outline what we will look at: the story behind how and why I started this initiative, the reasoning for having such tools, some real examples, and a look into the tooling available.
00:02:54 Finally, we will also have some fun with Ruby. So let's dive into the background of this project.
00:03:06 It all began when I was teaching Ruby to my younger brother. Here's a photo of his dog, who is much more photogenic than him. Many of his questions were about why we use certain keywords like 'class' and 'def' when defining a function.
00:03:30 Many of his queries were related not to logic but to the English language itself, leading me to think about how useful it would be if we could have a programming language presented in his own language.
00:03:46 This way, language wouldn't be a barrier, and he could grasp the concepts of object-oriented programming without confusion.
00:03:59 To provide more context, in the Indian setting, the word 'class' typically relates to school classrooms.
00:04:02 This connection can cause confusion when learning programming concepts. Now, moving on to the reasoning behind this initiative.
00:04:33 Assigning meanings to words is essential. Oftentimes, programming languages lack clear meanings, and we must derive meaning from outside sources to relate the code to our understanding.
00:04:50 For example, implicit versus explicit code can create confusion. Developers sometimes differentiate between admin roles and manager roles based solely on character lengths, which risks misunderstanding the intent of the code.
00:05:20 Here's how clarity can be achieved: explicitly checking if a given role is part of all admin roles. This avoids ambiguity.
00:05:34 Let me share a story called the Gimli Glider from 1983, which teaches valuable lessons about communication and teamwork.
00:06:07 During a flight from Montreal to Edmonton, a new Air Canada Boeing 767 encountered a fuel pressure alarm due to a mistake with the measurement systems: the crew miscalculated fuel in pounds instead of kilos.
00:06:41 This accounting miscommunication caused the plane to land without enough fuel, but both pilots navigated it successfully to land at Gimli Airport without any injuries.
00:07:03 This incident highlighted the importance of communication and teamwork, just as we often experience similar issues in the Ruby and Rails world.
00:07:28 For instance, the renaming of 'before action' to 'before filter' pursued clarity that often later generated headaches during upgrades when developers were required to change existing code.
00:07:46 In pursuit of meaningfulness, we see it reflected in our community with the growing emphasis on domain-specific languages like Rspec.
00:08:05 Now, let's look at some real-world examples. I have created a couple of Spanish code examples to demonstrate this concept.
00:08:32 For instance, here’s a simple 'Hello World' program where I translated the standard Ruby keywords into Spanish.
00:08:49 This was relatively easy because Ruby’s flexibility allows for simple aliases for basic commands. However, translating more complex structures poses challenges.
00:09:05 For example, we can create a Spanish version of a Ruby program that includes translations for keywords like 'class', 'def', and 'end'.
00:09:17 Let’s check if we can run that code together.
00:09:26 If I run this translated code, you can see the command to execute it is not just Ruby, but 'Ruby Spanish'.
00:09:36 This method allows us to seamlessly execute code while using our own language.
00:09:47 Moreover, the approach I used for translation relied heavily on literal translations, which I initially obtained through Google Translate.
00:10:05 After collaborating with some Spanish developers, I noticed parallel issues to those found in Marathi or Hindi languages regarding object-oriented programming terminology.
00:10:24 For instance, the word 'class' holds various annotations in many languages. This made me question and redefine its meaning to ensure clarity.
00:10:41 The term I came up with translates to 'mold' or 'die cast', which describes the role of classes in shaping our objects.
00:11:07 Discussions with fellow developers about terminology led to questions over many keywords in programming—especially the meaning and appropriateness of using words like 'class'.
00:11:27 For example, if we were to redefine object-oriented languages today, would we still use 'class', or perhaps 'template' might be more suitable?
00:11:38 This topic extends to other keywords as well, such as 'module', which in some languages suggests a satellite component rather than its intended usage.
00:11:53 Here are some more Spanish examples depicting control structures like loops that remain functional after translation.
00:12:00 These examples demonstrate how we can construct loops in Spanish, further illustrating the effectiveness of a bilingual code approach.
00:12:14 However, there is no need to demo all variations extensively, as we have already seen a few.
00:12:31 Additionally, we have Hindi and Marathi Ruby examples, showcasing diverse yet effective translations as well.
00:12:44 The key takeaway from coding in native languages is that the contextual examples can be more relatable, engaging, and ultimately more educational.
00:12:55 Localizations allow us to incorporate culturally relevant examples, significantly enhancing the learning experience.
00:13:07 Now, let’s discuss tooling. Creating these translations requires just a couple of gems.
00:13:18 The first is the Ruby vernac parser gem. This gem generates the structure for the desired language and loops through all standard classes and methods.
00:13:38 It makes API calls to Google Translate to obtain literal translations while allowing developers to refine these translations.
00:14:00 It's crucial to ensure meaningfulness in translating. For example, direct translations might yield incorrect meanings.
00:14:23 The goal of the Ruby vernacular is not to replace existing code but to provide an avenue for learning programming without needing English proficiency.
00:14:33 This tool allows non-native speakers to learn programming and find meaningful translations that resonate in their native language.
00:14:45 As we wrap up, I want to mention Aaron Patterson, known for his humor and contributions to the Ruby community.
00:14:56 He created the 'mini test emoji' gem to replace passing tests with emojis.
00:15:07 Inspired by this, I applied a similar concept to the Ruby vernac parser, creating an emoji-based Ruby vernacular.
00:15:21 This code is entirely composed of emojis, and remarkably, it is still valid Ruby code.
00:15:37 Thank you all the contributors and volunteers, especially Daniel, Julia, and Spartaco, for their help in translation.
00:15:53 If you want to learn more or play with the idea, please feel free to tweet me.
00:16:02 Thank you for attending!