Categories
Uncategorised

A Brief Discussion on Ruby’s Philosophy and AI Integration

This article is a brief introduction to the Ruby programming language and its philosophy, and why it can be a good option for AI.

To be honest, the main reason I wrote this article is to talk about Ruby and its philosophy. But since my blog focuses on AI and data science, I also wanted to include content that appeals to readers who are here specifically for those topics.

Why does this article exist in the first place?

That was the first question I asked myself while writing it, why should I even write something like this? The first reason is that I came across an article about RubyLLM, and it ignited a spark in me.

Not because I’m a super fan of the Ruby language itself, but because I’m a fan of Yukihiro Matsumoto’s philosophy behind Ruby. Honestly, I don’t use Ruby that often, which feels a bit shameful, considering how much I admire its philosophy. It’s like being a Persona fan who never actually played the game.

But today, that changes. Writing this article feels like a big step for me. It’s the first post about Ruby on this blog, and I think that’s a good start.

One Problem, Many Solutions

Ruby is often compared with Python, and it’s not an unfair comparison, both languages prioritize simplicity, but they approach it in very different ways.

Python’s core design is all about there should be one obvious way to do it. This enforces consistency and makes the language predictable.

On the other hand, Ruby’s philosophy is there’s more than one way to do it. The goal is to maximize developer happiness, giving you the freedom to express your ideas in the way that feels best to you.

You can think of it like this: Python gives you a clean, single-purpose tool to get a job done efficiently. Ruby gives you six beautifully crafted tools that do the same thing, just so you can pick the one you enjoy using the most, and maybe even have fun along the way.

text = "hello"
reversed_text = text[::-1]
print(reversed_text)

text = "hello"

puts text.reverse                     
puts text.chars.reverse.join         
puts text.split('').reverse.join     
puts (0...text.length).map { |i| text[-i-1] }.join  

Yes, Python gives you the simplest solution to reverse a text, while Ruby gives you four different cool options, so you can pick one depending on your mood that day.

Convention over Configuration

Emphasized heavily in Ruby (especially Ruby on Rails), you don’t need to spend time configuring the project, just keep going with the defaults so you can spend less time setting things up and more time creating something.

Write Code for Humans, Not Machines

Ruby strongly embraces writing expressive, almost natural-language-like code. The language feels intuitive and readable, making you feel like you’re having a conversation with your code instead of struggling to decode complex syntax.

This philosophy makes programming feel less like a chore and more like crafting something elegant, where the code flows smoothly and reflects your thoughts clearly. It’s one of the reasons why many developers say working with Ruby feels joyful and creative, because the language itself invites you to write code that reads almost like plain English.

Flexible and Adaptable Coding

Ruby’s flexible syntax and metaprogramming power let you write code that writes code. This means when things change or your project grows, you don’t have to start from scratch, you can easily adapt and customize your solutions.

With Ruby, you can even create your own mini languages inside your code (called DSLs) to make complicated stuff feel simple and fun. This freedom to shape the language to your needs is what makes Ruby so great for developers who want to keep things creative and ready for whatever comes next.

So basically, you can bend or break the rules as much as you need to in order to do things your way. Ruby gives you the freedom to customize and shape your code, letting you find the best solution that fits your style and the problem at hand.

Gems for AI Development

Let’s talk about Ruby’s libraries that are ready to use in the AI field. I also want to highlight an async library because, well, I love anything that boosts performance.

Rumale is like Ruby’s version of scikit-learn, giving you solid tools for classification, regression, clustering, and dimensionality reduction, all in Ruby.

Async is my favorite when it comes to performance, letting you run tasks concurrently so your AI workflows don’t get stuck waiting on things like API calls or data loading.

OpenAI Ruby makes it super easy to connect with OpenAI’s API and bring powerful language models like GPT right into your Ruby apps.

Ruby-Tensorflow lets you build and run deep learning models using TensorFlow but all from Ruby, while DNN is a pure Ruby deep learning library that’s perfect for learning and quick prototyping.

Plus, there’s Torch.rb, which brings PyTorch’s power to Ruby, yes that’s all what it does.

Conclusion

Are you also a fan of Ruby’s flexibility? Then I think it’s worth giving at least one of those Ruby gems a shot for your hobbies.

Who knows, maybe you’ll decide to use one of them for your main project and enjoy it too.

Ruby’s flexibility and philosophy really make coding fun and bearable, in my opinion. Plus, the Ruby community is doing their best to bring many libraries from Python to Ruby, so give it a try.

I’m a mess in the distress, but we’re still the best dressed…

Leave a Reply

Your email address will not be published. Required fields are marked *