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.
Why C Is Obsolete
51–60 of 75 posts
Re: Why C Is Obsolete
#52~
Instead, let's talk about things that C++ got right that aren't super obvious! :)
For me, one of the coolest things about C++ is having destructors. The neat thing about them is that they are based on the scope of an object, and tie directly into when the object leaves scope in the language (as determined at compile time). Any code there gets run when the object is deleted or leaves scope, and this is guaranteed to happen immediately.
So, I know exactly when an object is no longer "needed", and if I'm careful I can use things like smart pointers and reference counting to guarantee that a shared resource gets removed when it needs to. I can also override new/delete and do some magic to have a reliable "hey, come free me from the heap later" behavior--when the destructor is called, have the class append itself to a list of things to be GC'ed when the time is right.
Java, for example, doesn't do this--a request to finalize may be fulfilled, one day, when the VM feels like it. This makes smart handling of things like system resources really clunky, and can force me to write C-ish code like freeSystemResources() or something. Having an ability to explicitly know when lexical scope has been left is pretty cool.
What other cool things have you seen in C++ (or C)?
Re: Why C Is Obsolete
#53> 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. Sa…
I meant something like: other languages have risen in popularity because they are better than C++ for many types of projects.
Re: Why C Is Obsolete
#54Earlier quoted context omitted.
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…
"""Every person uses a different subset of C++, but that subset varies from a group to the other. You cannot therefore "remove features of C++"""" Actually you can. You don't remove them from the existing language that is, you make a better language with bs/redundant removed. While "every person uses a different subset of C++" is true, it's not like everything someone uses is equally beneficial to have in a language.…
Re: Why C Is Obsolete
#55Earlier quoted context omitted.
> long after the world has moved on to Java, C#, Python, Ruby, JavaScript, etc. I don't think this is true for everyone. In fact I believe recently we have seen a renaissance of native code. C++ is the number one language for that. Those higher level languages waste a lot of cycles. You pay the warm and fuzzy feeling during development with performance and/or energy.
I used this argument for Java, but it's the same with C++. If I can deliver a first version 2 months before the C++ version gets ready, I'll have two months to optimize market-tested algorithms before you hit the market. I may even have time to rewrite the sensitive parts in C. If we are talking gadgets with embedded software, you may use a less powerful hardware and offer a cheaper product, but you'll have to amorti…
Yeah, the only problem with that logic is that it never happens.
(Except in the server space, where it doesn't matter what language you're using to make your web app, and you can throw more server boxes at it to make it go faster).
1) Very few commercial programs are made with some dynamic language as opposed to C/C++, and none in the fields where performance matters (games, video, multimedia) etc.
2) Some do incorporate a scripting language, but for non critical layers (Lightroom for example uses Lua for its UI scripting, but all image crunching is in C/C++).
3) It's not like time to market matters that much. You're not building Facebook, you're building a desktop app. Chances are a lot more exist in the same section of the market.
4) """For many things the world really moved on.""" --care to give some examples of successful desktop apps not written in C/C++?
I'm sure you'll find 10.
I doubt you'll find 20.
Re: Why C Is Obsolete
#56Re: Why C Is Obsolete
#57* group code into functions * group primitives into structures.
However, it's simplicity is it's strength. You can write clean, standardised code in it. It's clean and simple. It's obvious. It's far too easy to make mistakes in C++ from bad type conversion or bad inheritance models (e.g. forgetting to virtualise something) to confusing subtly broken operator overloading that's counter-intutative.
C++ does render a C a little bit redundant. The abstractions it provides not only make programs more maintainable, but that additional intent allows compilers to potentially generate faster and more portable multithreaded code. We hit a point where C programs compile to faster/better assembly than a human can write. I expect that soon we'll hit a second wall where the C++ compilers can write faster/better multithreaded code than a C programmer could write or optimise and a C compiler couldn't support that directly "intent" as the language doesn't facilitate describing it.
However that point hasn't come yet. C still benefits from being clean, easy to interpret (from a human perspective) and is a demonstration of how to design a new language.
C++ is a federation of languages but writing pure C with gcc is better than g++ with all warnings enabled IMHO.
Re: Why C Is Obsolete
#58What about Operating System?
Re: Why C Is Obsolete
#59Earlier quoted context omitted.
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
#60Earlier quoted context omitted.
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.
"""This claim is clearly false on Mac OS X and X Window platforms, and disputable on Windows, with the increasing share of .NET apps.""" Actually it is not. On OS X tons of programs, and especially the very largest, most popular ones, are in C++ (think: Photoshop and the Creative Suite, MS Office, and lots of Apple's own: Safari (webkit) is C++, Final Cut and Logic are C++, etc. Don't confuse the front-end UI code (C…