New presentation on Ruby

As for any presentation, there are a lot of things that are said and
that
are not written in the slides.

2007/4/2, Ilan B. [email protected]:

Slide 12) Doesn’t illustrate duck typing at all as I can write the exact
same thing in Java. You could have illustrated the point more
accurately by assigning the types to a temporary and then invoking the
method
class Duck; def quack; “quack”; end; end;
class Bird; def quack; “chirp”; end; end;
[Duck.new, Bird.new].each {|duck| duck.quack}

As stated in the slide, “The type of an object is defined by what that
object can do (and not by its class/interface).”

In the code snippet,

  • I do not have to declare the type of a variable
    a_duck = Duck.new
  • I can request an object to walk and it will work if the object has the
    corresponding method
    a_duck.walk
    As Duck defines a walk method, the above request will succeed and there
    is
    no need for having a type defining the walk capability.
    This is quite relevant regarding duck typing.

Slide 13) Doesn’t add anything that wasn’t already mentioned in slide 12

From the Ruby side, there is nothing new.
The point here is to indicate that there is no need to have an interface
concept like in Java for having different implementations.

Slide 14) You are implying that Java’s containers do not support

heterogeneous types which it does and since JDK 1.5 and the insertion of
generics, your point about downcasting is also moot.

Slide 15) All wrong, please see comments for slide 14

As stated in slide 15 :

  • I just said that Java untyped collections or generic collections for
    type
    Object DO support heterogeneous types.
    But the drawback is that you NEED to downcast a retrieved element.
  • Conversely, if you use a generic collection for a type X (e.g.
    TalkingAnimal) different than Object, you can put only objects of type
    X.
    You cannot put an object that is not of type X (e.g Rabbit2)
    You avoid most downcasts for retrieved elements. Thus you can retrieve a
    TalkingAnimal and call talk.
    But if you put an object of type Y that extends the capability of X
    (e.gDuck2) and you want to call a method of Y (
    e.g. walk), then you need to downcast to Y.

Tell me what is wrong about that ?

Slide 16) Your comments also apply to static languages, the need for

testing is equal to both types of languages. There has been no
quantitive study on the reduction of bugs due to static language’s
compile type checks (and has been discussed to death on this list). I
believe you are misleading your intended audience here

Exactly. I just want to mean that the important thing here is testing
and
not type checking whether static or dynamic.

Slide 17) What does talking about Erlang have anything remotely to do

with Ruby especially in the context of which it’s being posed:
dynasism(spelling). So what if I can build a fault tolerant system in
Erlang, can I do it in Ruby??? Erlang and Ruby couldn’t be more
different in their approach and implementation. The only thing they
share is “some” aspects from functional language sets. Comparing the 2
is like comparing apples and farmers

I just want to mean here that they are both dynamic languages but good
ones.

Slide 19) I don’t have to make a custom class to convert a type or
modify some behaviour, I can simply open up the class and mess with it
(as you yourself mentione later in the slide show). Secondly, it
“doesn’t have to make sense” and I can do it regardless of my level of
sanity as I do most things.

You’re right. “Custom class” is too restrictive.

In my example, I use the to_str coercion method. This is an easy
illustration of type conversion to a String.
But my Complex class cannot be used like a String in all cases.
“if it really makes sense” is just a caution. to_str is definitively
different than to_s.

Slide 22) If “top level functions” are “private” methods of class

Object, there would be no way to call them without a receiver which is
simply not the case

They are private methods of Object.

Slide 23) Although I would intend to agree with you here, James B.

certainly won’t. This is an argument that has gone back to the 70’s and
both sides are in war escalation mode right now.
Anyways, if you are going to mention buzzwords, you should mention
polymorphism below encapsulation and mention inheritance at the bottom
as it’s the view of Peter Coad and many others that inheritance violates
efforts at encapsulation and therefore usually aggregation is the better
choice.

These are only two of the main features of OO that are particularly well
captured in Ruby.

Slide 24) Point about attributes only allowed to be defined within their

class definition is wrong. In ruby I can define one almost anywhere
with Object::instance_variable_set or Module::module_eval.

The normal way is encapsulation. But you can break encapsulation as
stated
in slide 37.

Slide 26) Who are you to say what “private” means. Each class has their

own definition and either could be viewed as the truth.

In C++ and Java, an instance of a given class can access the private
members
of another instance of the same class.
In the real life, this is not the case. We’re both Human or instances of
class Human, but I don’t want you to access my private data.

Related with slide 23, Ruby encapsulation reflects better the real life.

Slide 27) How is C++ multiple inheritance complex? It may be complex

for a compiler but I am not a compiler… :slight_smile: If you are referring to
diamond ambiguity, then I would agree with you but you don’t explain
yourself here. Stating that java’s single inheritance is “annoying”
won’t win you any friends but will invite flames your way. Is there any
way you could state it differently?

The diamond ambiguity is one point. The other point is virtual
inheritance
when you want to have only one instance of a base class that is
inherited
multiple times.
Regarding Java, it is just a fact.

Slide 28) Your statement under benefits makes absolutely no sense.

I don’t know how to say it differently.

Slide 32) Again you bring up Erlang and concurrency but Ruby is not

Erlang and can obviously have side effects from method invocation. In
fact, if it didn’t, we couldn’t change the state of any object! Are you
trying to sell Ruby or Erlang here? In Erlang, I can’t change the
variable once it’s instantiated… ← see that doesn’t have anything to
do with anything either!

Slide 31 and 32 are principles of Functional Programming as stated in
the
title.
In slide 32, I just give examples of “functional style” code in Ruby.

I never say that Ruby is a pure Functional Programming language. See
slide
33.

Slide 34) Subjective analysis again. Anonymous Java classes are not

very difficult at all and there are indeed issues with closures that are
being addressed for ruby 2.0

Anonymous Java classes are not difficult but you have to write a lot of
code.
Ruby Blocks are thus easier to write. This is an objective fact.

Slide 47) Will anger many readers as it’s subjective again. Please play
nice!

Unlike defining a function, defining a method in Python requires self as
the
first parameter.
There is a lack of uniformity of definition between a function and a
method.
What is subjective ?

If you find that I made errors, please correct me.
But I always try to be fair.

Slide 53) Subjective to the point of insanity…

What I want to mean here are :

  • Java has introduced a lot of features simplifying the work of
    programmer
    (garbage collector to simplify memory allocation…)
  • Ruby adds another level of simplification (dynamic typing,
    block/closure
    …)
    This is the reason why Groovy has been created.

I’ve programmed both in Java and C++ and I’m firmly convinced that we
have
to integrate technologies.
See the title of this slide.

I like the style and presentation but some of your comments have to be

corrected and you should make an effort not to irritate python, php,
java, and c++ developers…

Great. I hope that my answers will make you like it more :slight_smile:

let us know how it was received…

Very well.
This has already been presented. There were Java, Python and PHP
programmers.
What the audience liked was the “pragmatic approach” constituted by the
comparison of features with things they already know in Java, Python and
PHP.

Again, there are a lot of things I said and that are not written in the
slides.
This is why I will develop these slides with some future posts in my
blog.

Chauk-Mean.
http://selfreflexion.free.fr/

Chauk-Mean P wrote:

As stated in slide 15 :

  • I just said that Java untyped collections or generic collections for
    type
    Object DO support heterogeneous types.
    But the drawback is that you NEED to downcast a retrieved element.
  • Conversely, if you use a generic collection for a type X (e.g.
    TalkingAnimal) different than Object, you can put only objects of type
    X.
    You cannot put an object that is not of type X (e.g Rabbit2)
    You avoid most downcasts for retrieved elements. Thus you can retrieve a
    TalkingAnimal and call talk.
    But if you put an object of type Y that extends the capability of X
    (e.gDuck2) and you want to call a method of Y (
    e.g. walk), then you need to downcast to Y.

Tell me what is wrong about that ?

Chuck, please update your java from 1.4 to 1.5JDK (5.0) and check out
generics, there is no longer a NEED(why the upercase?) to downcast from
containers as it’s done for you. It is a far cry from c++ templates
that are done at compile time but it still alleviates the need for
downcasting.

class SomeThing
{
}

java.util.Vector noNeedForDownCastingVector = new
java.util.Vector;

for your viewing pleasure: Java 2 Platform SE 5.0

I also fully realize that I didn’t hear the talk that went with the
slides but you asked us for feedback on the slides knowing that we
didn’t hear the presentation. Be carefull what you wish for especially
on this list…

As for your example on duck typing, I can illustrate the same thing in
your slides by doing an exact port in Java which is known not to support
duck typing (message passing)

class Duck
{ public String quack() {return “quack”;} }

class Bird
{ public String quack() {return “chirp”;}}

d = new Duck(); d.quack();
b = new Bird(); b.quack(); // does this mean java supports duck typing
too?? It does if we go by your slide

or C++
struct Duck { void quack() {cout << “quack”;}}
struct Bird { void quack() {cout << “chirp”;}}
Duck().quack(); Bird().quack(); // Wow… guess this means c++ supports
duck typing too…

i.e. My point was in order to illustrate the construct, you must use a
temporary variable!

As for private methods in class Object, you are correct sir and I stand
corrected…

As for Erlang, it has simply nothing at all remotely to do with Ruby.
It’s a seperate beast entirely and it appeared from your slide show that
you were utilizing it to promote Ruby based on a small subset of
functional programming. It’s kind of like saying that the language Ruby
is spelled exactly like the gem and we all know how shiny the gem is so
Ruby must be shiny by extension. Actually come to think of it, I think
Ruby has more in common with a gem than it has with Erlang.

I experimented with Erlang from the urging of my former boss and
suffered from severe headaches, brushes with suicide, weight gain and
halitosis… I am hoping the new pragmatic book will enlighten me but
one thing I can atest to is that it’s far removed from Ruby and the only
time thy should be used in a sentence together is the following:
"Ruby starts with an ‘R’ and Erlang starts with an ‘E’ "

ilan

2007/4/3, David A. Black [email protected]:

both.

David

I see what you mean. I will adapt the example with your suggestion in a
next
release.

Thanks for your feedback.

Chauk-Mean.

http://selfreflexion.free.fr/

2007/4/3, Ilan B. [email protected]:

You avoid most downcasts for retrieved elements. Thus you can retrieve a
TalkingAnimal and call talk.
But if you put an object of type Y that extends the capability of X
(e.gDuck2) and you want to call a method of Y (
e.g. walk), then you need to downcast to Y.

Chuck, please update your java from 1.4 to 1.5JDK (5.0) and check out
generics, there is no longer a NEED(why the upercase?) to downcast from
containers as it’s done for you.

Ilan,

First, my first name is Chauk-Mean not Chuck :slight_smile:

Regarding Java 1.5, I think that I’m up to date.
Indeed, the second example from the slide 15 uses generics (please take
a
second look at it) :

Map<String, TalkingAnimal> menagerie = new Map<String, TalkingAnimal>

Yes, a talking animal can talk directly and there is no need to downcast

TalkingAnimal duckObject = menagerie.get(“my duck”);
duckObject.talk

But if you want your object (which happens to be a duck ) to walk, you
have
to downcast it to Duck2

Duck2 duck = (Duck2)duckObject;
duck.walk;

As I said, with generics you avoid most downcasts but there are cases
like
this one which require downcasts.

I also fully realize that I didn’t hear the talk that went with the
slides but you asked us for feedback on the slides knowing that we
didn’t hear the presentation. Be carefull what you wish for especially
on this list…

You’re right. It seems that I have to make an annotated version with
some
additional comments.

As for your example on duck typing, I can illustrate the same thing in
your slides by doing an exact port in Java which is known not to support
duck typing (message passing)

class Duck

{ public String quack() {return “quack”;} }

class Bird
{ public String quack() {return “chirp”;}}

d = new Duck(); d.quack();
b = new Bird(); b.quack(); // does this mean java supports duck typing
too?? It does if we go by your slide

Hey, you have to declare the type in Java.
And of course, it will work if you declare the type like :
Duck d = new Duck();
d.quack();

It’s a detail that is important.

It’s the same for C++.

Chauk-Mean.

Marcin R. wrote:

Hello, i noticed that for every RPC call distributed ruby opens separate
connection, this can create huge bottleneck - especially when using with SSL,
anyone have any idea how to make persistent connections - of course i can
read sources for whole library, but mayby someone already solved this
problem, mayby there’s some “keep-alive” for x secs options.

Dunno about ssl, but you could always open an ssh tunnel with the -S
option, which lets several sessions share on connection.

[email protected] wrote:

Dunno about ssl, but you could always open an ssh tunnel with the -S
option, which lets several sessions share on connection.

i think every call must open a connection - in case of ‘yield’. all drb
objects are servants.

-a

Arg, you’re right. One tunnel wouldn’t be enough.

On Thu, 5 Apr 2007, Joel VanderWerf wrote:

Marcin R. wrote:

Hello, i noticed that for every RPC call distributed ruby opens separate
connection, this can create huge bottleneck - especially when using with
SSL, anyone have any idea how to make persistent connections - of course i
can read sources for whole library, but mayby someone already solved this
problem, mayby there’s some “keep-alive” for x secs options.

Dunno about ssl, but you could always open an ssh tunnel with the -S option,
which lets several sessions share on connection.

i think every call must open a connection - in case of ‘yield’. all drb
objects are servants.

-a

On Wednesday 04 April 2007 23:18, [email protected] wrote:

i think every call must open a connection - in case of ‘yield’. all drb
objects are servants.

-a

you probably didn’t understand me :slight_smile:
RPC calls are made over TCP/IP connections, but there’s no reason why
each RPC
should have one connection - they probably should have some id, and
should be
all sent over one connection - i’ve been to busy to investigate this,
but
since it looks like noone knows anything about it, I’ll check if it’s
possible to make it happen.