As I read this account of transitioning from Java EE to Ruby on Rails,”Java Web Apps to Rails, A Developer’s Experience,” I thought the following:
Regarding the lack of a good Ruby/Rails IDE:
When it was time to look at the code, I was a bit disappointed. TextMate looked like a popular choice but it fell short in many ways. I struggled to navigate the code, link the methods across files and follow the code. Grep was my only savior.
I am surprised he did not find RubyMine. JetBrains makes awesome IDEs (IntelliJ IDEA for Java, too). I have to admit at being very impressed that the underlying model of the ruby code within the RubyMine IDE is amazingly capable of giving you the same sort of features that it can for a “compiled,” or more type-centric language like Java.
Next he mentioned about learning the language…
My approach to learning Ruby was to start looking at code and figuring out pieces of syntax that did not make sense. That turned out to be a bad idea. Constructs like “do |x| x+1” threw me off. … I found it very important to understand the motivation behind creating the new language.
There are some good books out there, and other resources…
- Eloquent Ruby
- Of course, the newest version of the venerable Pick Axe book by my friends at Pragmatic Bookshelf.
- Practical Object-Oriented Design in Ruby (aka, POODR — remined me of the Java Design book I worked on with Peter Coad, way back when!)
- Ruby Tapas by Avdi Grimm
- Building a Web App with Corey Haines
- Rails Programming with Mike and Nicole Clark at Pragmatic Studios.
Another comment rang true with me:
I found it very important to understand the motivation behind creating the new language.
More about the motivation behind Ruby… or at least, how I interpret things.
Ruby treats you like an adult. It doesn’t baby you, or hold your hand, or make you type all sorts of (obfuscating, in my opinion) fluff that a compiled language needs. Your code is more compact and obvious and “dense with meaning,” leading to less need for things like method return types and method parameter data types. Or semicolons.
However, I miss parameters list, curly braces, return statements, camel case naming conventions…
Be patient… soon you will grow weary of having to read all that extra stuff when you go back to Java. If you write well-formed classes, and very small, compact, and obvious methods, you don’t need the extra frills. You will run across the concept of “duck typing” which really means that classic C++/Java/C# style interfaces are not needed. If you create a method that expects a passed-in object to respond to a method call (e.g., “torque”), any object of any class will do — as long as it has that method call! And if you pass in an object that does not have that method, Rails will kindly throw an exception.
The concept of ‘open classes’ that allow developers to go in and change a base class sounds scary.
Go back to my opening statement. “Ruby treats you like an adult.” If you are naive, you can blow your code up and break stuff. If you do everything the Ruby way, you’ll be fine — because you will catch it with tests (right?). There are good rules of thumb for how and why and when you should consider adding to an existing class — or worse, monkey-patching. In Ruby you can actually alter the behavior of an existing method of an existing class. Do it poorly, and you will pay the price. And maybe not for a year or two. Mwahahahaha.
Ruby’s metaprogramming is incredibly powerful (even if the syntax takes a bit of getting used to).
Rails is incredibly opinionated about how the MVC code should look. It is basically a model-driven architecture approach. The framework expects the MVC stack to have a model, a view, and a controller for each domain concept. (As a long-time domain modeler, and UML guy, this is a real treat.) You can use the default rails generators (interesting when first starting, or for banging out a quick prototype), or write your own twist on a generator. Instead of focusing on the boring framework bits with repetitive, template-like code for each domain object, you can focus on quickly creating features that people want to use and pay for
Ruby on Rails has a great ecosystem of wonderfully talented folks providing 1000s of gems to do all sorts of useful things. For example:
- Registration/user management (devise)
- PDF parsing,
- Simple rules models,
- Object-relational mappers (MongoMapper and MongoID)
- For my favorite database: MongoDB,
- and so much more.
The ecosystem of supporting tools is incredible. Some of my favorites:
Is it perfect? Of course not. There are other cool things to look at as well… Meteor, Node.js, MEAN, etc. So much to explore, so little time.
Back to my continuous learning!