6 ms·
Does this make C++ a horrible language? https://gist.github.com/aras-p/6224951 https://gist.github.com/aras-p/6224951 Just because you can write horrible thin
by tiborsaas 7y ago
Does this make C++ a horrible language?
https://gist.github.com/aras-p/6224951 https://gist.github.com/aras-p/6224951
Just because you can write horrible things in a language it doesn't mean it's bad. Just like you can drive your car to a wall doesn't mean your car sucks.
- deleted 7y ago[deleted]
- ekianjo 7y agoI think the parent was concerned about accidental unsafe behavior, not by design.
- pjc50 7y ago> Does this make C++ a horrible language? As a C++ programmer from before it was standardised, I would happily say "yes". Unfortunately it has some properties which make it too useful not to use in some situations, and the default shared library linkage on most platforms only works for C or C++ style languages. Edit: no, it's worse than that, there's no truly reliable C++ ABI! See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4028.pdf http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n402... Inter-linkage of C++ programs tends to be done over "extern C" ABIs, or "object broker" systems (COM, CORBA etc). Possibly the next closest system is C#'s MSIL, which is almost a first-class platform citizen on Windows, and allows you to interlink assemblies produced in different languages (F#, "managed" C++, VB). Even then it's capable of alarming confusion depending on whether you've used a "framework" or "core" version.
- rocqua 7y agoIt makes the C++ preprocessor a horrible language. Whether C++ templates are an improvement is very much up for debate.
- pjc50 7y agoC++ templates allow you to do some brilliant metaprogramming. They can also be computationally expensive to compile, produce incomprehensible error messages, and are a great way of teleporting surprising behavior into your program. Especially when combined with operator overloading.
- pjmlp 7y agoAt least with C++20 modules and concepts that should improve.
- matheusmoreira 7y agoUsing anything other than C makes one's code unusable as a general purpose library due to the complexity of the binary interfaces. Writing C++ ensures the code won't be touched by anything but more C++ code. A Python script can load a C library shared object, resolve a symbol to a function pointer and call it. I don't think I'll ever see Python load a C++ library shared object, obtain a pointer to a C++ object and call methods on it using the C++ ABI and handle the C++ exceptions it may throw. The only way to interoperate is to sacrifice all the benefits of C++ and adopt a C interface. Rust has this feature as well. I like how the creator of Zig put it: if it doesn't speak the C ABI, someone's gonna rewrite it in C. https://youtu.be/Gv2I7qTux7g?t=2m https://youtu.be/Gv2I7qTux7g?t=2m
- bluGill 7y agoIn practice the C++ ABI issues are only on Microsoft Windows from what I can tell. Everything else seems to have long ago standardized on the itaniam C++ ABI, with one c++ standard library for everything in the system. Upgrades do happen, but they are major system updates where you are required to rebuild everything (generally by installing packages) so it all works. It is possible to violate those, either with a different ABI, or a different incompatible library of course, but in practice nobody does. Microsoft has their own ABI (which is annoying, but otherwise there is nothing wrong with it), but they made the "mistake" of tieing it and the standard library to the compiler not the system thus ensuring you will generally have more than one ABI to worry about unless you are careful. They do this because they have a rule that if it ever ran on a Microsoft OS it will still run (I think they have dropped some DOS and Windows 16 support, but otherwise they are famously bug compatible when bugs are exploited). I understand why Microsoft made these decisions, but for developers they are a problem.
- matheusmoreira 7y agoEven if it is stable, it's still far too complex. The compilers generate so much machinery it's not realistic to expect interoperability with foreign code.
- 7y ago
- bcoates 7y agoMost or all of these are ill-formed and required to be diagnosed by a conforming compiler.