<< >>
justin = { main feed , music , code , askjf , pubkey };
[ <<< last (older) article | view in index | next (newer) article >>> ]

January 6, 2024
Notes on software development these days, and C++

While I mostly program in C++, pretty much everything I write targets C++98 or C++03, and completely avoids the C++ standard template library.

I have no doubt that one can write exceptionally good and safe code using C++/STL, but it also appears to be incredibly easy to write very clean and safe C++/STL code that compiles without warnings or other notice into stupidly large, inefficient, memory-intensive machine code.

People new to C++ might write something that generates a list of strings:

  std::vector<std::string> list;

  // populate my list with strings, suppose this is in a loop
  std::string s = ...;
  list.push_back(s);
then later on decide to pass this list to a function:
  void dosomething(std::vector<std::string> list)
  {
    // does something
  }

...but nobody will tell them that each call of dosomething() will execute a std::string copy constructor for each item in the list, allocating (and subsequently freeing) memory for each string. There are just so many ways to get bitten here. Yes, I know, make list 'const &' etc, but it's very easy not to know that (or somewhat less easy but still possible to forget), and multiply this by 1,000 times (I know one person who was sufficiently burned by pre-increment vs post-increment having massive performance implications that they always use pre-increment in for loops, even if it's a basic type -- not that there's anything wrong with that, I guess post-increment is an odd thing to see as normal anyway)..

And we wonder why modern software generally sucks?

Recordings:

Yes, Exactly, Yes! - 1 - Sandwich Terrier (I) -- [4:47]
Yes, Exactly, Yes! - 2 - Sandwich Terrier (II) -- [3:45]
Yes, Exactly, Yes! - 3 - Sandwich Terrier (III) -- [3:38]
Yes, Exactly, Yes! - 4 - Virgins Again (Bad at Math) -- [3:27]
Yes, Exactly, Yes! - 5 - Prelude to the River -- [7:47]
Yes, Exactly, Yes! - 6 - The River -- [4:36]
Yes, Exactly, Yes! - 7 - Vertical Integration (I) -- [5:51]
Yes, Exactly, Yes! - 8 - Vertical Integration (II) -- [5:07]
Yes, Exactly, Yes! - 9 - May 29 Track 6 -- [6:34]
Yes, Exactly, Yes! - 10 - Las Vegas -- [3:57]
Yes, Exactly, Yes! - 11 - Terms of Service -- [5:32]
Yes, Exactly, Yes! - 12 - Hindenburg -- [8:19]
Yes, Exactly, Yes! - 13 - Chosen by the Few -- [5:20]
Yes, Exactly, Yes! - 14 - Self Imposed (I) -- [7:40]
Yes, Exactly, Yes! - 15 - Self Imposed (II, slower) -- [7:23]






5 Comments:
Posted by Tale on Sun 07 Jan 2024 at 06:04 from 77.170.68.x
Yeah, C++03 for the win, and no STL please! That being said, sometimes when communicating with other software (e.g. audio plugin APIs) I do have to use C++11 and/or STL, and then of course does its job just fine. But I also tend to avoid STL, and most other C++ "modernisms".


Posted by Gio on Sun 07 Jan 2024 at 11:56 from 94.70.23.x
Exactly that - my preference for WDL is that it is based on reality without much happening behind the scenes. You mostly use real constructs like a pointer, etc. What you see is what you get. Lately I started an experimental project with STL but I have to say that it is not a satisfactory experience compared to WDL. For me it looks like that the old style/methods still produce the best results. STL is not that bad but...


Posted by Gio on Sun 07 Jan 2024 at 14:35 from 94.70.23.x
Also, STL is full of pitfalls: if you know them you can write good software if not well good luck. I like to separate the programming idioms, I would describe C and C-style C++ as high performance, systems programming and equal for the most part -- but STL and Modern C++ I would address them as budget performance or cheapness depending the mood.


Posted by Gio on Sun 07 Jan 2024 at 18:38 from 94.70.23.x
It's not only that with STL: Is std::vector continuous memory in VC6? Does std::unique_ptr destruct in the correct order in VC11? Are atomics fast in VC11? Does the std::find give the correct result all the time in VC11? Are template aliases in the delivered implementation of C++11 standard in VC11? Why std::thread leaks the last decade? And the questions go on and on... I mean those compilers have a life-cycle for 10 years in theory because in reality it's a totally different story. Never had any questions with WDL, it's old but inspires confidence.


Posted by Justin on Sun 07 Jan 2024 at 20:15 from 71.125.233.x
hah well I've since given up on VC6 at least... but yeah having all of these implementation-defined questions doesn't inspire confidence for me either!


Add comment:
Name:
Human?: (no or yes, patented anti crap stuff here)
Comment:
search : rss : recent comments : Copyright © 2024 Justin Frankel