"Does C++ Have a Future?"
-
- KVRAF
- 2256 posts since 29 May, 2012
A common property of languages that are marketed to management instead programmers.I've been told that Java 'hotspot' is as fast as native code, but I've yet to be shown something that actually is.
~stratum~
- KVRAF
- 15260 posts since 8 Mar, 2005 from Utrecht, Holland
See https://benchmarksgame-team.pages.debia ... marksgame/ for a lot of comparisons.
C++ vs C# is only magnitudes faster for the regex-redux algorithm, probably due to a lousy implementation.
C++ vs C# is only magnitudes faster for the regex-redux algorithm, probably due to a lousy implementation.
We are the KVR collective. Resistance is futile. You will be assimilated.
My MusicCalc is served over https!!
My MusicCalc is served over https!!
-
- KVRAF
- 1607 posts since 12 Apr, 2002
The beauty of C (and possibly it's most scary side ) is that it can be seen as a high-level access to low-level programming. It's as if you're writing in assembler, but need to type much less and in a much more readable form. Sorta high-level assembler.
C++ inherited most of it and, despite trying really hard (I'm halfway kidding here, but I hope you get what I'm hinting at ), fortunately didn't get rid of this legacy yet. So, while having even more high-level programming features, one is still capable of controlling what's going on on the low level.
So, one has the whole spectrum from almost machine-code level to high-level language features. One can think in any of these terms and be able express the ideas in C++. Thus one is simultaneously capable of constructing very complex architectures and/or write very efficient and predictable implementations, staying in control (still) of what's going on. And it saves you lots of typing
With other languages you are much more at the mercy of the compiler, language runtime and other things. Sure, with time they do their job better and better. But... the so-called nonfunctional aspects (memory usage, performance, esp. in edge cases which pop up every now and then). So, on the average they might even compare to C++, but are we caring only about the average or the worst case performance? Also, how often do you get to the edge cases? The more you want to push the limits, the more you're likely to. So C++ gives you more options in pushing the limits.
One way around it is, if almost nobody would use C++ anymore, people will get used to accepting the mentioned issues (read: software getting bigger and slower ). So it's like a self-sustaining system. As long as people use C++ (and do it in an efficient way), chances are C++ will still shine for quite a while. If nobody uses it anymore, people get to accept what there is.
Of course I'm not saying that there are no other languages which are capable of properly competing with C++. Maybe there are. But I personally still have to see a successful competition in terms of described above.
C++ inherited most of it and, despite trying really hard (I'm halfway kidding here, but I hope you get what I'm hinting at ), fortunately didn't get rid of this legacy yet. So, while having even more high-level programming features, one is still capable of controlling what's going on on the low level.
So, one has the whole spectrum from almost machine-code level to high-level language features. One can think in any of these terms and be able express the ideas in C++. Thus one is simultaneously capable of constructing very complex architectures and/or write very efficient and predictable implementations, staying in control (still) of what's going on. And it saves you lots of typing
With other languages you are much more at the mercy of the compiler, language runtime and other things. Sure, with time they do their job better and better. But... the so-called nonfunctional aspects (memory usage, performance, esp. in edge cases which pop up every now and then). So, on the average they might even compare to C++, but are we caring only about the average or the worst case performance? Also, how often do you get to the edge cases? The more you want to push the limits, the more you're likely to. So C++ gives you more options in pushing the limits.
One way around it is, if almost nobody would use C++ anymore, people will get used to accepting the mentioned issues (read: software getting bigger and slower ). So it's like a self-sustaining system. As long as people use C++ (and do it in an efficient way), chances are C++ will still shine for quite a while. If nobody uses it anymore, people get to accept what there is.
Of course I'm not saying that there are no other languages which are capable of properly competing with C++. Maybe there are. But I personally still have to see a successful competition in terms of described above.
-
- KVRAF
- 2256 posts since 29 May, 2012
There used to be Object Pascal by Borland, and I don't recall anything else. I'm sure people will mention that D also works if you disable half of it.Z1202 wrote: But I personally still have to see a successful competition in terms of described above.
~stratum~
- KVRian
- 872 posts since 6 Aug, 2005 from England
The speed test I've seen bigging-up C# call a lot of native library code, which of course is fine of you're doing render heavy game code, or any mundane system stuff like hard-drive searching etc. It's when you start doing proper algorithms, that shows C++ as king.
Also if you're not an arse about obfuscating (ie loving the language too much, rather than what you're actually making), C++ can make life a whole lot easier - take Juce as a fine example of c++ being readable and friendly(ish)
Also if you're not an arse about obfuscating (ie loving the language too much, rather than what you're actually making), C++ can make life a whole lot easier - take Juce as a fine example of c++ being readable and friendly(ish)
Dave Hoskins. http://www.quikquak.com
- KVRAF
- 2237 posts since 25 Sep, 2014 from Specific Northwest
C++ is constantly in my way. I avoid all of its libraries, for the most part. They're terrible. I just make my own routines. It was actually faster for me to do my own double-linked list than to figure out what the hell C++ was doing.
If it was JUST K&R C with the addition of classes with auto malloc/release (cuz I'm lazy ), I'd be all over it, but they've made it practically impossible to just use that subset.
In the end, I'd rather just use structs and create my own C classes with memory macros to handle the new/delete bits.
/rant off I've been learning the Windows API this week...
If it was JUST K&R C with the addition of classes with auto malloc/release (cuz I'm lazy ), I'd be all over it, but they've made it practically impossible to just use that subset.
In the end, I'd rather just use structs and create my own C classes with memory macros to handle the new/delete bits.
/rant off I've been learning the Windows API this week...
I started on Logic 5 with a PowerBook G4 550Mhz. I now have a MacBook Air M1 and it's ~165x faster! So, why is my music not proportionally better?
-
- KVRAF
- 2256 posts since 29 May, 2012
It was actually faster for me to do my own double-linked list than to figure out what the hell C++ was doing.
Code: Select all
#include <list>
#include <iostream>
#include <algorithm>
int main()
{
typedef std::list<int> IntList;
IntList ll;
ll.push_back(3);
for (IntList::const_iterator ii = ll.begin(); ii != ll.end();ii++) std::cerr << *ii;
IntList::iterator jj = std::find(ll.begin(), ll.end(), 3);
ll.erase(jj);
return 0;
}
~stratum~
- KVRAF
- 2237 posts since 25 Sep, 2014 from Specific Northwest
As an aside, tight loops in Java doing mathy stuff can compete with C/C++ in speed, so can be a viable alternative. If I Java, I stick with 6. If only they'd added proper closures and redid Swing with 1/10th the bloat... The only JVM language I've found that I like is Fantom. Simple and to the point.
I understand trying to add features to make languages safer from bad programmers, but really, they are just making them as unusable as possible. I don't need my compiler whinging at me about how strcpy is unsafe when I'm tacking ".txt" to the end of MY file name.
I understand trying to add features to make languages safer from bad programmers, but really, they are just making them as unusable as possible. I don't need my compiler whinging at me about how strcpy is unsafe when I'm tacking ".txt" to the end of MY file name.
I started on Logic 5 with a PowerBook G4 550Mhz. I now have a MacBook Air M1 and it's ~165x faster! So, why is my music not proportionally better?
-
- KVRAF
- 2256 posts since 29 May, 2012
That's C, not C++. C++ version is this:syntonica wrote:I don't need my compiler whinging at me about how strcpy is unsafe when I'm tacking ".txt" to the end of MY file name.
std::string x("file"),y(".txt");
x+=y;
~stratum~
- KVRAF
- 2237 posts since 25 Sep, 2014 from Specific Northwest
Complete gibberish!stratum wrote:It was actually faster for me to do my own double-linked list than to figure out what the hell C++ was doing.As you can see it's pretty simple if you quit that genus hircus attitudeCode: Select all
#include <list> #include <iostream> #include <algorithm> int main() { typedef std::list<int> IntList; IntList ll; ll.push_back(3); for (IntList::const_iterator ii = ll.begin(); ii != ll.end();ii++) std::cerr << *ii; IntList::iterator jj = std::find(ll.begin(), ll.end(), 3); ll.erase(jj); return 0; }
I'm really crabby this week, so just ignore my tirades...
I started on Logic 5 with a PowerBook G4 550Mhz. I now have a MacBook Air M1 and it's ~165x faster! So, why is my music not proportionally better?
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
Use clang, it has modules instead of headers, and they should come in the standard for C++20.quikquak wrote:I've always hated header files, but I've learned to live with them.
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
And they are starting (finally) to things natively, like threads and soon SIMD (instead of using intrinsics, so portable), so yes, I think the future is sunny again for C++. And with better memory management practices introduces with C++11, you don't have to worry as much about it and still do low level stuff.Z1202 wrote:So, one has the whole spectrum from almost machine-code level to high-level language features. One can think in any of these terms and be able express the ideas in C++. Thus one is simultaneously capable of constructing very complex architectures and/or write very efficient and predictable implementations, staying in control (still) of what's going on. And it saves you lots of typing
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
Have you looked at the cppcon presentations? Especially those by Chandler Carruth, it should reconcile you with C++. It's always about using the proper container. list is usually never.syntonica wrote:C++ is constantly in my way. I avoid all of its libraries, for the most part. They're terrible. I just make my own routines. It was actually faster for me to do my own double-linked list than to figure out what the hell C++ was doing.
- KVRAF
- 2237 posts since 25 Sep, 2014 from Specific Northwest
Heh. I needed something arbitrarily expandable. I could have just thrown memory at the problem and used an array large enough to handle extreme cases, but the list was faster, simpler and more elegant, despite creating and destroying the items. I suppose I could keep a pool of empties, but it hasn't proven necessary. It's actually the first list type I've ever had to use, but FIFO order was needed, as well as being able to remove items in the middle. Normally, I'm stuck with doing key/value maps. (Insert yawning emoticon here.)Miles1981 wrote:Have you looked at the cppcon presentations? Especially those by Chandler Carruth, it should reconcile you with C++. It's always about using the proper container. list is usually never.syntonica wrote:C++ is constantly in my way. I avoid all of its libraries, for the most part. They're terrible. I just make my own routines. It was actually faster for me to do my own double-linked list than to figure out what the hell C++ was doing.
I started on Logic 5 with a PowerBook G4 550Mhz. I now have a MacBook Air M1 and it's ~165x faster! So, why is my music not proportionally better?