"Does C++ Have a Future?"

DSP, Plug-in and Host development discussion.
Miles1981
KVRian
1366 posts since 26 Apr, 2004 from UK

Post Sun Apr 15, 2018 7:06 am

sonigen wrote:You missed my point, there are specifically lots of books on how to avoid all the pitfalls of C++, how to avoid stepping on the landmines, written by the C++ gurus like Meyers, Sutter and Alexandrescu.
Except for the last Meyers, they are already quite old, so you need to adapt them when you read to the new C++ features. And even then, they didn't write than many books, so that would make it around 10. It gets very easy to read the wrong book.
sonigen wrote:No other language I've used has so much written in terms of "If you're doing A make sure you avoid B". Or "it has MI which is cool, but really dont use it, its not a good idea".
That's true. That's something I actually like about the language, and make it also its power. You can write in more or less any fashion. In some cases one manner is better than another.
sonigen wrote:I've been coding 30 years and have used a bunch of different languages, C++ is not fast to develop in. You can imply that I don't know what I'm doing but then I could imply you've never been out of your C++ bubble.
Haha.
sonigen wrote:What language features have been depreciated in the last 10 years?
Everything that was deprecated due to the introduction of lambdas, auto_ptr, register, auto, export, random_shuffle...
sonigen wrote:So you know C++ and Python? Not exactly a broad horizon.
Is this now a bragging contest?

sonigen
KVRian
563 posts since 23 Nov, 2010

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 8:07 am

Miles1981 wrote:
sonigen wrote:What language features have been depreciated in the last 10 years?
Everything that was deprecated due to the introduction of lambdas, auto_ptr, register, auto, export, random_shuffle...
Maybe I didn't explain what I meant properly. Adding new features isn't the same as depreciating old ones. I'm asking what features have actually been either taken out from the language or have been marked for removal at some point in the future. So for example the compiler will give you a warning or an error if you use them.
Miles1981 wrote:
sonigen wrote:So you know C++ and Python? Not exactly a broad horizon.
Is this now a bragging contest?
No, I'm just saying that when you say C++ is fast to develop in, and safe, etc.. you dont really have much frame of reference.
Chris Jones
www.sonigen.com

User avatar
BertKoor
KVRAF
10792 posts since 8 Mar, 2005 from Utrecht, Holland

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 9:01 am

That. Typing is never the bottleneck.

But suppose I have a list or array (well: collection) and I want to process each item. I'm gonna write some imperative pseudo-code, not a C dialect perse.

Code: Select all

for (int i=0; i++; i< list.size()) {
    doSometingWith(list[i]);
}
Why start with zero? Should it be smaller than size() or smaller-or-equal? Or was it length() instead of size()?
You see there's many small pitfalls in one simple line already.

Better write something like this:

Code: Select all

forEach (item in list) {
   doSomethingWith(item);
}
Much less brittle, no boundary cases on either end. It's obvious what's being done. It's not written like you're giving instructions to a toddler.
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is back online!!

User avatar
syntonica
KVRist
443 posts since 25 Sep, 2014 from Specific Northwest

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 9:23 am

BertKoor wrote:That. Typing is never the bottleneck.

But suppose I have a list or array (well: collection) and I want to process each item. I'm gonna write some imperative pseudo-code, not a C dialect perse.

Code: Select all

for (int i=0; i++; i< list.size()) {
    doSometingWith(list[i]);
}
Why start with zero? Should it be smaller than size() or smaller-or-equal? Or was it length() instead of size()?
You see there's many small pitfalls in one simple line already.

Better write something like this:

Code: Select all

forEach (item in list) {
   doSomethingWith(item);
}
Much less brittle, no boundary cases on either end. It's obvious what's being done. It's not written like you're giving instructions to a toddler.
Unless you need i for something... And "forEach item in list" IS writing to the lowest common denominator. Reminds me of Apple/HyperScript, made to read like common English, but a pain to use for actual programmers to use who think in 1s and 0s.

And if you don't know WHY start with zero on an iterator, well... :P :lol: But I do agree about the whole count/length/size thing. I'm talking to you, Java!

Miles1981
KVRian
1366 posts since 26 Apr, 2004 from UK

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 9:38 am

sonigen wrote:
Miles1981 wrote:
sonigen wrote:What language features have been depreciated in the last 10 years?
Everything that was deprecated due to the introduction of lambdas, auto_ptr, register, auto, export, random_shuffle...
Maybe I didn't explain what I meant properly. Adding new features isn't the same as depreciating old ones. I'm asking what features have actually been either taken out from the language or have been marked for removal at some point in the future. So for example the compiler will give you a warning or an error if you use them.
All of these. Deprecated in C++11 or C//14, removed in C++17. So if you don't understand a list:
- everything deprecated due to lambdas (std::unary_functions...)
- auto_ptr
- register
- export
- the old auto keyword
- random_shuffle
Last edited by Miles1981 on Sun Apr 15, 2018 9:41 am, edited 1 time in total.

Miles1981
KVRian
1366 posts since 26 Apr, 2004 from UK

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 9:40 am

BertKoor wrote:Better write something like this:

Code: Select all

forEach (item in list) {
   doSomethingWith(item);
}
Much less brittle, no boundary cases on either end. It's obvious what's being done. It's not written like you're giving instructions to a toddler.
Which why in modern C++, you write it like this:

Code: Select all

for (auto item: list) {
   doSomethingWith(item);
}

stratum
KVRAF
2115 posts since 29 May, 2012

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 10:44 am

Max M. wrote:
stratum wrote:This discussion makes me think that weaknesses of the education systems are best revealed in things that are hard to teach, nothing particular about C++.
(kvr trolling mode on) It's known the average human brain size fades out since ~40k b.c., so there's nothing surprising (and these days we've just built a society that no longer needs any brain at all). Luckily our generation won't be alive when things go really bad.
I wish it was just a trolling joke.

Anyway, lets not interupt the discussion further.
~stratum~

camsr
KVRAF
6890 posts since 17 Feb, 2005

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 10:56 am

Miles1981 wrote: Which why in modern C++, you write it like this:

Code: Select all

for (auto item: list) {
   doSomethingWith(item);
}
I'm not familiar with this construct, can you elaborate how it works?
Image

Z1202
KVRian
978 posts since 12 Apr, 2002

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 11:04 am

BertKoor wrote:Why start with zero? Should it be smaller than size() or smaller-or-equal? Or was it length() instead of size()?
You see there's many small pitfalls in one simple line already.
I'm sorry, I can't take this criticism seriously. It's like complaining that our grammar is inaccessibly hard: when do I put an exclamation mark? When do I put a comma? Why do I have to learn all these things?

You just learn these things once, and they shouldn't bother you anymore. Of course, if you want a language with a low learning investment, that's a different story. But these kinds of investments do pay off (if you care about the areas where they pay off, of course).

Actually I'd say C++ is easier than the language grammar, at least the Russian one. For one because there is just a small number of key elements (others you can always look up, if you have to, but that's happening for the features you rarely use, otherwise you'd have learned them already, so not much time waste). Also the compiler is going to tell you immediately, if it doesn't like your code ;)

Z1202
KVRian
978 posts since 12 Apr, 2002

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 11:06 am

Miles1981 wrote:Deprecated in C++11 or C//14, removed in C++17. So if you don't understand a list:
- everything deprecated due to lambdas (std::unary_functions...)
- auto_ptr
- register
- export
- the old auto keyword
- random_shuffle
Never used any of these ;) I don't think one _has_ to use all features of the language either ;)

camsr
KVRAF
6890 posts since 17 Feb, 2005

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 11:12 am

BertKoor wrote:

Code: Select all

for (int i=0; i++; i< list.size()) {
    doSometingWith(list[i]);
}
Why start with zero? Should it be smaller than size() or smaller-or-equal? Or was it length() instead of size()?
You see there's many small pitfalls in one simple line already.
Well, If you REALLY want to count from 1, you could do this:
(assuming list.size is an unsigned int type here)

Code: Select all

size_t local_listsize = (size_t)list.size();
size_t i = 0;
void* ptr_list = (void*)(((size_t)(&list)) - sizeof(list))

for (i=1; i++; i<=local_listsize)
{ doSomethingWith(((list*)ptr_list)[i] ); }
ptr_list is declared 1 memory offset back, the size in bytes is determined by the datatype (struct or basic).

edit for error
Last edited by camsr on Sun Apr 15, 2018 12:40 pm, edited 1 time in total.
Image

quikquak
KVRist
425 posts since 6 Aug, 2005 from England

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 11:22 am

Occasionally something appears that I like:- http://en.cppreference.com/w/cpp/memory/unique_ptr
Which is going to be replacing ScopedPointer in the JUCE code...

User avatar
Max M.
KVRist
275 posts since 20 Apr, 2005 from Moscow, Russian Federation

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 11:25 am

sonigen wrote:So you know C++ and Python? Not exactly a broad horizon.
You'd better to not use any args like this since there's always people out there who will sheet your amount of known languages down to nothing. Miles1981 may be wrong with his particular visions on specific things and weird language knowledge, but he is known to be valuable to the community - and you are not. EoD (as anything he writes is times more profound than what you do).
Last edited by Max M. on Sun Apr 15, 2018 12:00 pm, edited 1 time in total.

quikquak
KVRist
425 posts since 6 Aug, 2005 from England

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 11:45 am

Max M. wrote:
sonigen wrote:So you know C++ and Python? Not exactly a broad horizon.
You'd better to not use any args like this since there's always people out there who will sheet your amount of known languages down to nothing. Miles1981 may be wrong with his particular visions on specific things and weird language knowledge, but he is known to be valuable to the community - and you are not. EoD.
I couldn't give a flying truck what people code in as long as they don't love the language more than what they're supposed to be doing with it. Once that happens, you're doomed!

camsr
KVRAF
6890 posts since 17 Feb, 2005

Re: "Does C++ Have a Future?"

Post Sun Apr 15, 2018 12:43 pm

BertKoor wrote:

Code: Select all

for (int i=0; i++; i< list.size()) {
    doSometingWith(list[i]);
}
Why start with zero? Should it be smaller than size() or smaller-or-equal? Or was it length() instead of size()?
You see there's many small pitfalls in one simple line already.
There is also this very simple way:

Code: Select all

for (int i=1; i++; i<= list.size())
{ doSometingWith(list[i-1]); }
Which, the compiler WILL reduce to simply counting from (or to) 0.
Image

Return to “DSP and Plug-in Development”