Sunday, February 20, 2011

Learning Object-C and Ruby

I'm trying to teach myself several languages to increase my Foo. I've decided to learn Ruby (which I already know via Rails but I want to become intimately knowledgeable), Objective-C, Python and Groovy. I'm starting off learning Ruby and Objective-C and Here are the things I've found that I like and dislike about each - with the caveat that since I'm still learning these languages I may incorrectly understand some of the things I dislike.

Objective-C
Like:
  • Since it is the language of Apple, the tools (XCode, IB) are powerful but insanely simple.
  • The basics of the language feel comfortable coming from a Java background - why shouldn't they since both harken back to C.
  • It is taking some getting used to but I really like the separation of the header (interface) with the class file (implementation) because it forces me to think of the messaging of my objects instead of the data - ala SmallTalk
  • Documentation is right at your fingertips, even offline. I know you can download the Java API but I'm lazy. :)
Dislike:
  • Pointers: I understand their power but with great power comes great responsibility; responsibility that I haven't had to worry about in Java.
  • Glyphs: I thought Java had a lot of syntactic glyphs but Objective-C will gives you carpal tunnel - (MyObj *)methodName:(type)parameter vs. MyObj methodName(type parameter) -- 4 extra syntax characters to accomplish the same thing.  But the Obj-C way is a lot more descriptive.
  • That darn 'NS': Was it really necessary to append every single library object with 'NS': NSString, NSArray, NSMutableString, etc...; couldn't have been just as easy to use String, Array, MutableString?
Ruby
Like:
  • Natural Language: As I get more used to the Ruby way, my assumptions end up being correct more often than not.
  • Syntax: glyphs and ceremony is kept to an absolute minimum.
  • Brevity: Accomplishing tasks in Ruby requires 1/2 or even 1/4 of the lines of code that are required with Java just to do simple tasks.
Dislike:
  • IDE: I've become spoiled with content assistance and my IDE of choice, TextMate, is very powerful but it doesn't have content assist so I have to actually memorize the library or have the API handy at all times.
  • Dependency management: I hate wrestling with dependency issues in Java but Ruby takes it to a whole new level with require, require_relative and include.
  • File sprawl: I remember my old days of PHP where packaging your project for deployment was like herding cats, files spread out everywhere on the filesystem. More often than not it was my fault for allowing my directory structures to get so scattered but with Java I'm forced to at least have a reasonable directly layout. With Ruby the onus is back on me.
As I get more familiar with these languages and start developing real applications, not just test and examples, I will be able to form a more informed decision.