News for hackers. Stuff that matters.
Re:I love coding in C by codr7 on Thursday December 26, 2019 @10:40AM (#21884519)
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.
Re:I love coding in C by ChrisSD on Thursday December 26, 2019 @12:34PM (#21885335)
> 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.

Re:I love coding in C by codr7 on Thursday December 26, 2019 @02:01PM (#21885883)
I 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.

Re:I love coding in C by fanf2 on Thursday December 26, 2019 @02:04PM (#21885897)
And the language needs to hide its runtime support so it appears to be as minimal as C
Re:I love coding in C by ensiferum on Thursday December 26, 2019 @01:48PM (#21885792)
And anything that C can do C++ can also do but better and easier and safer. So yeah... Obsolete.
Re:I love coding in C by codr7 on Thursday December 26, 2019 @01:54PM (#21885831)
That'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.

Re:I love coding in C by ensiferum on Thursday December 26, 2019 @02:41PM (#21886131)
There'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++?
Re:I love coding in C by codr7 on Thursday December 26, 2019 @03:42PM (#21886600)
Itani-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 [1] https://github.com/codr7/libceque/blob/master/source/libcequ...

Re:I love coding in C by ncmncm on Thursday December 26, 2019 @04:40PM (#21887043)
I 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.