Hello,

I'm new to Rust, and I have some questions concerning some aspects of the
language. From what I understand until now, rust has no dynamic  linkage
for methods as it would be the case in any standard OOP language. This is
surely an intentionaly different philosophy from the current trend among
other recent programming languages. But why not after all. I like the idea.
So I find myself skeptical when I read the chapters of the documentation
about OOP-like concepts like classes or interfaces.

The essence of the "class" concept lies in the possibility to gather a data
structure (a type) and the related processes that can act on the
corresponding instances (methods) in a single bundle. But, tell me if you
disagree, the only interesting purpose of such an operation is the ability
to use inheritance. If no concept of inheritance exists, I hardly see what
is the need of making functions "pets" for data. All we obtain are
classical design issues like "is my 'f(a,b)' function a 'a.f(b)' method or
a 'b.f(a)' method ?" (and I don't think the rust "resource"
concept requires classes, as destructors or destructor-like functions are
not methods). I'm afraid that the answer is merely to offer a supposedly
"attractive" syntax for OOP users. And I think this would be a weak argument

The concept of interface/implementation in rust is surely different than
the usual one, but again to me it looks like it has some limitations due to
the same reason than above: it tries to look OOP. I could have imagined a
very similar interface concept but that does not focus on a *single *type:

iface shape_drawing<Sf, Sh> {
    fn draw(Sf, Sh);
    fn bounding_box(Sh) -> bounding_box;
}

fn draw_twice<Sf, Sh with shape_drawing<Sf, Sh>>(surface: Sf, shape: Sh) {
    draw(surface, shape);
    draw(surface, shape);
}

Of course this example is a simple one. And any consistent system like this
(if it does exist but I'm pretty sure it does) would have been more complex
than the current one. But also more general and then more powerful.

Let me clear about something: I don't expect anybody to change the current
design. I'm nobody and I know it's always easier to criticize than to do
things. I'm just expressing the feeling that while Rust tried to take a
different direction from all the other new
JVM-compliant-OOP-languages-with-functional-features (which I really really
value very much) it seems it has not got rid of some conceptual patterns
that are not, IMHO, necessary anymore. And I wish people could give their
opinion about this.

Thank you

-- 
Eddy Cizeron
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to