Self Wright

Tag: c++

Starting new C++ projects

I wanted to have a playground to try out new idioms and concepts (hah!) in C++, and it became an excuse to figure out what the right way (in my opinion) would be, given the enormous range of choices each step of the way.

I settled on two requirements: a good build system and a good standard library augmentation.

There are numerous build systems these days, but (blame familiarity here, I guess) I went with Bazel.

Similarly, familiarity led me to pick Abseil over (say) Boost or Folly.

To show how straightforward it can be these days to “just start making” something in C++, I made a small dummy program that has a single cc_binary rule and uses some basic string library functions.

(The real story is how amazing it is to have open-sourced versions of these, this setup would have been unthinkable just a couple of years ago!!)

Take a look here.

I’m getting somewhat peeved with the repetitive claims that C is so fast.

It isn’t. it never was. It’s just that the language is fairly transparent down to the machine level so when you change something in the C code, you can predict the effect on the compiled machine code.

That doesn’t make it fast, it only ingratiates the control-freak aspect of most programmers.

The C-only train has left the station. Few departments teach surveys of programming languages anymore, and I don’t know of any department that teaches a required course in history of computing. I worry about what this means for our discipline.

Are we really going to tell students that the peak of human expressibility for computation was in 1973? That all programming language research from here on out is wasted energy? That simplicity is all that we can ever hope for, and correctness and consistency just aren’t worth working on?

Are we forever stuck with 30+ year old ideas and don’t even teach that anything else is possible?

All experience has taught us that solving a complex problem uncovers hidden assumptions and ever more knowledge, trade-offs that we didn’t anticipate but which can make the difference between meeting a deadline and going into research mode for a year, etc.

If C++ were used only to solve known problems with known solutions, it would be a perfectly OK language. Smart people would design classes “once and for all” and sell them like nuts and bolts, companies could pre-fabricate parts that fit together because of industry consensus on standards and specifications, and this age-old “dream” of some software engineers.

I believe this is a completely insane view of programming, but C++ cannot have any other – it is designed to be an “ex post facto language”

Java takes the part of C++ that I like the least – its syntax derived from the C syntax – and not the parts I consider most important – the ability to do data abstraction without compromising efficiency and the ability to write user-defined types that are treated on equal footing with built-in types.

Powered by WordPress & Theme by Anders Norén