(I have no numbers, but agree in the general point you make.)
Post by Thiago AdamsPost by BartPost by Bonita MonteroIn lines of code. Imagine you would specialize a container like
unordered_map by hand in C. That would be days of work. In C++
it's one line of code and you get nearly optimal performance.
Or just think about what an emplace_back on a vector of strings
all does; if the capacity isn't sufficient a doubled vector is
allocated (libstdc++, libc++), all objects are moved there and
a new item is emplaced at the end. That's one line of code, but
in C that's a half day's work.
Sure, because every time you start a new C app, you're starting from zero.
Sadly, considering the practical consequences, yes. (See below.)
(And irony isn't helpful, Bart.)
Post by Thiago AdamsPost by BartThere are no existing libraries to use. No online examples to use as
templates. There are no examples of hashtables or growable arrays that
you've implemented over decades of your own work to draw from.
There are, a lot! - And since there's no standard everyone's writing
his/her own, or copies *any* hack from "anyone". - It appears to me
like seen with shareware and freeware tools; you can choose between
plenty of contributions, rarely one well designed and none portable.
Some alleviation of the issue is sometimes achieved by use of some
"quasi-standard" libraries that have been established, but that is
neither guaranteed to be existing (in the first place) nor reliable
when used.[*]) And you can also have "fun" if you assemble different
source code packages where each is coming with it's own version of
(non-standard) container functionality.
Post by Thiago AdamsPost by Bart[...]
Posted C code using a non-standard library would be problematical.
That's probably why C code that use a hash-map, for example, may need
to come with its implementation so it may appear to have a higher line
count.
[...]
I was planing to create something (not as advanced of course) but
something I could just write "create a vector of int" "create map of
strings to int" , "create single linked list" etc.
That's what I meant.
I'd still think it's better to look for an (somewhat) "established"
library that appears to be sophisticatedly written and sufficiently
fulfills your (functional and non-functional) requirements. If we
have the source code available, IME, we often [have to] produce yet
another version branch by changing or adding stuff. Or we want (or
have to) write an adapter or abstraction layer.
Existing code alone, Bart, is not addressing the issue. (Even if you
don't have to write the first chunk of some code.) That's missing the
problems.
(The situation is probably to be valued a bit differently in personal
or isolated projects; this may be where you're coming from?)
Using a well-designed standard library is the way to go. - And less
work, as formulated above, for the same problem _in practice_. YMMV.
Janis
[*] Two decades ago, for example, I used (in a Java project context)
a well designed regexp library from a well-known "contributor". There
were a few to choose from. This one was simple to use (no overhead to
provide unnecessary "flexibility"). Two years later another one, a
complex one, became Java standard. - that example is from practical
experience, and don't think the basic question and inherent problems
and practical implications are different in other language contexts
that don't have a well-designed standard library available for all
the elementary things like data structures.