You are a stupid programmer, you can't have that
Dukc
ajieskola at gmail.com
Tue Aug 10 11:16:15 UTC 2021
On Tuesday, 10 August 2021 at 06:23:39 UTC, Paulo Pinto wrote:
>
> 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.
In this case, Java was already raised as an example, so it was
easiest to talk about it when criticizing the dogmatism about OO.
Of those other languages, I really only know C#. Yes, the
criticism about lack of free functions does apply to C# just like
it applies to Java. In general I don't consider C# quite as
restrictive as Java, because at least it has user-defined value
types and operator overloading.
I'll grant that this is probably not because Java would trust the
programmer less than C#, but because of language simplicity. I
quess I dislike scarce-featured languages in general - I'm not
very tempted by Go either, not that I have tried. C is kind of
fun to play with because of the low-level tricks, but I don't
consider it a good general-purpose language either.
>
> How has D's multiparadigm helped to have a better marketshare
> than some of those extremist OOP languages?
I don't think I have to explain the bandwagon fallacy for you, so
I'm assuming you mean "How has D's multiparadigm helped to have a
better marketshare than if it had an extremist attitude towards
OOP?".
Consider a simple bug report
(https://issues.dlang.org/show_bug.cgi?id=22151) example I
submitted recently.
```d
void main()
{ *&main = *&main;
}
```
if D had a similar OO attitude as Java and C#, the example would
have to be something like
```d
struct S
{ static freeFun()
{ *&freeFun = *&freeFun;
}
}
```
Note that the comparison is fair - I'm still taking advantage of
D's expressive power in the second example, by dropping the
unnecessary `void` and visibility attribute. If every single
small code snippet (or utility module) has to contain an
enclosing `struct`, `class` or `union`, that totals to a HUGE
readability price.
Yes, allowing free functions does complicate modules, and
includes the need for function hijack protection. But that pays
back in a big way when it comes to readability.
Also remember that you cannot have UFCS without free functions,
except if you have something like C# `this` parameters for
`static` member functions. And frankly, that solution has NO
upsides whatsoever compared to D. The programmer still needs to
define the needless `class`, and language designers need to think
about the module system and hijack protection just as hard as
with free functions.
More information about the Digitalmars-d
mailing list