4 Replies - 3317 Views - Last Post: 19 December 2011 - 05:01 PM Rate Topic: -----

#1 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 877
  • View blog
  • Posts: 3,122
  • Joined: 12-May 09

What makes Ruby different?

Post icon  Posted 26 January 2011 - 11:50 AM

As a language, Ruby follows several interesting paradigms that make it very unique. There is no one language that Ruby attempts to substitute. I'd like to compile a list of comparisons between Ruby and other languages.

If you have any thoughts on Ruby's strengths and weaknesses or similarities and differences with these languages, I'll edit them into the OP.

General Features
Ruby makes metaprogramming easy and interesting.
Every class is open (you can edit how strings or integers work at any time).
Everything is an object.
Ruby uses dynamic, strong typing.
Ruby is an interpreted language.

Python
Python has as its paradigm that there should be "One Obvious Way" to do things. In Ruby, there are many obvious and not so obvious ways of accomplishing what you want done. It's a very versatile language and lets you do things however you want without much hassle.

Ruby is entirely object-oriented. You'll find that Python is OO as well, but also mixes in several procedural habits.

Python does most things explicitly, Ruby has several implicit features inherited from Perl and Lisp.

Languages or categories to consider:
Python
Perl
Java
C/C++
Smalltalk
Lisps

Is This A Good Question/Topic? 4
  • +

Replies To: What makes Ruby different?

#2 noahgibbs  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 17
  • Joined: 18-December 11

Re: What makes Ruby different?

Posted 18 December 2011 - 10:25 PM

Java: Java is statically typed, so it requires more work to write but gives *much* faster runtime performance. Java also disallows a lot of the modification and introspection Ruby allows - it's harder to get a list of methods on an object, say, or call a method when you have its name as a string, or add a new class at runtime. This also makes Java faster than Ruby.

But philosophically, the biggest difference is that Java makes it hard to mess with other people's stuff - they can declare things final, can declare private (rather than protected), and otherwise keep you from messing with the innards of their classes. Ruby gives you nearly unlimited flexibility in messing up other people's stuff :-) This allows Ruby to be a much more powerful tool for really amazing programmers... And it makes it very, very hard to use if your team isn't excellent, because one bad coder can screw *everybody* up.
Was This Post Helpful? 1
  • +
  • -

#3 DimitriV  Icon User is online

  • They don't think it be like it is, but it do
  • member icon

Reputation: 563
  • View blog
  • Posts: 2,690
  • Joined: 24-July 11

Re: What makes Ruby different?

Posted 18 December 2011 - 10:28 PM

In a thread earlier today an OP mentioned that Java made his head spin. It's very picky about how you type commands and stuff like that. Still, many see it as the language of choice.
Was This Post Helpful? 0
  • +
  • -

#4 noahgibbs  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 17
  • Joined: 18-December 11

Re: What makes Ruby different?

Posted 19 December 2011 - 10:36 AM

View PostjimmyBo, on 18 December 2011 - 10:28 PM, said:

In a thread earlier today an OP mentioned that Java made his head spin. It's very picky about how you type commands and stuff like that. Still, many see it as the language of choice.


Yeah. Part of that is static typing - you have to know exactly what Java is expecting, and tell it. You'll see a lot of that in C++ as well. C doesn't make you type it... It just breaks your whole process completely if you get it wrong :-)
Was This Post Helpful? 0
  • +
  • -

#5 noahgibbs  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 17
  • Joined: 18-December 11

Re: What makes Ruby different?

Posted 19 December 2011 - 05:01 PM

C: Ruby is different from C in that C is basically a portable assembly language. C is meant to make it as clear as possible what your code compiles down to in bare machine code. It allows direct bit access, manual structure alignment and data layout, direct access to most of the lowest-level control constructs like loop and goto... C is meant to give you basically no surprises in how it compiles down to the bare metal. It's awesome for device drivers, kernels, socket-level network protocols and other fiddly tasks that require very direct access to the bits, and ridiculous blazing speed. It also has manual memory management, deals poorly with ambiguity, is very hard to do security for, and takes forever to write large, comprehensive tasks. C should be a language for writing speed-intensive tools that do the inner-loop 5% of your code that takes 95% of the time. C is a great language for databases and other storage servers for this reason.

Ruby allows some bit-level access and *can* write a socket-level protocol, but you wouldn't use it for a driver or a kernel. It's too slow, its bit-by-bit memory layout is too unpredictable and you certainly can't tell how (or even when!) it compiles to bare machine instructions.

In return, Ruby is *far* faster to write than C with better security (no pointer bugs, it has taint mode) and great callout to other languages and tools. But given the performance, you should be planning to have Ruby call out to higher-performance tools and servers for anything performance critical.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1