4 ms·
I'm reminded of the first time I tried out Ruby on Rails. I had done some PHP, Perl, C, and Java programming before that. I had worked on some medium sized pr
by Periodic 15y ago
I'm reminded of the first time I tried out Ruby on Rails. I had done some PHP, Perl, C, and Java programming before that. I had worked on some medium sized projects, but in general anything larger than a few dozen files got so complicated it was hard to keep track of.
Then I saw what a really good OO design was like. I learned what real separation of concerns and encapsulation could do. It was an epiphany that the programming I was doing wasn't nearly as good as I thought it was, despite everyone around me being proud of it.
I quit that job do my best not to look back.
- cpt1138 15y agoWhat about the language you are using enforces real separation of concerns and encapsulation that Java doesn't have? Seems to me that those principals are not a quality of a language per se but of design principles that can be applied to any language (maybe some easier than others).
- sunchild 15y agoPresumably, Periodic was referring to Rails' emphatically opinionated framework, which (under the right circumstances) can shine a light on at least one approach to SoC that may, in turn, lead to a deeper understanding of the underlying principles.
- ssmoot 15y agoThat's weird because a lack of SoC is probably my biggest pet peeve with 99% of the Ruby code available, including the Rails source. Other than that, sure RoR can be a nice introduction to MVC. But Monorail was a much cleaner framework from an OOAD perspective. I won't even append "IMO" to that. :-)
- aagha 15y agoWhat does "I had done some...Java" mean? You used servlets to write a web app? With our without JSPs? When? That elham are sfo many frameworks out there that comparing RoR to (generic) Java seems nonsensical to me. Have you played with Stripes? Simple, efficient, fast, extensible--blows Struts out of the water, and is up and running in under five minutes.
- Periodic 15y agoThat was my exposure, Struts, and poorly designed struts too. I think 90% of the code was in static methods. I deferred to the people with 10 years of seniority over me at the time.
- forensic 15y agoI don't understand that because Java is more object-oriented than Ruby, not less. Most people seem to think that Ruby got popular because it was LESS Object-oriented than C++, Java and .NET.
- theBobMcCormick 15y agoIn what way is Java more object oriented than Ruby? In Ruby, everything is an object. There's nothing like Java's glaringly out of place "primitive data types". Not to mention that late binding is one of the qualities Alan Kay listed as being central the the meaning of the concept "Object Oriented Programming".
- forensic 15y agoIn Ruby you can write in a functional style. Can't do that as easily in Java. Java enforces a more pure OO style.
- chc 15y agoI could be off-base, but your thinking seems to be, essentially, "More buzzwords can be applied to Ruby, while 'OO' is the only one that applies to Java, so Java must be more purely OO." This is not a very accurate view of the two languages. Ruby's support for "functional" programming essentially comes down to its ability to encapsulate code in closure objects and the core libraries' pervasive support for these code-objects, called "blocks." But there's nothing about blocks that's anathema to OO. Ruby's blocks are ripped off wholesale from Smalltalk, one of the pioneering OO languages and the one that coined the term "object-oriented programming." Blocks are objects. You can send messages to them, store them in arrays, etc. Ruby is very similar in general to Smalltalk, much more so than Java. It's also very different from a real functional language like OCaml or Haskell, and trying to write a program as though it were one is an exercise in frustration. Here are some aspects of Ruby that are more strongly OO than Java: • Classes are objects — they have methods and instance variables and can be used anywhere another object would be used. • Due to classes being true objects, class methods can be overridden. In Java, class methods are pretty much just namespaced functions. There isn't even a self/this in Java's static methods. That is totally broken OO — Ruby does it right, Java does it wrong. • Every type in a Ruby program is an object type. In Java, some types are objects and some aren't. For many types in Java, there are both object and primitive variants. I'm not commenting on whether this is good or bad, but having non-object types in your language is not pure OO. I would be hard-pressed to come up with similar counterexamples that show Java to be more in line with OO principles than Ruby.