From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: String Buffer
Date: Thu, 2 Dec 2021 22:45:32 +0100 [thread overview]
Message-ID: <sobepr$h88$1@gioia.aioe.org> (raw)
In-Reply-To: sobcg4$tc4$1@dont-email.me
On 2021-12-02 22:06, Jeffrey R.Carter wrote:
> On 2021-12-02 21:15, Dmitry A. Kazakov wrote:
>>
>> It is true only to a certain degree. When comparing algorithms it is
>> valid to claim inefficiency without any context if computational
>> complexity sufficiently differs.
>>
>> For example, an O(N) algorithm is unquestionably inefficient comparing
>> to O(log N) one. I leave marginal cases of very small N.
>
> This is false. If you have the O(N) algorithm and it meets your
> requirements, then using it is more efficient than implementing the
> O(log N) algorithm.
You have to show that it meets these requirements. The burden of proof
is on you as you select an objectively inferior algorithm. Selecting a
better algorithm is a safe choice under ill-defined conditions.
> Unbounded_String is needed far less than many people think, but there
> are application domains where it is much easier to achieve correctness
> and clarity with a variable-length string abstraction than without.
> Blanket statements about "efficiency" are dangerous for those working in
> such domains.
It is a good argument because introducing String requires more initial
efforts in Ada than a thoughtless application Unbounded_String.
And note, that in most cases it is really thoughtless as the choice is
made on the basis of how easy it is to declare a string component of a
record type and then rewrite it.
Later on throughout the rest of the program the user of Unbounded_String
will be consistently punished for that poor choice because normal string
operations are very uncomfortable with Unbounded_String. But that
happens later. Right now and here, let us save a couple of code lines.
So the simplest and most persuasive blanket statement is OK to dissuade
people from poor choices.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2021-12-02 21:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-02 18:17 String Buffer Kevin Chadwick
2021-12-02 19:56 ` Jeffrey R.Carter
2021-12-02 20:15 ` Dmitry A. Kazakov
2021-12-02 21:06 ` Jeffrey R.Carter
2021-12-02 21:45 ` Dmitry A. Kazakov [this message]
2021-12-03 0:49 ` Kevin Chadwick
2021-12-03 5:25 ` Randy Brukardt
2021-12-03 8:31 ` ldries46
2021-12-02 20:51 ` Simon Wright
2021-12-03 8:11 ` Vadim Godunko
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox