Back in the days, when I got serious about becoming a “real programmer”, I decided I wanted to learn Java.
I didn’t know anything about OOP, Design Patterns, Single Responsibility… all I knew was some PHP, Visual Basic, and database design stuff. That was it.
So I went to a book store and I bought this book about Object-Oriented Programming in Java 6. It was a massive book, probably around 1000 pages of code and programming best practices, and I read like 80% of it. Some parts were too advanced for me, but I learned a lot.
I used to like Java. I thought, “so this is what real programming looks like, with classes and inheritance. That’s the right way”.
I actually believed this for a while, until that day…
One day I went to this website, projecteuler.net, which is basically a way to prove your skills by solving difficult programming challenges, and learn in the process.
It was years ago, but I remember I solved the first couple exercises pretty easily. The third one was a bit harder. Here’s the original text:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
Source: https://projecteuler.net/problem=4
I spent a few hours on it before coming up with this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
It’s 46 lines of code, without counting blank lines. Not too bad, right?
Ok, don’t be mean. I know that’s probably shitty code, but it was my own solution and I was quite proud of it.
Now, when you finish a challenge successfully, you’re given access to the forum, where other programmers post their own solutions in many different languages.
That’s where I first discovered Ruby.
I was reading the thread about the problem I just solved, when I stumbled across this Ruby solution:
1 2 3 4 5 6 7 8 |
|
And I was like, “holy shit, seriously? Only 8 lines of code?”.
I couldn’t believe my eyes. I was staring at something marvelous; some beauty that I never came across before.
Ruby is an object-oriented programming language that focuses on expressiveness and readability.
It was love at first sight. I started reading about this amazing language, about the fact that everything in Ruby is an object, even integers, and that you can write code like 3.times { print "Hello" }
to simply print “Hello” 3 times. It was like reading English, and I felt truly amazed, humbled, and inspired.
Anyway, that’s just part of my story about becoming a better programmer. I’m not sure what the point is, I just felt like writing it down. But if, like me, you’re one of those people that need some ‘takeaway’ from a story, I guess it should be this:
Just don’t stop learning, ever.
Keep on learning and practicing, and you too will discover beautiful things.