TangledHyphae ,

As someone who writes C++ every day for work, up to version C++20 now, I hate the incoming C++23 even more somehow. The idea of concepts, it just... gets worse and worse. Although structured binding in C++17 did actually help some with the syntax, to be fair.

ninth_plane ,

Eventually the line comes back in from the top.

witx ,

Or perhaps it will come from the right? Undefined behaviour is the magic word

RoyaltyInTraining ,
@RoyaltyInTraining@lemmy.world avatar

Integer underflow

erp ,

C++: C with blackjack and 40 year old hookers. Anyway, only the rich can inherit diamonds or something. Or perhaps not, my memory is corrupted. I'm open to any pointers though...

mindbleach ,

The C++ feature set is a giant tome written in an unsteady hand and bound with suspicious leather. You're supposed to study it deeply, use as little as possible, and ideally have a backup plan if things go wrong for this plane of existence.

MajorHavoc ,

Perfect description.

It also describes why I now love GoLang so much.

"How has GoLang improved on this unholy tome or horrors?"

"Well, it fits in my pocket now."

lseif ,

i like to think of C++ as a testing ground for new features and paradigms. to see how some concepts will handle in production.

mindbleach ,

An excellent perspective.

Announcement N: "C++ can now do [blank]!"

Announcement N+1: "Don't."

penquin ,
@penquin@lemm.ee avatar

I like C# better. Ok, I'll see myself out.

Templa ,
@Templa@beehaw.org avatar

More like Java#

AVincentInSpace ,

In the early days of C#, before it was called C#, Microsoft gave it the most Microsoft name ever conceived for anything ever: Visual J++

skuzz ,

I did not realize they were one and the same!

AVincentInSpace ,

update: i just looked it up and they are not. Visual J++ is a predecessor to C#. Nevertheless, the name "Visual J++" in all its Microsoftian goodness(?) is as good a descriptor as any for what C# turned into

skuzz ,

So more an iterative family member, which I suppose was more what I'd expect with how Microsoft hisorically handled programming languages. Still interesting! Thanks for the fact-check!

hark ,
@hark@lemmy.world avatar

The graph goes up for me when I find my comfortable little subset of C++ but goes back down when I encounter other people's comfortable little subset of C++ or when I find/remember another footgun I didn't know/forgot about.

henfredemars ,

When I became a team leader at my last job, my first priority was making a list of parts of the language we must never use because of our high reliability requirement.

brisk ,

Care to share any favourites?

henfredemars ,

strtok is a worst offender that comes to mind. Global state. Pretty much just waiting to bite you in the ass and it did, multiple times.

mormegil ,
@mormegil@programming.dev avatar

Sure, strtok is a terrible misfeature, a relic of ancient times, but it's plainly the heritage of C, not C++ (just like e.g. strcpy). The C++ problems are things like braced initialization list having different meaning depending on the set of available constructors, or the significantly non-zero cost of various abstractions, caused by strange backward-compatible limitations of the standard/ABI definitions, or the distinctness of vector<bool> etc.

LANIK2000 ,

That's one thing that always shocks me. You can have two people writing C++ and have them both not understand what the other is writing. C++ has soo many random and contradictory design patterns, that two people can literally use it as if it were 2 separate languages.

ChaoticNeutralCzech ,

my comfortable little subset of C++

I also have one. I call it "C"

hark ,
@hark@lemmy.world avatar

C is almost the perfect subset for me, but then I miss templates (almost exclusively for defining generic data structures) and automatic cleanup. That's why I'm so interested in Zig with its comptime and defer features.

jas0n ,

You may also like Odin if you haven't already started zig. It's less of a learning curve and feels more like what c should have always been. It has defer and simple generics, but doesn't have the magic of comptime.

uis ,
@uis@lemm.ee avatar

Damm, C23 has a lot of changes. Some of them are really good, some of them I strongly dislike(keyword auto, addition of nullptr).

grrgyle ,
@grrgyle@slrpnk.net avatar

This comment smells like unix

nothacking ,

Hot take, C is better then C++. It really just has one unique footgun, pointers, which can be avoided most of the time. C++ has lots of (smart)pointer related footguns, each with their own rules.

Venator ,

Then C++ what?

MajorHavoc ,

Yeah. My journey of love, loathing, hatred, adoration, and mild appreciation for C++, ended with the realization that 90% of the time I can get the job done in C with little hassle, and a consistent, predictable, trustworthy set of unholy abominations.

Valmond ,

If you do C, and avoid pointers, do tell me what the point is using the language at all?

I mean if memory management is "the only way to shoot yourself in the foot" in C, then thats a quite big part of the language!

uis ,
@uis@lemm.ee avatar

If you do C, and avoid pointers, do tell me what the point is using the language at all?

Person is saying that C has one big footgun, while C++ has armory of them

Valmond ,

C is like one big problem then :-D

C++ lots of smaller problems: divide & conquer baby!

jas0n ,

But it's a single problem.

AProfessional ,

C++ literally makes it easier to avoid raw pointers and allocation that are dangerous…

jas0n ,

Preach brother, I don't think that's a hot take at all. I've become almost twice as productive since moving from c++ to c. I think I made the change when I was looking into virtual destructors and I was thinking, "at what point am I solving a problem the language is creating?" Another good example of this is move semantics. It's only a solution to a problem the language invented.

My hot take: The general fear of pointers needs to die.

OpenStars ,
@OpenStars@discuss.online avatar

Compared to Assembly language, C++ is fantastic! :-P

scrion ,

It's actually a lot worse than ASM, there are far more ambiguities in C++. And yet here I am, still developing with it some 30+ years later.

Don't worry, I'm using Rust were it makes sense.

Kakaofruchttafel ,

Where does using Rust not make sense?

xmunk ,

This graph cuts off early. Once you learn that pointers are a trap for noobs that you should avoid outside really specific circumstances the line crosses zero and goes back into normal land.

Pelicanen ,

C++ is unironically my favorite language, especially coding in python feels so ambiguous and you need to take care of so many special cases that just wouldn't even exist in C++.

GlitchyDigiBun ,
@GlitchyDigiBun@lemmy.world avatar

But can you read someone else's C++ code?

magic_lobster_party ,

Why should I do that?

Narwhalrus ,

Typically, I can read an "average" open source programmers code. One of the issues I have with C++ is the standard library source seems to be completely incomprehensible.

I recently started learning rust, and the idea of being able to look at the standard library source to understand something without having to travel through 10 layers of abstraction was incredible to me.

barsoap ,

One of the issues I have with C++ is the standard library source seems to be completely incomprehensible.

AAAAAAhhh I once read a Stroustrup quote essentially going "if you understand vectors you understand C++", thought about that for a second, coming to the conclusion "surely he didn't mean using them, but implementing them", then had a quick google, people said llvm's libc++ was clean, had a look, and noped out of that abomination instantly. For comparison, Rust's vectors. About the same LOC, yes, but the Rust is like 80% docs and comments.

lazyneet ,

I've been using C++ almost daily for the past 7 years and I haven't found a use for shared_ptr, unique_ptr, etc. At what point does one stop being a noob?

AngryPancake ,

Given that you probably are using pointers, and occasionally you are allocating memory, smart pointers handle deallocation for you. And yes, you can do it yourself but it is prone to errors and maybe sometimes you forget a case and memory doesn't get deallocated and suddenly there is a leak in the program.

When you're there, shared_ptr is used when you want to store the pointer in multiple locations, unique_ptr when you only want to have one instance of the pointer (you can move it around though).

Smart pointers are really really nice, I do recommend getting used to them (and all other features from c++11 forward).

arendjr ,

Smart pointers are really really nice, I do recommend getting used to them (and all other features from c++11 forward).

You’re recommending him to give up his sanity and/or life?

MajorHavoc ,

At what point does one stop being a noob?

I recognize that trick question. For C++, the answer is always "soon".

orbitz ,

First year programming in the late 90s .. segmentation fault? I put printfs everywhere. Heh. You'd still get faults before the prints happened, such a pain to debug while learning. Though we weren't really taught your point of the comment at the time.

Least that was my experience on an AIX system not sure if that was general or not, the crash before a print I mean.

xmunk ,

Yea, pointer arithmetic is cute but at this point the compiler can do it better - just type everything correctly and use []... and, whenever possible, pass by reference!

uis ,
@uis@lemm.ee avatar

Faust bless Stallman for creating GDB.

5C5C5C ,

Your graph also cuts out early. Eventually you want to get performance gains with multi-threading and concurrency, and then the line drops all the way into hell.

xmunk ,

Good Afternoon Sir, have you heard about our lord and savior pthreads?

5C5C5C ,

I'm not saying you can't do multi-threading or concurrency in C++. The problem is that it's far too easy to get data races or deadlocks by making subtle syntactical mistakes that the compiler doesn't catch. pthreads does nothing to help with that.

If you don't need to share any data across threads then sure, everything is easy, but I've never seen such a simple use case in my entire professional career.

All these people talking about "C++ is easy, just don't use pointers!" must be writing the easiest applications of all time and also producing code that's so inefficient they'd probably get performance gains by switching to Python.

deadcream ,

That's the problem of most general-use languages out there, including "safe" ones like Java or Go. They all require manual synchronization for shared mutable state.

5C5C5C ,

There's a difference between "You have to decide when to synchronize your state" and "If you make any very small mistake that appears to be perfectly fine in the absence of extremely rigorous scrutiny then this code block will cause a crash or some other incomprehensible undefined behavior 1/10000 times that it gets run, leaving you with no indication of what went wrong or where the problem is."

uis ,
@uis@lemm.ee avatar

Well, threadsanitizer catches them in runtime. Not sure about GCC static analyser and other SA tools.

5C5C5C ,

I use thread sanitizer and address sanitizer in my CI, and they have certainly helped in some cases, but they don't catch everything. In fact it's the cases that they miss which are by far the most subtle instances of undefined behavior of all.

They also slow down execution so severely that I can't use them when trying to recreate issues that occur in production.

WormFood ,

pointers are fine, but when you learn about the preprocessor and templates and 75% of the STL it goes negative again

c++ templates are such a busted implementation of generics that if I didn't have context I'd assume they were bad on purpose like malbolge

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • kbinchat
  • All magazines