Defending Ruby's OOP

L

Lucas Holland

Hi,

I've got someone here saying that Ruby (and other languages) can't be
100% object-oriented because if and unless and so on (keywords) are no
objects.

How can I defend the claim that Ruby is 100% OOP?
 
G

Giles Bowkett

I've got someone here saying that Ruby (and other languages) can't be
100% object-oriented because if and unless and so on (keywords) are no
objects.

How can I defend the claim that Ruby is 100% OOP?

Righteously! Ye must purge yon heretics with whips and scorpions!

(Alternatively, why bother?)

--
Giles Bowkett

I'm running a time management experiment: I'm only checking e-mail
twice per day, at 11am and 5pm. If you need to get in touch quicker
than that, call me on my cell.

Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
 
G

Gary Wright

How can I defend the claim that Ruby is 100% OOP?

Just redefine the meaning of 100%, that should work.
If not, redefine the meaning of OOP.

Really, it seems like a silly argument. Better to
simply understand what Ruby is or isn't and the same
for other languages. I doubt that there is some
mathematically-true total ordering on programming
languages relative to OOPness (or any other criteria
for that matter).

Gary Wright
 
G

Gary Wright

Or better yet, tell him to design a language that has "if" "unless"
etc as
objects and see where that goes. What does having if/unless as
objects even
mean?

In Smalltalk, if-then-else is a message and messages are objects....

If Ruby is 100% OOP, then what is Smalltalk?

Gary Wright
 
G

Giles Bowkett

Tell him to find a more substantial argument. That's the lamest complaint I
think I've ever heard about Ruby or dynamic languages in general.

Or better yet, tell him to design a language that has "if" "unless" etc as
objects and see where that goes. What does having if/unless as objects even
mean?

It's like saying the car is inferior to the horse because you can't
feed the car oats.

Smalltalk is the purest OOP language there is and it doesn't **have**
if or unless at all. You know how you can bypass control structures in
Ruby by using blocks and closures instead? In Smalltalk, that's the
only way to do control structures at all. "If" and "unless" don't even
exist in Smalltalk. "If" and "unless" are not fundamental in the first
place. They're a conscious design feature. It sounds like the person
you're arguing with is a Smalltalk stalwart and/or an argumentative
type making a silly, meaningless point which is only useful for the
sake of arguing.

Seriously, what kind of object would an If object be? What is the
essence of If-ness? I think if anybody could answer that question they
would instantly achieve enlightment and then their head would explode.

--
Giles Bowkett

I'm running a time management experiment: I'm only checking e-mail
twice per day, at 11am and 5pm. If you need to get in touch quicker
than that, call me on my cell.

Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
 
D

Dan Debertin

From: Lucas Holland said:
I've got someone here saying that Ruby (and other languages) can't be
100% object-oriented because if and unless and so on (keywords) are no
objects.

How can I defend the claim that Ruby is 100% OOP?

Well, as others have said, it's a stupid thing to argue about.

But to answer your actual question, your friend is correct. for, case,
do, else, if, etc. are reserved words, not objects. Check your pickaxe
book, page 329.


-Dan Debertin
(e-mail address removed)
 
G

Giles Bowkett

Well, as others have said, it's a stupid thing to argue about.

I think getting into that kind of argument at all is a bad idea.

You're only defending a language's design decisions when engaged in
ideological arguments. That kind of argument is bad for the community,
because it encourages picking sides, and bad for the language itself,
insofar as it influences design decisions. Design decisions are not
about taking a side ideologically. They're about building something
useful.

Don't even bother defending Ruby in any context, except against the
charge that it is not **useful** for some purpose, and then only if it
really **is** useful for that purpose.

--
Giles Bowkett

I'm running a time management experiment: I'm only checking e-mail
twice per day, at 11am and 5pm. If you need to get in touch quicker
than that, call me on my cell.

Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
 
B

Bill Guindon

I'm patiently waiting for the Oatsmobile.

And once you get one, you can declare yourself to be Oatman! I'm not
sure what superpowers that brings, besides being 'regular'.
 
G

Gregory Brown

And once you get one, you can declare yourself to be Oatman! I'm not
sure what superpowers that brings, besides being 'regular'.

well, a car fueled by oats would probably be carbon neutral... Oatman
would indeed be as least as eco-friendly as captain planet!
 
S

Sammy Larbi

the_if = if.new
the_then = then.new
then_end = end.new
the_else = else.new

the_if(1==2) the_then

the_else()
the_end


Yeah... I can't make sense of it either.


Jason Roelofs wrote, On 5/10/2007 2:39 PM:
Tell him to find a more substantial argument. That's the lamest
complaint I
think I've ever heard about Ruby or dynamic languages in general.

Or better yet, tell him to design a language that has "if" "unless"
etc as
objects and see where that goes. What does having if/unless as objects
even
mean?

Jason
 
S

Sammy Larbi

Gary Wright wrote, On 5/10/2007 2:47 PM:
Just redefine the meaning of 100%, that should work.
If not, redefine the meaning of OOP.

Really, it seems like a silly argument. Better to
simply understand what Ruby is or isn't and the same
for other languages. I doubt that there is some
mathematically-true total ordering on programming
languages relative to OOPness (or any other criteria
for that matter).


And more importantly, what value would that bring?
 
C

Clifford Heath

Giles said:
Seriously, what kind of object would an If object be? What is the
essence of If-ness? I think if anybody could answer that question they
would instantly achieve enlightment and then their head would explode.

That, my friends, is exactly how LISP programmers are created.
 
B

Bill Guindon

well, a car fueled by oats would probably be carbon neutral... Oatman
would indeed be as least as eco-friendly as captain planet!

True! You could retire by selling off your carbon credits. Having
thought about it a bit, being regular is one of those rare super
powers that actually improves with age ;)
 
P

Peña, Botp

From: Jason Roelofs [mailto:[email protected]] :
# Or better yet, tell him to design a language that has "if"=20
# "unless" etc as objects and see where that goes. What does having=20
# if/unless as objects even mean?

Maybe they mean a boolean class. I myself would like a boolean class in =
ruby. Sometimes, i feel if-else constructs too restrictive,.. maybe i =
hate grammar rules.. (maybe because i find english weird language??)

anyway, can we chain booleans like this?

(x<2).iftrue{"got it!"}.capitalize.each{|c| puts c}
=3D>G
o
t
=20
i
t
!
 
J

John Joyce

From: Jason Roelofs [mailto:[email protected]] :
# Or better yet, tell him to design a language that has "if"
# "unless" etc as objects and see where that goes. What does having
# if/unless as objects even mean?

Maybe they mean a boolean class. I myself would like a boolean =20
class in ruby. Sometimes, i feel if-else constructs too =20
restrictive,.. maybe i hate grammar rules.. (maybe because i find =20
english weird language??)

anyway, can we chain booleans like this?

(x<2).iftrue{"got it!"}.capitalize.each{|c| puts c}
=3D>G
o
t

i
t
!
Indeed, it is a pointless argument. Even smalltalk is not 100 percent =20=

OOP because the characters you use to type code are not objects. [ is =20=

not an object and neither is ]
Big deal.
'if' could be made an object that responds to a message by returning =20
the equivalent of 'jump' or 'goto' in ASM or not. (which is basically =20=

all if does in any language.)
You could very well make if an object if you wanted to, but there =20
would be little benefit, and only extra overhead for nearly pointless =20=

abstraction.
The whole thing is just debasing an argument to win a debate.
 
G

Gregory Brown

From: Jason Roelofs [mailto:[email protected]] :
# Or better yet, tell him to design a language that has "if"
# "unless" etc as objects and see where that goes. What does having
# if/unless as objects even mean?

Maybe they mean a boolean class. I myself would like a boolean class in r=
uby. Sometimes, i feel if-else constructs too restrictive,.. maybe i hate g=
rammar rules.. (maybe because i find english weird language??)
anyway, can we chain booleans like this?

(x<2).iftrue{"got it!"}.capitalize.each{|c| puts c}

to get each char, you don't do each, you do something like each_byte {
|c| c.chr }

But here's a naive implementation of what you're looking for:

class Null
def self.method_missing(id,*args)
self
end
end

class Object
def iftrue
self ? yield : Null
end
end

x =3D 1
(x<2).iftrue{"got it!"}.capitalize.each_byte {|c| puts c.chr}

x =3D 3
(x<2).iftrue{"got it!"}.capitalize.each_byte {|c| puts c.chr }
 
G

Gregory Brown

But here's a naive implementation of what you're looking for:

Note if you really wanted to use this, you'd need to use some sort of
blank slate for your Null object.
 
E

Enrique Comba Riepenhausen

Hi Lucas,

Hi,

I've got someone here saying that Ruby (and other languages) can't be
100% object-oriented because if and unless and so on (keywords) are no
objects.

How can I defend the claim that Ruby is 100% OOP?

Do you have to?

There are a lot of languages claiming to be pure OO languages, but
are they really? What is a pure OO language at all?

Some say Java is OO, but is it? I don't think so. Java is OO in a
sense but lacks a lot of features that would make is "purely" OO.

A pure OO implementation of a language would have to have the
capacity to model anything in life. That is we would not have only
objects (or classes) but would also need some kind of verb construct
that we would be able to model. Or how do you model a class for let's
say a while statement? This would be a verb that you could model
somehow...

verb While
def condition_met?
#bla bla bla
end
end

The real question here is if it makes sense at all. I think that the
work done so far in OO is much more impressive than this. Instead of
trying to focus on the pureness of a language regarding it's OO-ness
we should focus on how good can I model the Domain Model (i.e. the
problem) at hand and how good does it help me to solve that problem.

Coming from a Java environment I can remember the times when we used
JDBC (back in the late 90's) coding our access to the database,
transactions, two-phase-commits. Then Hibernate appeared down the
road and made life easier. And in Ruby...

Well, if you have ever coded a database access in Java (or C, or any
compiled language y guess) and then see the power of ActiveRecord
(and of Ruby in this case), how it dynamically gives you methods to a
class that did not have them before... That is impressive!

It not only helps you to work faster and having more fun (something i
really appreciate, I remember a few months ago, when I started
working with Ruby I changed a middleware server my company did in
Java for the last one and a half years in one day using Ruby), it
gives you those tools (idiomatic) to model much better the domain at
hand.

And that is something to consider. Does this language help me to get
the job done? Or if you are talking to your boss... Than make a
simple calculus:

1,5 years coding in Java = hundreds of thousands of euros
1 day coding in Ruby = lots of fun

Cheers,

Enrique Comba Riepenhausen
 

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
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top