👋 Hi there and welcome to the first post in our series, Rediscovering Ruby.
My name is Julianna. I’m a primarily backend-focused Software Engineer at Forem and I have been working with Ruby and Rails, almost exclusively, for roughly 3 years now and I still learn new things about Ruby almost daily.
My name is Ridhwana and I’m a Full Stack Lead Software engineer at Forem. I’ve been dabbling in Ruby on Rails for about 8-10 years and spent just under half of that time focussing on backend development which has been leading me through weird and wonderful explorations in this language.
We’ve been working together for a while now and thoroughly enjoy it. We often find ourselves talking through Ruby concepts or pair programming asynchronously through draft PRs. We’ve realized that a lot of developers (including ourselves) end up learning a new language by exploring and copying existing patterns within an already existing codebase. This sometimes leaves us without a name for a pattern that we’re following or without a deeper understanding of what's happening behind the “magic” of the language. It also means that sometimes we struggle to articulate concepts that we use on a daily basis.
Hence, we came up with an idea to write a series of posts that explore and explain these different concepts in Ruby. We hope that you’ll follow along and share your knowledge and experiences with us too.
First, we’ll begin with the basics–foundational concepts and the like. While the rest of our plan is still a bit up in the air, after covering some of the core Ruby concepts, we plan to slowly start introducing more complex topics. Some of the concepts and topics that we hope to cover include: classes, objects, memory, and duck-typing.
With that being said, let's dive into an introduction of our favourite language Ruby.
Ruby was conceived in 1993 and publicly released in 1995 by its creator Yukihiro “Matz” Matsumoto. It's approximately ~27 years old already!
Over the years, Matz, Ruby’s creator, can be found talking about some of his motivations for creating Ruby. Some of these include:
- Blending parts of his favorite languages at the time like Perl, Smalltalk, Ada and Lisp etc. into a better object-oriented version, Ruby.
- In a Google talk in 2008 he told the audience that he hoped to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. He also jokes that he created Ruby for selfish reasons because he was so underwhelmed by other languages that he just wanted to create something that would make him happy.
Shortly after the release of Ruby, interest in the language quickly grew in Japan. In 2000, the first English-language book “Programming Ruby” was released by author Dave Thomas. This helped to spread the language internationally, and by 2006 Ruby had become popular worldwide. However, after the release of the Ruby on Rails framework the community grew even bigger.
As mentioned above, Ruby has been around for a while, and so has the community that supports the language. The Ruby community has a reputation for being welcoming and supportive, which is one of the reasons why the language is often suggested for beginners.
If conferences or meetups are your thing (or if you’d like them to be!), Ruby has a plethora of in-person and more recently, remote events. Additionally, due to the age of the language and the size of the community, there are many opportunities to contribute to Open Source projects that use Ruby as their foundation and there are many learning resources available (like this one! :)) for when you want to better acquaint yourself with the language’s intricacies.
Ruby can be described as “Object Oriented and Dynamic language.”
What exactly does object oriented mean?
This means the language is centered around the concept of “objects.” Hence, in order to write useful applications in an OO language, the code will contain a group of objects. Each object will have its own set of attributes and methods, and these objects will send and react to messages from the other objects. .
In order to understand what is a “dynamic language'' let's get two definitions out of the way - compile time and run-time?
Compile-time is the time at which the source code is converted into an executable code.
Run time is the time at which the executable code has started running.
Knowing the above, what does this have to do with a dynamic language?
Well, a dynamic language gives us the ability to carry out certain actions at runtime that other languages cannot, such as assigning and reassigning objects without running into compiler-related issues.
In addition, if any errors occur during compile-time, the process will not be halted by those errors and will continue to move forward. For example: If we were to call a method on an object that does not exist, the compiler will not produce a warning or an error. Only once the code is executed will we see a
Okay, so we’ve discussed what object-oriented and dynamic means–is there anything else that sets Ruby aside that I should be aware of?
When it comes to memory allocation and deallocation, Ruby is one of those languages that handles it for you. Memory allocation and deallocation is baked into the language so that, for the most part, you don’t have to think about how to allocate and deallocate memory on a day-to-day basis–this is handled by Ruby garbage collection.
There are entire books written and countless talks given on Ruby’s garbage collection mechanism, but a concise explanation for just what Ruby garbage collection is, is that it’s a mechanism within Ruby that handles memory usage–both allocation and deallocation. Ruby provides an interface for its garbage collection so that, in the event that you need to adjust memory usage (or if you’re just curious like us!), then you can see just what’s going on under the hood.
And that’s it folks…
We hope that this post piqued your interest, as we’ll be diving deeper into some of these concepts in upcoming posts. Thank you for reading!