Advantages of Ruby

R

rjack

I am new to Ruby. I have done most of my development in statically
typed languages (Java, C++, C#, etc.).

I understand that there are advantages and disadvantages to dynamic
versus static typing. What idioms/patterns can you do in Ruby that you
just can't do in statically typed languages? Are there problems you can
solve in Ruby that you can't solve or would be awkward to solve in
statically typed languages?

Is there a website or document that describes this somewhere?

[Note: I'm not interested in starting any language wars here. I really
want to understand the expressive advantages of Ruby.]

Thanks!
 
A

Austin Ziegler

I am new to Ruby. I have done most of my development in statically
typed languages (Java, C++, C#, etc.).

I understand that there are advantages and disadvantages to dynamic
versus static typing. What idioms/patterns can you do in Ruby that you
just can't do in statically typed languages? Are there problems you can
solve in Ruby that you can't solve or would be awkward to solve in
statically typed languages?

Is there a website or document that describes this somewhere?

[Note: I'm not interested in starting any language wars here. I really
want to understand the expressive advantages of Ruby.]

PDF::Writer is 6,000 lines of code. Readable code. I suspect that
other implementations are much larger.

-austin
 
R

Robert Klemme

I am new to Ruby. I have done most of my development in statically
typed languages (Java, C++, C#, etc.).

I understand that there are advantages and disadvantages to dynamic
versus static typing. What idioms/patterns can you do in Ruby that you
just can't do in statically typed languages?

One of the major advantages is that you get polymorphism without the need
to make types compatible (via a common interface like in Java for
example). In Ruby you can easily do something like this:

f = lambda {|x| puts "calc...";x ** x}
if do_it_fast?
calc = Hash.new do |h,k|
h[k] = f[k]
end
else
calc = f
end

puts calc[10]
puts calc[10]

i.e. you can use a Hash and a lambda interchangably. Basically, you gain
a lot of flexibility.
Are there problems you
can solve in Ruby that you can't solve or would be awkward to solve in
statically typed languages?

I don't think this is about issues not being solvable but about needing
more or less lines of code (which directly impacts productivity and
likeliness of bugs).

Kind regards

robert
 
E

Edward Faulkner

--EVF5PPMfhYS0aIcm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I understand that there are advantages and disadvantages to dynamic
versus static typing.=20

I recently rewrote a C++ library in Ruby. The Ruby version is smaller
by a factor of 11, despite having all the same functionality.

And the Ruby version is well-covered with unit tests, something I
never had in the C++ version. If you count the unit test code as part
of the library, it's still 8x smaller.

That's approximately 8x fewer bugs, 8x faster development, and 8x
lower maintenance cost. Smaller code is better code. Choosing a more
expressive language is the best way to make your code smaller.

Computer languages fall on a continuum that moves from low-level,
hardware-oriented code up toward more abstract, human-oriented code.
A rough ordering, IMHO, goes like this:

assembly
C
C++
Java
Python
Perl,Ruby
Haskell
Lisp

I choose Ruby over Java for the same reason you choose Java over C.
In general it's a mistake not to use the most powerful language you
realistically have available.

Why don't more people use the really high level languages? Mostly
because languages are not only tools, but also habits of thought. And
habits of thought evolve very slowly. =20

regards,
Ed

--EVF5PPMfhYS0aIcm
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDVnFpnhUz11p9MSARAs4CAJ9xYmbvqYvBv+2aqbaTfxgTnzjmZACfYRSQ
h5GBP2wk62pTsZAhKhRI1MA=
=p9pV
-----END PGP SIGNATURE-----

--EVF5PPMfhYS0aIcm--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,537
Latest member
BellCorone

Latest Threads

Top