4 ms·
Kudos to the author ... ... but yes - a 'Modern' approach means calling out risks, or more abruptly - that which may even be considered 'anti pattern' inherent
by jollybean 4y ago
Kudos to the author ...
... but yes - a 'Modern' approach means calling out risks, or more abruptly - that which may even be considered 'anti pattern' inherent in a language as it evolves over time, with hindsight.
Perhaps the most preeminent example would be pointers in C++ - which we generally know to use with 'smart pointers'.
If C++ 'were designed today' - among other things, it'd be likely that 'smart pointers' would be 'default' and they'd be more deeply and seamlessly integrated, and 'direct memory reference' would be seen as a 'thing to do only if necessary' and a bit of a 'corner case'. Necessary, and common enough, surely as in that level of programming we are going to 'go there', however, it's something we wouldn't see as normal practice, rather something we do but with some other idioms, APIs and conventions around it ... possibly with demarcations of 'unsafe' a bit like Rust.
I think it's important, because these are precisely the things that young developers may become entangled in. It should be more like: "By the way this is how this works, but you may want to think twice about using it, here are some cases where it might be 'ok', here are some cases where it's not".
But I don't want to take away from good authorship either, we depend a lot on people stepping up to the plate and doing this work. As an aside, it seems almost perverse that 'Big Corps' just don't do this themselves. I mean, if AWS uses JS extensively, it'd seem reasonable (even from a selfish perspective) for them to 'just do' a comprehensive, JS set of docs.
It's weird that the world depends on 'a few nice dudes/dudettes' to maintain something like 'caniuse.com' and the plethora of other such important works.
- UncleEntity 4y ago> Perhaps the most preeminent example would be pointers in C++ - which we generally know to use with 'smart pointers'. Smart pointers are nice and all that but I have yet figured out how to mix them with code which doesn’t use them which is like 99.9% of all library code. Not to mention that interfacing with C code (like python extensions) are basically impossible unless the calling code is responsible for the object lifetimes. I don’t know how language de jour deals with this C interop but have read it is a pain point almost universally. Even some of the newer languages I see posted here have manual memory management as the default.
- hoseja 4y ago>how to mix them with code which doesn’t use them which is like 99.9% of all library code That's what the "more deeply and seamlessly integrated" would be mostly about.
- j16sdiz 4y ago> 'smart pointers' I tends to avoid smart pointers. There are too many variants, supported in different c++ version. Can't reasonably track which one is supported in which compiler
- hoseja 4y agoHuh? It's literally just std::unique_ptr for most uses, available since c++11.
- pjmlp 4y agoAlmost every C++ framework since the mid-90's has some variation of them, and those haven't gone away in existing code.
- gituliar 4y agoAvoiding smart pointers for those reasons is a bad idea. Smart pointers are unified since C++11 standard with support in all modern compilers for various platform. Invest some time to get familiar with them and you will not regret.
- jollybean 4y agoYes, it's a bit my point. They are a messy bandaid. The notion of using them in lieu of 'nothing' is rational - but the application is a mess. We need a clean version of C++ that's not some gigantic new thing.