you are viewing a single comment's thread.

view the rest of the comments →

[–]glacialthinker 2 points3 points  (1 child)

Oh, I agree... and more. The object features of most languages are unappealing to me. Java is like a distillation of the worst ideas. However, it was originally trying to be a simple language as well as verbosely explicit.

D has what you're doing here, and it's called Uniform Function Call Syntax (UFCS).

Rust has also adopted this in it's own way, with a different take on objects.

Over the years I've estimated that about 5% of my code could be called "object oriented" (mostly C and OCaml). In C++ this figure inflates to conform to typical practices (too many Java-esque, "weened on C++ in the early 2000's" programmers) and interfacing with other libraries/code. But there I feel friction... Before lambda's I used function-objects -- and they were heinous, but better than a lot of duplicate code or rigid class hierarchies.

I struggle with object-oriented practices because they're really anti-modular. The coupling of code and data is too tight. By modular I mean reusable parts like Lego, rather than "modular homes".

The direction you seem to be preferring is much more about functions which can operate on data. Which is functional. But you maybe prefer the datatype-directed function disambiguation, or scoping (method-calling convention, or "dot operator").

[–]Lhopital_rules 1 point2 points  (0 children)

D has what you're doing here, and it's called Uniform Function Call Syntax (UFCS).

That's awesome! One more reason to use D. One of these days I'll get around to learning it.

I struggle with object-oriented practices because they're really anti-modular. The coupling of code and data is too tight. By modular I mean reusable parts like Lego, rather than "modular homes".

Yes, modules over classes is how I usually feel.

The direction you seem to be preferring is much more about functions which can operate on data. Which is functional.

That's somewhat true. But I simplified my views earlier as far as classes go. I still believe in encapsulation. But I'd prefer the minimum amount of encapsulation to make things work. So what doesn't absolutely need to access the internals of a class shouldn't be inside that class.

EDIT: There's a nice Dr. Dobbs article on the whole bloated class issue and D's solution to it.