Sujet : Re: Other programming languages (Was: Command line globber/tokenizer library for C?)
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 13. Sep 2024, 05:18:36
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240912204121.482@kylheku.com>
References : 1 2 3 4 5 6 7 8 9
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-09-13, Janis Papanagnou <janis_papanagnou+
ng@hotmail.com> wrote:
On 13.09.2024 00:32, Lawrence D'Oliveiro wrote:
On Thu, 12 Sep 2024 17:40:17 +0200, Janis Papanagnou wrote:
A lot of early C++ programs I've seen were just, umm, "enhanced" "C"
programs.
Given that C++ makes “virtual” optional instead of standard behaviour, I’d
say that C++ is in fact designed to be used that way.
>
There's different semantics with and without a 'virtual' specification.
>
Even if you want polymorphism (and have to use 'virtual') there's no
need to define it as _default_ (and "disable" it where unnecessary).
Thd development of C++ follows, or at least used to, a "don't pay for
what you don't use" principle: programs not using certain mechanisms
that have an implementation cost should not ideally bear the cost of
implementing them.
When a class doesn't use virtual functions, that class doesn't need the
"vtable" implementation mechanism. And even if functions are called
through pointers or references to the object, the dispatch is static.
That would not be the case with virtuals, because a class must be
suspected of being a base class.
This "don't pay for what you don't use" principle doesn't mean that
the language is designed to be used with a preference toward
the cheap choices. It's just pragmatics. Programs do not all use all
available features, so why turn them on? A program which needs no
special features that have an implementation cost would then have to
verbiage to opt-out of all of them. Moreover, old programs would have to
be maintained to add more verbiage to opt out of newer hidden expenses
that have been made default.
We can imagine the "ls" program was designed such that a large number
of options were enabled at the same time, such that users
have to turn off what they don't need. It does not follow that just
because things are not that way (options sanely optional)
that doesn't imply that ls is designed to be used with no options.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca