Because of learning Java OOP before, I have some comparisons between Ruby and the language I've known:
Similarities:
- Use Garbage Collection to clean all unused variables
- Focus on Object
- Use MVC
- Use OOP
Differences:
- Ruby don’t need to compile, it runs directly!
- To declare a block of codes, now we use do…end to replace ‘{ }’. With “one-line or short block code”, we still use ‘{ }’ to perform block.
- Use ‘require’ to replace ‘import’
- All variables is private
- Everything is object
- No need to converse, no need to have type declaration.
- Method 'Constructor' is now method 'initialize'
- 'Null' is now 'Nil'
- The usage of '==' and 'equal()' in Java are now reverse in Ruby
My comments:
- Block is ‘supercool!’ in Ruby (special about yield, lambda, proc)
- Codes can be performed in super-short way - which make me confuse a lot.
- To understand Ruby, I think we must think like a ‘human’ (LOL)