Official Ruby logoRuby is so brittle that I would never use it.
-- Stéphan

From a Java developer perspective, I thought Ruby was so brittle that I would never use it. How could you survive with a bunch of strings (except on on the beach) ? How could you survive without a compiler ? But in fact this brittleness makes you a better developer, makes better code.

First, the compiler isn't there so you feel obliged to write tests. You can try without tests but you will not survive a week. Writing tests is the good and only way to go. As you often have less noise in Ruby than in Java, it's quite easy to get a 70-80% coverage with the nominal case. In Java, you have this false sense of security/confidence : "If it compiles, it works”, so sometimes you omit a test.

Note for the Java developer with the fear of losing the content assist of their IDE: Sublime Text content assist and open files (CTRL-P) are really - really - good.

Second, the duck typing is just great. Do you remember how complex it is to create mocks in Java? Need a double/stub for test, no problem: just instantiate an OpenStruct or Hashie with the appropriate accessors and you are done. No need to "create an interface", "create a dynamic proxy", ... Remove all this plumbing noise, just code your test.

Third, this fragility and the fact that Ruby has testing built-in, makes writing tests a pleasure, with a framework that rocksRSpec or MiniTest-Spec. The "let", "describe", "it","should","must" wording is just what you need to understand this test code, 6 month after it has been written. Another aspect from these frameworks is the mental shift to model the test. You are no longer tempted to write long test methods with a lot of assert. Instead each feature/behaviour has is own test with one or two assert.

Last, the tooling is just there in SaaS, self-hosted, or in your workspace : minitest-spec or rspec, simple-cov, ci-reporter, jenkins or travis-ci.

Ruby is so brittle, and I like it.
-- Stéphan

But don't take for granted that your is code is 100% clean, just because you picked Ruby. I only wrote about tests, the usual code germs are still there, hiding in the corner: complexity, duplication, undocumented methods, dead code and commented code, bad style...

Have you tried PullReview ?

Enhanced by Zemanta