This post is co-authored by @juliannatetreault and @ridhwana.
Introduction
š 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.
Why are we writing this series?
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 pull request reviews. 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.
What do we plan on covering in this series?
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.
About 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.
The Ruby Community
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.
A Ruby Primer
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 NoMethodError.
Okay, so weāve discussed what an object-oriented and dynamic language 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.
ā¦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!
Top comments (7)
Sweet series! Rediscovering Ruby is such a great title and I'm sure the content will live up to it!
Nice work @ridhwana and @juliannatetreault! š
Did not know you could access the garbage collector. Learn something new everyday!!!
Are there any examples where people have done this?
Hi šš½ apologies for the delayed response here. This is a good question - I'm not sure that I can point to specific examples, but the most common use case for accessing the garbage collector is to debug complex memory management issues.
Very interesting. I'll have to look around for examples.
So excited for this series! I've been in an on-and-off relationship with Ruby for the last 10 or so years, and I just know that these posts will make me love it even more. Thanks!
Thank you! we're pretty psyched to be writing this too. If there are any Ruby topics that you would find beneficial to read about, please drop us a note š
Hello @ridhwana
Nice to know you. I have a minor problem with using api written in ruby...
Would you like to talk through telegram for me?
I want to learn from you.
@mijin1993