Follow

C++ sure does make simple things complicated

· · Web · 2 · 1 · 6

I think I'm really just not smart enough to use this language. I miss Go.

Show thread

C++ is a language that's had pretty much every possible feature crammed into it over a period of decades and yet somehow none of them seem to actually be useful for solving what seems like a very simple problem

Show thread

@fraggle I'm not sure the complexity of the problem and the solution even correlate that strongly in C++. Sometimes you hit this beautiful, elegant groove where all your types are Bjorn and Meyers-approved and the STL is letting you write these powerful, clear, succinct statements of intent that will compile down to blisteringly efficient raw code...and sometimes you just want to build a hex string without feeling dirty about snprintf and find yourself with stringstreams and manipualtors.

@fraggle (The "I'm in someone's Framework, and I'm twenty-namespaces deep, dealing with an abstraction of an abstraction of an abstraction, and I'm holding a pointer to memory owned by Jeff, who thinks they might release it next Tuesday if it's not raining" is mostly a language-agnostic kind of horror. GC advocates only change the kinds of violence Jeff can inflict on you with mismatch of lifetime expectations.)

@LionsPhil probably the biggest change to my coding style in the past 10 years has been to set a really high bar for when it's appropriate to define a new type. Excessive types are a plague

@fraggle I do like how Abseil does things like make Durations their own type rather than just using ints (abseil.io/docs/cpp/guides/time), because nobody does Apps Hungarian properly, and without things like this sooner or later someone has messed up if that int is nano vs milli vs full seconds and your delay between API call retries is now approximately one mouse heartbeat.

But yes, otherwise classes should protect invariants. They are not the universal hammer Java uses them as.

@fraggle @LionsPhil that’s a really interesting yard stick because I agree it’s probably appropriate in C/C++ but you’d probably want the opposite rule for FP

@fraggle C++ has so much feature creep it is now a super-bloated complex language.

@fraggle I just threw up my hands and went back to C because I'd rather have complete understanding of the language and none of the features than all of the features and an incomplete understanding.

And then Rust happened.

@thoth my favourite example is that in C++ it's impossible to know what "a = b + c;" does without reading the entire program

@fraggle Oh that's nothing. In C, the comma operator performs expression sequencing. In C++, the comma operator *can be overloaded*.

Why? How? Why would you ever WANT that?

@fraggle can recommend giving Rust a go - got to use it a little for work and now sad that I can't use it for everything :( The amount of time saved from errors that are super easy to make in C++ (and other languages) alone make it very desirable to me...

Sign in to participate in the conversation
Octodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!