I decided to try out Ruby today. I have wanted to try it out for quite a while. Some of my impressions may be inaccurate, but I have done what I can. I have Zero interest in DB and web ‘programming’ so I am going to skip rails and related material.
I tried to use JetBrains’ RubyMine, but I couldn’t get anything to run. I know it is a public preview, but for the time I am willing to put into Ruby, there was just too much friction for now. I look forward to trying out the full product when it is RTM.
I installed Ruby In Steel Personal Edition and that was a great way to get started. I ran the installers and I was up and running in a familiar environment. I created a Ruby project and I started with hello world. After that I started going through the guide at Techtopia and the RDocs. I love the product for a free version, but for someone trying to learn Ruby, the intellisence feature would be handy. I am never going to pay $200 for an IDE that I would use as a hobby; that being said, if I ever were to program Ruby as a job, $200 is a great price.
What I like
- very straightforward language
- I loved that when I wanted to shift the elements of an array I found it was built-in
- Class library
- being able to have a line of code like this; I wish I knew what to call it
- return SolveUsingClosedFormExpression( n ) if ( 0..1474 ).include? n
- return SolveUsingClosedFormExpression( n ) if (0..1474) === n
- I will complain about this as well, but in writing the closed form Fibonacci solution, the data type changes allowing for huge results
def SolveUsingClosedFormExpression(n)
left = GOLDENRATIO ** n
right = (-GOLDENRATIOINV) ** n
return ( (left - right) / ROOT5 ).to_i
end
What I didn’t like
- Trying to figure out how to use gems (packages, not the tool) and files in the class library
- Lack of type information
- Yes, yes, I know, I know, but for a c, c++/cli, c# programmer, it feels just wrong
- Declaring a variable feels like I am introducing a magic variable - *poof* it exists. At least in TI-Basic I had to declare my dynamically typed variables. \
- Lack of method return types
- At least four ways to return a value from a method, see below.
- Inconsistent API
- I was very frustrated when trying to use .power! only to find that it isn’t defined for Float types – I have to use ** everywhere.
- Ruby is supposed to be super OO, but what object contains puts/print?
What I really didn’t like
def multiplyWithReturn(val1, val2 ) |
Running this code prints
30 |
I don’t know if I am missing a key ‘feature’ of the language, but at least four ways to return a value from a method just really irks me. Given that there is no return type of a method, reading code to determine what is returning a value and what methods are void seems ridiculous.
I have never programmed in a dynamic language, so it has been a bit of a ride. There a so many nuances to the language, it will take a while to get them down, but they allow for very concise code.