C is Brittle D is Plastic
H. S. Teoh
hsteoh at qfbox.info
Wed Apr 1 18:55:29 UTC 2026
On Wed, Apr 01, 2026 at 09:11:45AM -0700, Walter Bright via Digitalmars-d wrote:
[...]
> (It's a rite of passage for every C programmer to develop their own,
> unique string package. Gawd knows I've probably coded up a couple
> dozen of them.)
Ugh, recently at a work project (> 2G LOC, majority of it in plain C) I
had to deal with cleaning up string code for compliance with security
standards. Every module has its own way of working with strings; some
have fancy buffers with custom functions for building strings (and each
gratuitously incompatible with the others), others abuse snprintf and
strncat all over the place (hidden O(n^2) costs, anyone?), and yet
others outright strcat and sprintf (yes, the unsafe variants!) to a
buffer whose size is never checked that's passed around as a bare char*.
(It took some digging to discover that everyone uses the same underlying
64k buffer size. Still, extremely scary.)
A lot of boilerplate code exists purely to bridge the impedance
mismatch when passing strings between modules.
In this day and age, not having a standard API for string handling
across the entire language is inexcusable. While flexibility is nice to
have, some things *need* to be standardized, otherwise it becomes
unmanageable with size and leads to needless boilerplate bloat.
T
--
Democracy: The triumph of popularity over principle. -- C.Bond
More information about the Digitalmars-d
mailing list