Live data from Hacker News

Why C Is Obsolete

softdevtube.com

31–40 of 75 posts

Re: Why C Is Obsolete

#31
post #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…

Here we go again...

C++ is used heavily from everything from Games, VFX programs (modellers, renderers/raytracer, compositors, paint programs), autopilot and control systems (cars, fighters (JSF), SpaceX are using it for their systems on their rockets), database systems, webservers, etc, etc.

There's a reason it is used a lot - in the real world it gets jobs done well by people who know what they're doing with it.

Saying "the world has moved on to Java, C#, etc, etc" is pushing it, given that the base system for many of those things are written in C++ (most of the native JNI stuff is C++, most Javascript compilers/interpreters are C++, many databases (Oracle, MySQL, MongoDB) are written in C++.

You may not like C++, and it might be difficult, and it may have worts, but thousands of people are using it very successfully for things no other language can do to the same degree overall.

Re: Why C Is Obsolete

#32
post #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…

If you now wanted to have polymorphism, you'd have to do even more work in the function, which would probably involve looking up a function pointer in a table and invoking that (i.e. Linux VFS). If you didn't start out wanting polymorphism, but then wanted to add it, C++ is way less work to do it. Why code this all by hand when the language can do it for you at no penalty? The only penalty I see in C++ for using clas…

> Why code this all by hand when the language can do it for you at no penalty? The only penalty I see in C++ for using classes or polymorphism is that it produces longer symbol names (w/ the type mangling)

There are other penalties which people who write C++ are oblivious to. For example, switching the class of an established object in runtime:

Suppose you have two compatible class layouts (same field order and types, different methods). When you implement dispatch yourself, switching the behavior is a simple matter of replacing the vtbl pointer from one class to the other (I'm not sure Linux VFS does this, but it's common enough in C object systems).

Whereas if you use C++, the standard solution is to break this into a dataless "strategy" object (which can be changed independently of the data) and a data object which contains the state. If you never had the luxury of doing something like "if (obj->class == Living) obj->class = Zombie", you don't miss it, but it doesn't mean you're not missing out on some flexibility.

> Of course, just because you're using classes doesn't mean you're doing any useful object-oriented programming.

Furthermore, just because you are doing object-oriented programming doesn't mean it is useful. (And a purist would say, just because you are doing programming, doesn't meant it is useful)

> Right now, you'd have to do a lot of convincing to get me to write native code in straight C again.

I've switched to C++ in 1993 and back to C in 2004 when compile times with boost started to measure on a geological time scale and single error messages spilled onto my 2nd screen -- and haven't looked back. When a write GUIs, I do use FLTK which is C++ (very effective, but not idiomatic), because I haven't seen a GUI toolkit as good that's native C -- but other than that, I don't miss anything, and I'm not less productive.

C++, the language, has a lot of useful tools, but C++, the ecosystem, guarantees that in any nontrivial project you'll be thrown into the tarpit. In my experience, the overall effect of C++ on a project is negative. YMMV.

Re: Why C Is Obsolete

#33
post #26

Earlier quoted context omitted.

Then again, browsers are written in C++ and so are almost all GUI apps. We spend most of our time with software that is developed in C++, probably for a good reason

so are almost all GUI apps This claim is clearly false on Mac OS X and X Window platforms, and disputable on Windows, with the increasing share of .NET apps.

No it's not - there's a reason Qt is one of the most mature and well used GUI toolkits in the world by professional desktop software...

Re: Why C Is Obsolete

#34
post #22

C++ could have been so much . . . less. Any language that takes the better part of a year to develop an adequate parser for is NOT to be trusted. I had a long rant on RTTI, templates, the positively miserable experience around exceptions, and so on. But you've heard it before. C++ should have /started/ with a string class and a set of collection classes, rather than having them be bolted on a decade later. This would…

Every person uses a different subset of C++, but that subset varies from a group to the other. You cannot therefore "remove features from C++".

A lot of people use C++ to code as they would in Java or C#, generally their experience is terrible. Exceptions don't work the way you think they do (in C++ exceptions should be exceptional). Polymorphism is more verbose, it's not introspective, etc. There's much to say about it.

I've found you enjoy the language much more when you go generic/functional full speed. You also understand why some arcane features of the languages are there (such as the .* operator).

Re: Why C Is Obsolete

#35
post #26

Earlier quoted context omitted.

Then again, browsers are written in C++ and so are almost all GUI apps. We spend most of our time with software that is developed in C++, probably for a good reason

so are almost all GUI apps This claim is clearly false on Mac OS X and X Window platforms, and disputable on Windows, with the increasing share of .NET apps.

Please, name a .NET app that is widely used on Windows.

Re: Why C Is Obsolete

#36
If only there were some extension of C which added the ability to more easily work with abstractions (say, particularly, object-oriented abstractions) that was a strict superset of C.

Re: Why C Is Obsolete

#38
post #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…

I think the point he was trying to make is that a good language allows a library to be a "domain specific embedded language", in which an expert in some domain who is not an expert in the host language can do meaningful work. The matrix example is a particularly flattering one for C++, since a good matrix library in C++ will provide syntax that is quite close to the notation that one would use on paper for matrices.

I think the matrix example is particularly unflattering, and highlights the fundamental issues with the language. For once, there is no agreed-upon matrix library in C++, but many different ones. They are only "compatible" at a very low-level (a contiguous memory buffer), and the promises of performances often broken. The only one I know of that has been delivering on the performance front is eigen3, but I think the difficulty of the approach to become slightly ridiculous. When you need some "dynamic" optimization as done by eigen, C++ and templates are rather crude tools IMO.

Re: Why C Is Obsolete

#39
To be fair, the interviewer used the provocative word "obsolete" when he asked the question. Dr. Stroustrup answered it honestly and use the words "merged" and "more compatible" and said there is no technical reason for the few existing differences today.

He also pointed out that he worked closely with the late dmr (office was just three doors down the hall) and still has strong ties to other famous and well-known C gurus (dinner with Brian Kernighan) and that C and C++ coexisted w/o issue in their world.

His final point was the best though... he pointed out how programmers argue and fight about which is better, not the designers and researchers themselves.

Edit: Also, the new C11 standard brings C closer to being a complete subset of C++ and subsequent standards will continue doing this until they are merged, but this won't make C obsolete.

Re: Why C Is Obsolete

#40

If only there were some extension of C which added the ability to more easily work with abstractions (say, particularly, object-oriented abstractions) that was a strict superset of C.

That would be Objective-C
Post reply on HN