4 ms·
How would you recommend doing that sort of "subtyping"? _Generic and macros?
by remexre 1y ago
How would you recommend doing that sort of "subtyping"? _Generic and macros?
- o11c 1y agoYup. It's a lot saner in C++, but people who refuse to use C++ for political reasons can do it the ugly way using C11 or GNU C.
- improgrammer007 1y agoThey even downvote people who suggest C++ :-). Doing this in C is such a colossal waste of time and energy, not to mention the bugs it'll introduce. Sigh!
- zahlman 1y agoTrolling about the choice of implementation language from a throwaway account is worth downvotes, yes. Doing a given task in a given language, simply for the sake of having it done in that language, is a legitimate endeavour, and having someone document (from personal experience) why it's difficult in that language is real content worth discussion. Choosing a better language is very much not a goal here. > Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something.
- vlovich123 1y agoFollowing that argument, c++ is also a colossal waste of time and energy and bugs when compared with Rust :D.
- pjmlp 1y agoEventually, when Rust finally catches up with C++ ecosystem, including being used in industry standards like Khronos APIs, CUDA, console devkits, HPC and HFT standards. Until then, the choice is pretty much between C and C++, and the latter provides a much saner and safer alternative, than a language that keeps pretending to be portable macro assembler.
- vlovich123 1y agoYou can bind to C and c++ libraries just fine. There’s plenty of Rust bindings for Vulkan and CUDA, the canonical implementation of WebGPU is in rust.
- pjmlp 1y agoBinding just fine isn't the same as taking part in the conversation of industry standards, and being shipped in vendor SDKs. Requires manual work from people willing to put into the effort, lesser development experience reading documents written for other languages, no out of the box plugins for IDEs, or graphical debuggers support, e.g. CUDA as one such example.
- uecker 1y ago"political reasons"? I switched from C++ to C because C++ is too complex and dealing with this complexity was stealing my time. I would not call this a "political reason".
- deleted 1y ago[deleted]
- pjmlp 1y agoC's simplicity is oversold, when taking into account that in practice it isn't the second edition of the K&R C book, adapted for ISO, rather a plethora of extensions, several standard revisions since 1989, zero care for security. Dealing with security issues is one of my occupations, when having a DevOps role in project delivery, and I rather use that time elsewhere.
- uecker 1y agoAfter wasting many hours of my life debugging C++ code, before switching to C, I disagree. The simplicity and explicitness of C is underappreciated.
- pjmlp 1y agoIf only it came along with a security mindset, unfortunately 50 years aren't enough to change language culture.
- uecker 1y agoAs if C++ had a security mindset: void foo(std::vector<int> &x) { x[4] = 1; } int main() { std::vector<int> x{ 0, 1, 3, }; foo(x); std::cout << x[4]; }
- pjmlp 1y agoThe difference being that all C++ compilers have an option to enable bounds checking on operator[](). Additionally, until C++26, the way the standard is written, the legalese doesn't forbid the implementation to do bounds checking. Now can you please enlighten us how to do the same with C arrays and strings, with bounds checking enabled, and why in 50 years WG14 has completely ignored the problem, including Dennis Ritchie proposal for fat pointers, until the government and industry pressure, and even now, I am quite curious if C2y will really bring any actual improvement.