Live data from Hacker News

C++ Core Guidelines

github.com

1–10 of 115 posts

Re: C++ Core Guidelines

#3
I'm going to dissent on this. While the Core Guidelines "raise the floor" for code safety, I think the may be lowering/hardening the ceiling[1] as well. One problem is that, they impose an (inflexible) standard for function interfaces that is still intrinsically unsafe. For example, they direct you to standardize on std::shared_ptr for objects shared between threads. But this prevents you from using (even) safer smart pointers that, for example, do automatic mutex locking[2].

Presumably the alternatives to a standardized, intrinsically unsafe interface are either a standardized, safe interface, which would require introducing safe alternatives for unsafe elements like std::shared_ptr and raw pointers. Or a more felixible interface standard. For example, making your public functions function templates when necessary.

[1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus#safercplusp...

[2] https://github.com/duneroadrunner/SaferCPlusPlus#the-problem...

Re: C++ Core Guidelines

#5
post #4
post #2

Discussed in 2015: https://news.ycombinator.com/item?id=10239962

It's a permalink. The document itself seems to have been updated quite a bit since 2015.

I think 'dang provided the link so people could read the previous discussion (which has over 100 comments), not to imply it was a dupe. If the latter, I suspect he'd've marked it as such.

Re: C++ Core Guidelines

#6
Small annoyance (I haven't read the entire thing, but I have strong feelings about this): gsl::index is disgustingly verbose. If you use stl, just use size_t. If you're using something else, follow the conventions they use (be it size_t, int, or whatever). Their examples [1] conveniently omit size_t to push their alternative.

[1] https://github.com/isocpp/CppCoreGuidelines/blob/master/CppC...

Re: C++ Core Guidelines

#7
I wish they were more specific about when to use and not use exceptions. Truth be told I really hate exceptions and I strongly feel that they should only be used in the most disastrous situations. I'm messing with the 0MQ C++ wrapper now (which I will probably move off of) and they use exceptions for freaking everything. For example the send(msg) method returns true if the message is sent, false if EWOULDBLOCK is returned by the C api, or throws for any other error.. Like guys shit happens on networks all the time, just give me an error. Instead I have to try to track down all the damn exceptions and figure out what throws and what doesn't..

I actually really liked the way Apple did it for Objective-C. Don't use exceptions unless something is really going sideways, instead use NSError. I'm not saying this is the correct pattern for C++, but I don't personally think exceptions are the correct pattern either.

Re: C++ Core Guidelines

#8
post #7

I wish they were more specific about when to use and not use exceptions. Truth be told I really hate exceptions and I strongly feel that they should only be used in the most disastrous situations. I'm messing with the 0MQ C++ wrapper now (which I will probably move off of) and they use exceptions for freaking everything. For example the send(msg) method returns true if the message is sent, false if EWOULDBLOCK is ret…

The way ObjC did it is to use exceptions to signal programmer error, and error objects for program errors. I think it’s the best style, at least until the day programmer errors just won’t compile , but that needs something like Idris to take over.

Re: C++ Core Guidelines

#9
post #7

I wish they were more specific about when to use and not use exceptions. Truth be told I really hate exceptions and I strongly feel that they should only be used in the most disastrous situations. I'm messing with the 0MQ C++ wrapper now (which I will probably move off of) and they use exceptions for freaking everything. For example the send(msg) method returns true if the message is sent, false if EWOULDBLOCK is ret…

> I wish they were more specific about when to use and not use exceptions.

Do you have any examples in mind where it's unclear to you whether an exception would be appropriate?

Re: C++ Core Guidelines

#10
post #7

I wish they were more specific about when to use and not use exceptions. Truth be told I really hate exceptions and I strongly feel that they should only be used in the most disastrous situations. I'm messing with the 0MQ C++ wrapper now (which I will probably move off of) and they use exceptions for freaking everything. For example the send(msg) method returns true if the message is sent, false if EWOULDBLOCK is ret…

The way ObjC did it is to use exceptions to signal programmer error, and error objects for program errors. I think it’s the best style, at least until the day programmer errors just won’t compile , but that needs something like Idris to take over.

[deleted]
Post reply on HN