4 ms·
Except the entire world basically runs on top of C, and any library that wants to be usable from different languages is still written in it. Which is a pretty w
by codr7 7y ago
Except the entire world basically runs on top of C, and any library that wants to be usable from different languages is still written in it. Which is a pretty weird definition of obsolete. Don't use it if you don't want to for whatever reason, but spreading FUD to protect your bubble doesn't help anyone. C is the most successful programming language ever designed, and a fine tool in the right hands. It's not perfect, nothing is, anyone telling you otherwise is lying.
- ChrisSD 7y ago> any library that wants to be usable from different languages is still written in it. This part isn't quite true. All that's needed is to be able to define an exported function with a specific name and calling convention. Libraries can be written in any language that supports these features.
- codr7 7y agoI used to do some of that in Borland's Object Pascal, which sort of works but isn't much fun. Even C++ is a pain in the behind, because everything that doesn't translate needs to be encapsulated. As a result, it's very rare to find code written in different languages with exported C APIs from my experience.
- fanf2 7y agoAnd the language needs to hide its runtime support so it appears to be as minimal as C
- ensiferum 7y agoAnd anything that C can do C++ can also do but better and easier and safer. So yeah... Obsolete.
- codr7 7y agoThat's just not true, because C++ won't even allow many of the techniques that make C the awesome language it is. It's different, and that's about as far as it goes. Add name mangling, ABI issues and crazy compile times to that. It was potentially safer until they added Exceptions, which tipped the scales so far the other way I can't believe we're still having this discussion.
- ensiferum 7y agoThere's Itanium ABI, you can use C type interfaces when needed and suppress name mangling. How do exceptions make it unsafe? They're part of idiomatic C++ and solve a problem without anything unsafe about them. And what are the many of the "awesome C techniques" that you can't do in C++?
- codr7 7y agoItani-who? But you won't when writing C++ unless you absolutely have to, because it's a major pita to encapsulate everything. Entire books [0] have been written about exception safety in C++. Getting it right in combination with RAII, (copy)-constructors and assignment operators is very tricky. Which touches the main issue with C++ from my experience, mixing foot guns with higher level convenience. Embedded linked lists [1] is a good example. Seriously, live and let live. I'm fine with you enjoying and preferring C++, go for it. But consider taking a good look in the mirror and asking yourself why you feel the need to spread FUD about C to feel good about your choice. [0] http://www.gotw.ca/publications/xc++.htm http://www.gotw.ca/publications/xc++.htm [1] https://github.com/codr7/libceque/blob/master/source/libceque/list.h https://github.com/codr7/libceque/blob/master/source/libcequ...
- ncmncm 7y agoI can honestly say that C++ exceptions have never, in decades, cost me a single hour's lost sleep. If you have any trouble with them, I promise that you are Doing It Wrong. You can tell you are Doing It Wrong if it is not super-easy and super-clean. The key is to make sure all your cleanup code is in destructors where it will be exercised frequently as part of the normal operation of your program. In the event an exception is thrown, a bunch of destructors run, as usual, and your program ends up in a known clean state, with no extra effort.