:: Re: [DNG] GTK (was Will there be a …
Top Pagina
Delete this message
Reply to this message
Auteur: T.J. Duchene
Datum:  
Aan: dng
Onderwerp: Re: [DNG] GTK (was Will there be a MirDevuan "WTF"?)


On 7/24/2015 5:03 AM, Didier Kryn wrote:
>
>     Hey T.J., you seem to contradict yourself when saying "C and C++ 
> are strongly typed" and "Type checking is never C's job." :-)

>
>     Actually, yes, C and C++ are typed, but weakly. They silently do 
> type conversion in pretty much every instruction. One assumes the 
> programmers knows it and takes care...


I stand corrected. You are quite right, it is "weakly" typed. I assume
that everyone could figure out what I meant anyway. It's been a long
time since language theory. I think the error came from spending too
much time reading about languages like C#. Even Einstein made major
errors, so at least I am in good company.

>
>     What are your preventions against OOP for graphics? Is it against 
> OOP in general?

Mostly against OOP in general. It wasn't a bad idea to start with, but
OOP started out with good intentions and blossomed more into a
movement. The question really is has OOP made code easier to maintain
and less complex. Generally speaking, the answer is not really. The
primary reasons for using OOP are encapsulation, polymorphism and
inheritance.

Yes, encapsulation in scope is a good thing, but much of that can be
achieved in other ways without using objects. When you take languages
like C++, while the language itself is standardized, the name mangling
that the compilers introduce is not standardized at all. That makes
prepackaged libraries and sometimes linking questionable unless you are
using the same version and compiler. It is enough of a problem every
version of Linux recommends not updating your installation piecemeal
(eg if I update XFCE, I better recompile everything that is linked to
XFCE - even if everything is backward compatible). Microsoft got around
it somewhat by using their COM specification.

Polymorphism? Yes, I will agree that polymorphism is helpful. That can
be achieved with things like pointers, void arrays, and in the case of
C11, the use of _Generics.

So that leaves inheritance as the last real standing benefit of OOP, and
that is really the one everyone hates. Most OOP languages limit
inheritance to single instance in order to avoid some very bad problems.
Realistically 90% of the time, it is better to not inherit at all,
but simply instantiate what you would have used as a base class as a
variable class inside of your class, and then dispose of it when you are
finished. You have no problems with multiple inheritance, calling base
functions, and overall you are wasting less of the stack and memory.

The major reason I object to OOP is exceptions. They make it impossible
to write code with 100% predictable exit points. When code can exit at
any point above and below your own, that means that things can leak.
"Add a garbage collector," you might say. What happens when the
collector has a flaw and you do not know about it? Leak again.



>      I imagine the reason why Glib was written in C is because binding 
> to other languages is easier with C than C++.

>

I expect so. C is fairly straightforward.
> Have a good day.

Likewise!