You are a stupid programmer, you can't have that

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Aug 10 17:05:31 UTC 2021


On Tue, Aug 10, 2021 at 06:23:39AM +0000, Paulo Pinto via Digitalmars-d wrote:
> On Monday, 9 August 2021 at 23:09:30 UTC, H. S. Teoh wrote:
> > ...
> > No offense taken.  I just find the OO extremism of Java to be
> > laughable, that's all.  Why not just admit that OO isn't the be-all
> > and end-all of programming, and call free global functions what they
> > are.
> > 
> > This is why D's multi-paradigm approach makes so much more sense:
> > sometimes one paradigm doesn't fit the problem, why not acknowledge
> > it and allow a different paradigm to step in.  Not every problem is
> > a nail to which the OO hammer must be brought to bear.
[...]
> I love how people love to hate Java, yet have no words of hate against
> OOP in Smalltalk, SELF, Eiffel, Sather, C#, VB, Python (check methods
> from typeof(func)), Dart.

Whoa, slow down right there.  My rant was against shoehorning every
programming problem into a single paradigm, not against OOP itself.  OOP
certainly has its uses -- that's why D has it too!  The problem comes
when OOP zealots try to shove it down everyone's throats even when the
problem at hand clearly does not fit the glove.

I picked Java because that's the language I am most familiar with that
exhibits this syndrome.  I don't know enough (well, any) Smalltalk or
Eiffel to be able to criticize them coherently, and I have not written a
single line of C#, so I don't have much to go on there.  Python I have
written in very small scales, and it does have some nice things about
it.  But I've not written enough non-trivial Python code to be able to
criticize it effectively.

But the point is that single-paradigm languages ultimately suffer from
the shoehorn program: trying to shoehorn every programming problem into
a single mold, even when it doesn't really fit.  Certain algorithms are
simply better expressed as an imperative loop that mutate variables;
it's a royal pain in the neck to try to write the equivalent of such
code in Lisp, for example.  It's certainly *possible*, thanks to Turing
completeness, but exhibits all the symptoms of dressing up a duck as an
aquatic chicken with webbed feet: it's awkward, requires excessive
paraphrases, and more complex than it really needs to be.  The same can
be said about writing range-based code in a language like C: you can do
it, but it's awkward, error-prone, and just plain ugly.

In a multi-paradigm language, you can choose the best paradigm to
express the algorithm at hand, in the most convenient, clear way,
without having to resort to the shoe-horn. It's faster to write, easier
to read, and more maintainable in the long run. You can treat a duck as
a duck instead of an aquatic chicken with webbed feet. It's so
refreshing not to have to paraphrase yourself all the time.


> How has D's multiparadigm helped to have a better marketshare than
> some of those extremist OOP languages?

I don't understand where marketshare enters the equation. We're talking
about how well a language fits a problem domain, not about the fashion
contest that is today's programming language "market".

(And incidentally, which language is most popular has very little to do
with its technical merit, it is primarily determined by how much
marketing capital it has and how well the marketing department sells it.
With a large-enough marketing budget and a spark of marketing genius,
you can sell *anything* to anyone.  I have no interest in what's popular
and what's not; what I look for is technical excellence, which is the
true value.)


T

-- 
Дерево держится корнями, а человек - друзьями.


More information about the Digitalmars-d mailing list