Live data from Hacker News

Why C Is Obsolete

softdevtube.com

1–10 of 75 posts

Re: Why C Is Obsolete

#5
"In this video, Bjarne Stroustrup explains why he thinks C is obsolete. He explains that the languages should have been merged into one, so that C would have been a subset of C++ instead of nearly a subset of C++. And then people could have used whatever parts of the C++ tool set they needed. "

Yeah right, a language/platform is a bag of fun toys out of which you can pick whichever ones you want, and all is well and everyone is happy. How can a programmer who has any experience claim something so ridiculous? When you decide on a platform, you have to live with whatever is there, the good and the bad. You can't tell people to use some feature but not touch this library, or not include that other package but write yours instead.

Re: Why C Is Obsolete

#6
Grrrr, I dislike C++ - my current preference for a development environment is C with a scripting engine stuck on top, but I nevertheless have to agree with Bjarne on this one. There are enough libraries out there in C++ now that the pain point of having to write wrappers so that they are accesible from C needs to disappear.

It would be so easier if the only difference between compiling for C or C++ was whether or not symbols were mangled or not. Someone writing C code that nevertheless calls C++ code could still compile with the C compiler, instead of today's solution, specifically - wrap the file in #ifdef __cplusplus extern "C" { #endif

and compile with the C++ compiler.

Plus, no more need to deal with all of the different flags leading to CFLAGS, CPPFLAGS, CXXFLAGS, no more worrying if a bool is a bool or a _Bool etc etc etc

Of course, care would need to be taken to not needlessly drag in the C++ runtime if it is not used.

Re: Why C Is Obsolete

#7
I don't understand his matrix example.

in C++, you'd have a Matrix class with a getter. To get an element of the matrix you'd do

  int v = pMatrix->get(i,j);
whereas in C you'd typedef a Matrix structure type and have an accessor function

  int v = matrix_get(pMatrix,i,j);
Looking inside the functions, they'do pretty much the same thing. In both of these functions you'd be basically accessing either element i+imax * j of your data array if you are implementing the matrix as a single array, or the j-th element of the i-th row if you were using a pointer to pointer structure. the C version would work on the provided matrix structire whereas the C++ would use the implicitly provided this structure. C++ would allow your matrix class to override some operator to make this look cooler - but operator overloading being a good thing is not really a consensus AFAIK.

I dont see anything more than a syntactic difference here. The abstract reasoning behind the structures/classes is exactly the same.

C may be obsolete, but this is hardly a justification.

Re: Why C Is Obsolete

#8
Bjarne knows damn well that you can have a Matrix interface in C instead of "an array and a whole bunch of arrays". This is not a new concept. I would have hoped he was above spreading such disinformation.

Re: Why C Is Obsolete

#9
> He explains that the languages should have been merged into one, so that C would have been a subset of C++ instead of nearly a subset of C++.

Thank the stars this didn't & won't happen!

Bjarne has been stuck in "C++ is the best & only language anyone needs" long after the world has moved on to Java, C#, Python, Ruby, JavaScript, etc.

C occupies a sweet spot combination of:

- low-level with "no magic"

- small enough for most people to "hold in your head"

C++ matched these conditions for a brief time in it's life - the early 90s aka "Stroustrup 2nd edition" - when the only "magic" was basic virtual functions, and templates where just a promising experiment in an appendix.

Post reply on HN