The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

ROR Object Oriented?

Is Ruby on Rails, or Ruby I suppose, an object oriented language/framework? Can you develop the same type of three tiered applications like you can do in c#/ASP.NET?
SCADA Guy
Saturday, January 27, 2007
 
 
Yes they are. The short answer is you can developed three tired applications. The two tiers come free for you in Rails. The third tier may need a library called "dRB" (Distributed Ruby). You can set a server in dRB somewhere, with business layer or caching of data, and call it in ever request. This is quite uncommon, though. For most applications, a two tired model suffices. It follows the "client/server" model of accessing the database almost directly, while the web browser works as a thin client for instance. Not different than 90% of the other languages/tools provide.

The main difference, is that Ruby is more productive and comes with a set of libraries, like the dRB. Being easy to use, one can create everything needed. The difference between Ruby and Java, is that with Java things are much harder, and there are several service providers for Java tools, which work to help you if you have the money and the expertise, but I think more often than not, all the options in Java end up making it harder to develop and choose the tecnologies. :-)
Lostacular
Saturday, January 27, 2007
 
 
On the other hand, Ruby is an order of magnitude less efficient at _runtime_ than Java, so you need to weigh up the benefit of easy programming against the potential cost of throwing hardware at an inefficient solution.  There are also halfway houses like Python which provide many of the development benefits without all of the runtime costs.

(Executive summary: Ruby is cool and popular, but don't forget to evaluate other solutions as well to make sure you're choosing the right tool for your job.)
Iago
Sunday, January 28, 2007
 
 
About runtime efficiency, I think Ruby uses much less memory than Java. My own experience has been that Ruby + extensions libraries in C can use 3 times less memory than Java at a minimum. One of these times, I tested my own libraries in JRuby, and it seems that they default it to 256 MBs or something (I'm not really an expert in Java affairs), while my servers in Ruby generally use about 60 MBs of RAM at most I think. All the extra memory one can save in Ruby can go into caching more data/code. :-)

Give me 4 GBs of RAM with Ruby anyway over Java.

My own site is totally powered by Ruby/Mongrel, with Nginx as the current front-end: http://www.ralip.com.br/jp/wiki/

And it's fast enough, as Firebug says that most pages once cached come in under 1 second, which should be compatible with PHP solutions out there. The difference is that I have some connection pooling and other caching tricks which make it "custom" fast. :-)
Lostacular
Sunday, January 28, 2007
 
 
It's not the be-all and end-all, but this benchmark shows that, somewhat surprisingly, Lostacular is right that for some operations Ruby uses less memory than Java.  Also shows that Iago is right that Ruby is for many purposes an order of magnitude (or more!) slower than Java:

http://shootout.alioth.debian.org/debian/benchmark.php?test=all&lang=ruby&lang2=java
Herbert Sitz Send private email
Sunday, January 28, 2007
 
 
Here's the memory data from my commodity server (it only has 256MBs of RAM until now!):

USER      PID %CPU %MEM    VSZ  RSS TTY      STAT START  TIME COMMAND
username      5594  0.0 10.2  35976 24592 ?        Sl  Jan24  0:01 /home/dewd/workspace/web/pilarsoft/...
username      5595  0.1 15.2  48540 36708 ?        Sl  Jan24  9:15 /home/dewd/workspace/web/ralip/star...
username      5597  0.0  0.1  2524  416 ?        Ss  Jan24  0:00 nginx: master process /usr/local/ng...
username      5598  0.0  0.4  2788  1132 ?        S    Jan24  0:01  \_ nginx: worker process     
username      5599  0.0  0.4  2788  1112 ?        S    Jan24  0:01  \_ nginx: worker process

dewd@sp4527:~$ free
            total      used      free    shared    buffers    cached
Mem:        240184    236540      3644          0      58708      23164
-/+ buffers/cache:    154668      85516
Swap:      1542232      19232    1523000


The explanation is that "Nginx" works like Apache for me. It serves the static assets, while distributing the requests to its virtual hosts through proxies. I have two proxy servers, each for a different web site. One of them is very simple and uses less memory (35976), while the other one has more applications and uses more memory (48540).

If one sums them, including Nginx, it should be under anyone's memory budget. :-)

Turning this page, though, I agree that Ruby is not on par with Java and .NET when you want extreme speed, but unlike them, Ruby can be simpler, and when combined with conscious algorithms and technologies (like Nginx), it can be fast enough for most uses, or can serve as a bootstrap for your next MySpace or something. :-)

BTW, this year we should get a speed improvement in Ruby, with the addition of a virtual machine to it. It will have a chance of losing the tag of "slowest language". :-)
Lostacular
Sunday, January 28, 2007
 
 
mvc is not oop. creating objects around what is really procedural (mvc) is not oop. mvc is ok for the inner design of GUI things like buttons, grid/spreadsheets etc. but to apply it application wide is asking for trouble. You see, with mvc, you spread your object/entity between three separate layers for the sake of configurability (which most applications probably don't need). You might find these two articles by Allen Holub interesting:

http://www.javaworld.com/javaworld/jw-07-1999/jw-07-toolbox.html

http://www.javaworld.com/javaworld/jw-09-1999/jw-09-toolbox.html?page=1
wageslave
Monday, February 12, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz