Sunday, December 28, 2008

Ruby First Impressions

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 )
result = val1 * val2
return result
end

def
multiplyLocalVariable(val1, val2 )
result = val1 * val2
end

def
multiplyNoVariables(val1, val2 )
val1 * val2
end

def
multiplyAssignToMethodName(val1, val2 )
multiplyAssignToMethodName = val1 * val2
end

puts multiplyWithReturn(5,6)
puts multiplyLocalVariable(5,6)
puts multiplyNoVariables(5,6)
puts multiplyAssignToMethodName(5,6)



Running this code prints








30
30
30
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.

Monday, December 15, 2008

Continuous Build Systems

I have gone through so many tools trying to create the right build environment that it is a bit disheartening. I have set up multiple continuous integration systems and it keeps getting easier, but there is still a bit too much friction.

I tried to look into using Team Foundation Server and Team Build, but the cost is very high for a startup (even with the top msdn subscription). This is compounded when you have external developers that must also hook into the system.

I have fallen for TeamCity but with one deal breaker for me: no FinalBuilder support. I submitted some feedback and I received a detailed response from JetBrains; I have always received great customer support from JetBrains:

There are several ways to support FinalBuilder:
1. You may start using CommandLine runner to start the process.
2. To Add custom FinalBuilder reporting you may use TeamCity service messages.
   Please refer to
http://www.jetbrains.net/confluence/display/TCD4/Build+Script+Interaction+with+TeamCity
   documentation article on service messages for details
3. You may start FinalBuilder from any other build scripts,
   for example NAnt, MSBuild, Ant, Maven.
   If  you  need  custom  logging,  you  may  consider using TeamCity
   Service messages as well
4. Write a build runner plugin for TeamCity. There are two
   public available examples on the build runners at:
http://www.jetbrains.net/confluence/display/TW/Rake+Runner
   and
http://svn.jetbrains.org/teamcity/plugins/fxcop/
   Please feel free asking any questions on the integration.
5. Post an issue to our tracker at
   http://www.jetbrains.net/tracker

I checked out the code for the build runner plugins, but it is too much work. It is hard not to sound lazy in saying that, but I haven’t used java since my sophomore  year in college, and it doesn’t sit high on my list to spend hours getting a build runner going (I am looking for less friction, not more). I chose the 5th option and submitted a feature request TW-6442. With FinalBuilder support I don’t need any other build runners/tools as FinalBuilder most likely wraps them up in its UI.

One other feature that I would like to have, but am hesitant to request right now, is to be able to selected a successful build, and run a publish script (through the web interface (see Cruise)) that can tag the build and use the build  artifacts to deploy that build to Dev/Stage/Production environment.