lysdexic

joined 2 years ago
MODERATOR OF
[–] lysdexic@programming.dev 0 points 2 years ago (1 children)

Naked pointers are just too stupid for modern C++ ;)

Anyone who works on real-world production software written in C++ knows for a fact that pointers are a reality.

Also, there are plenty of frameworks who employ their own memory management frameworks, and raw pointers are perfectly fine in that context. For example, Qt uses raw pointers extensively because It's object system implements an object ownership system where each object can have child and parents, and you can simply invoke deleteLater() to free the whole dependency tree when you no longer need it.

[–] lysdexic@programming.dev 1 points 2 years ago* (last edited 2 years ago)

Simply taking std::string by value (as it is a memory management class created for that explicit purpose) would have solved the problem without kneecapping every class you make.

I think you are missing the whole point.

The blogger tried to make a point about how special member functions can be tricky to get right if you don't master them. In this case, the blogger even presents a concrete example of how the rule of 3/rule of 5 would fail to catch this issue. As the blogger was relying on the implicit special member functions to manage the life cycle of CheeseShop::clerkName and was oblivious to the possibility of copying values around, this resulted in the double free.

You can argue that you wouldn't have a problem if the string was used instead of a pointer to string, which is a point that the blogger indirectly does, but that would mean you'd be missing the root cause and missing the bigger picture, as you'd be trusting things to work by coincidence instead of actually knowing how they work.

The blogger also does a piss-poor job in advocating to explicitly delete move constructors, as that suggests he learned nothing from the ordeal. A preferable lesson would be to a) not use raw pointers and instead try to adopt a smart pointer with the relevant semantics, b) actually provide custom implementations for copy/move constructors/assignment operators whenever doing anything non-trivial to manage resources, such as handling raw pointers and needing to both copy them and free them whenever they stop being used.

[–] lysdexic@programming.dev 3 points 2 years ago

You're making a very poor example by subscribing to !cpp@programming.dev

[–] lysdexic@programming.dev 4 points 2 years ago

Any style guide is better than no style guide. Until a better option is presented, something is better than nothing.

[–] lysdexic@programming.dev 2 points 2 years ago (1 children)

Boy, that joke. How low can you go.

[–] lysdexic@programming.dev 3 points 2 years ago* (last edited 2 years ago) (5 children)

Such gains by limiting included headers is surprising to me, as it’s the first thing anyone would suggest doing.

Yes indeed. I think this is a testament of the loss of know-how we're seeing in software engineering in general, and how overambitious but underworking developers try to stake claims in technical expertise when they even failed to onboard onto the very basics of a tech stack.

I'm sure it's a matter of time before there's a new post in Figma's blog showing off their latest advanced technique to drive down build times: onboarding ccache. Followed by another blog post on how Figma is researching cutting edge distributed computing techniques to optimize build times by replacing ccache with sccache.

[–] lysdexic@programming.dev 1 points 2 years ago* (last edited 2 years ago)

The Philosophy section has quite a few wonky arguments; I’d skip it altogether.

I agree. I wish they moved that to a standalone section so that it could be easily skipable. Reference docs can and should have a rationale, but a lengthy rant is not what leads people to the site.

[–] lysdexic@programming.dev 1 points 2 years ago

As a side note, the final keyword is only tangentially related with inlining. It's killer feature is removing the need to do pointer dereferencing when calling virtual members of instances of classes that no longer require virtualization.

[–] lysdexic@programming.dev 5 points 2 years ago* (last edited 2 years ago)

Edit: just noticed this post is over 10 years old.

It would be helpful if the title was edited to feature the release date. Context is king. So many things are absurd with regards to the current state, but are sorely lacking a few years ago.

[–] lysdexic@programming.dev 10 points 2 years ago

Incidentally, this kind of passive-aggressive pressure is the kind of thing that might be considered a legitimate security threat, post xz.

Yes, OP's attempt to bully a maintainer into accepting his PR is a very shitty thing to do.

Throwing veiled personal attacks, such as insinuating a developer is incompetent or dumb, is also very bad form.

This says more about OP than anything. I hope I never have to work with anyone like that. What a shit show of a person.

[–] lysdexic@programming.dev 2 points 2 years ago

This shape certainly beats a triangle (...)

Nature loves triangles.

https://en.wikipedia.org/wiki/Michell_structures

[–] lysdexic@programming.dev 3 points 2 years ago (2 children)

I don’t really see how it’s daunting enough to avoid mentioning.

I think it's a good call not to mention them because they are irrelevant given the topic. If your code base and/or the consumers of your code base are using C-style arrays for input and/or output, it's hardly helpful to suggest changing all your interfaces to use another data type. It's outright impossible if you're dealing with extern C interfaces.

view more: ‹ prev next ›