www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Someone should tell him about D...

reply twinbee <twinbee42 skytopia.com> writes:
Quote from Elon Musk on Twitter:

"Side note: I hate the bloated mess that is modern C++, but love 
simple C, as you know what it will compile to in terms of actual 
CPU operations."

Source: https://twitter.com/elonmusk/status/1532274289893904384
Jun 02 2022
next sibling parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Thursday, 2 June 2022 at 10:36:24 UTC, twinbee wrote:
 Quote from Elon Musk on Twitter:

 "Side note: I hate the bloated mess that is modern C++, but 
 love simple C, as you know what it will compile to in terms of 
 actual CPU operations."

 Source: https://twitter.com/elonmusk/status/1532274289893904384
Makes no sense. Clang is the same compiler for C and C++…
Jun 02 2022
parent Paulo Pinto <pjmlp progtools.org> writes:
On Thursday, 2 June 2022 at 10:43:40 UTC, Ola Fosheim Grøstad 
wrote:
 On Thursday, 2 June 2022 at 10:36:24 UTC, twinbee wrote:
 Quote from Elon Musk on Twitter:

 "Side note: I hate the bloated mess that is modern C++, but 
 love simple C, as you know what it will compile to in terms of 
 actual CPU operations."

 Source: https://twitter.com/elonmusk/status/1532274289893904384
Makes no sense. Clang is the same compiler for C and C++…
Back in the early days of C vs C++ flamewars, there were these geek t-shirts, "my compiler compiles yours" from C folks. I guess we need an updated version of them.
Jun 02 2022
prev sibling next sibling parent reply forkit <forkit gmail.com> writes:
On Thursday, 2 June 2022 at 10:36:24 UTC, twinbee wrote:

Well, you know what they say:

"The weakness of the C language comes from its strength"
Jun 02 2022
parent reply Araq <rumpf_a web.de> writes:
On Thursday, 2 June 2022 at 11:51:30 UTC, forkit wrote:
 On Thursday, 2 June 2022 at 10:36:24 UTC, twinbee wrote:

 Well, you know what they say:

 "The weakness of the C language comes from its strength"
Assembly instruction `mov rcx, [rax]`. Cost: 1 cycle. Or 500. It's not 1980 anymore, there is hardly a benefit in looking at the assembler, you need to measure things. Musk is surprisingly bad at working from "first principles" sometimes.
Jun 02 2022
parent max haughton <maxhaton gmail.com> writes:
On Thursday, 2 June 2022 at 13:38:27 UTC, Araq wrote:
 On Thursday, 2 June 2022 at 11:51:30 UTC, forkit wrote:
 On Thursday, 2 June 2022 at 10:36:24 UTC, twinbee wrote:

 Well, you know what they say:

 "The weakness of the C language comes from its strength"
Assembly instruction `mov rcx, [rax]`. Cost: 1 cycle. Or 500. It's not 1980 anymore, there is hardly a benefit in looking at the assembler, you need to measure things. Musk is surprisingly bad at working from "first principles" sometimes.
Can even be zero on Zen3 with the stack to register file optimization.
Jun 02 2022
prev sibling next sibling parent reply Guillaume Piolat <first.last gmail.com> writes:
On Thursday, 2 June 2022 at 10:36:24 UTC, twinbee wrote:
 Quote from Elon Musk on Twitter:

 "Side note: I hate the bloated mess that is modern C++, but 
 love simple C, as you know what it will compile to in terms of 
 actual CPU operations."
Sometimes it feels like people with a conservative bias live in a world where only "established" languages and brands exist. https://en.wikipedia.org/wiki/Scurvy#History
Jun 02 2022
parent reply monkyyy <crazymonkyyy gmail.com> writes:
On Thursday, 2 June 2022 at 14:24:00 UTC, Guillaume Piolat wrote:
 Sometimes it feels like people with a conservative bias live in 
 a world where only "established" languages and brands exist.
Sometimes it feels like people with a commie bias live in a world where all the established languages will be trivially replaced by the next thing they think up
Jun 02 2022
parent "H. S. Teoh" <hsteoh qfbox.info> writes:
On Thu, Jun 02, 2022 at 04:45:04PM +0000, monkyyy via Digitalmars-d wrote:
 On Thursday, 2 June 2022 at 14:24:00 UTC, Guillaume Piolat wrote:
 Sometimes it feels like people with a conservative bias live in a
 world where only "established" languages and brands exist.
Sometimes it feels like people with a commie bias live in a world where all the established languages will be trivially replaced by the next thing they think up
+1, LOL. :-D T -- It won't be covered in the book. The source code has to be useful for something, after all. -- Larry Wall
Jun 02 2022
prev sibling next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 02.06.22 12:36, twinbee wrote:
 Quote from Elon Musk on Twitter:
 
 "Side note: I hate the bloated mess that is modern C++, but love simple 
 C, as you know what it will compile to in terms of actual CPU operations."
 
 Source: https://twitter.com/elonmusk/status/1532274289893904384
Truth. In terms of actual CPU operations, it will compile to an arbitrary code execution exploit. The point about C++ is valid too.
Jun 02 2022
prev sibling parent reply IGotD- <nise nise.com> writes:
On Thursday, 2 June 2022 at 10:36:24 UTC, twinbee wrote:
 Quote from Elon Musk on Twitter:

 "Side note: I hate the bloated mess that is modern C++, but 
 love simple C, as you know what it will compile to in terms of 
 actual CPU operations."

 Source: https://twitter.com/elonmusk/status/1532274289893904384
While I can understand the frustration of modern C++, the right tool for the right job is more important. Try doing string manipulation with the C standard library, in that case I would pick C++ over C any day. C is not always simpler.
Jun 02 2022
next sibling parent Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Thursday, 2 June 2022 at 17:00:35 UTC, IGotD- wrote:
 While I can understand the frustration of modern C++, the right 
 tool for the right job is more important. Try doing string 
 manipulation with the C standard library, in that case I would 
 pick C++ over C any day. C is not always simpler.
Yeah, well, modern C++ doesn't add anything that affects performance bottle necks in a negative way. Sounds like he has talked with someone that has started coding before they knew what the requirements should be. C++ does not support evolutionary development… you have to know what you are going to do before you start coding.
Jun 02 2022
prev sibling parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
On Thu, Jun 02, 2022 at 05:00:35PM +0000, IGotD- via Digitalmars-d wrote:
 On Thursday, 2 June 2022 at 10:36:24 UTC, twinbee wrote:
 Quote from Elon Musk on Twitter:
 
 "Side note: I hate the bloated mess that is modern C++, but love
 simple C, as you know what it will compile to in terms of actual CPU
 operations."
 
 Source: https://twitter.com/elonmusk/status/1532274289893904384
While I can understand the frustration of modern C++, the right tool for the right job is more important. Try doing string manipulation with the C standard library, in that case I would pick C++ over C any day. C is not always simpler.
C++? And string manipulation? In the same sentence?? You make me cringe. :-/ (Now, if it was *D* and string manipulation in the same sentence, it would be a different story. ;-)) T -- Computers aren't intelligent; they only think they are.
Jun 02 2022
parent reply IGotD- <nise nise.com> writes:
On Thursday, 2 June 2022 at 17:26:43 UTC, H. S. Teoh wrote:
 C++?  And string manipulation?  In the same sentence??

 You make me cringe. :-/

 (Now, if it was *D* and string manipulation in the same 
 sentence, it
 would be a different story. ;-))


 T
I know it's a bit strange because C++ is actually much better than C (not even mentioning the security hazards). That's why I like D because in this case it's much better than C++.
Jun 02 2022
parent reply monkyyy <crazymonkyyy gmail.com> writes:
On Thursday, 2 June 2022 at 17:42:42 UTC, IGotD- wrote:
 I know it's a bit strange because C++ is actually much better 
 than C (not even mentioning the security hazards). That's why I 
 like D because in this case it's much better than C++.
? Isnt c++ extremely slow? Like c++ adopts every feature and like thats .... fine; but it can never be good
Jun 03 2022
next sibling parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Friday, 3 June 2022 at 19:24:03 UTC, monkyyy wrote:
 Isnt c++ extremely slow? Like c++ adopts every feature and like 
 thats .... fine; but it can never be good
No, C++ is similar to C in performance, in theory C++ could do better than C because of stricter typing, but I don’t think compilers exploit that. It would break existing code... Most new C++ features are either syntax sugar or library additions, relatively few new features. Although stackless coroutines is a major recent one.
Jun 03 2022
parent reply monkyyy <crazymonkyyy gmail.com> writes:
On Friday, 3 June 2022 at 19:55:48 UTC, Ola Fosheim Grøstad wrote:
 On Friday, 3 June 2022 at 19:24:03 UTC, monkyyy wrote:
 Isnt c++ extremely slow? Like c++ adopts every feature and 
 like thats .... fine; but it can never be good
No, C++ is similar to C in performance, in theory C++ could do better than C because of stricter typing, but I don’t think compilers exploit that. It would break existing code... Most new C++ features are either syntax sugar or library additions, relatively few new features. Although stackless coroutines is a major recent one.
I meant compile speeds, adopting every feature will make a slow compiler and I dont want to spend an hour waiting
Jun 03 2022
parent Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Friday, 3 June 2022 at 20:04:37 UTC, monkyyy wrote:
 I meant compile speeds, adopting every feature will make a slow 
 compiler and I dont want to spend an hour waiting
If you write you own libraries and break dependencies then you can get decent compilation speeds, but many existing code bases #include way too much leading to many pointless dependencies and slower builds.
Jun 03 2022
prev sibling parent reply IGotD- <nise nise.com> writes:
On Friday, 3 June 2022 at 19:24:03 UTC, monkyyy wrote:
 On Thursday, 2 June 2022 at 17:42:42 UTC, IGotD- wrote:
 I know it's a bit strange because C++ is actually much better 
 than C (not even mentioning the security hazards). That's why 
 I like D because in this case it's much better than C++.
? Isnt c++ extremely slow? Like c++ adopts every feature and like thats .... fine; but it can never be good
When it comes to strings? Depends what you are doing and how you are doing it. C++ made a strange decision to include the null terminator at the end of the strings even if it isn't really necessary. The result is that you cannot slice strings and can lead to unnecessary deep copies. In order avoid this C++ invented string_view and associated literals. Now you suddenly have two types of strings and if you make an API you might have to support both string and string_view. This is one of the crazy things with "modern C++". Still it is more user friendly than the old C library strings which also are prone to buffer overflows. D in this case did the right choice not including the null terminator so that you can slice strings all you want and no extra string view.
Jun 03 2022
next sibling parent reply monkyyy <crazymonkyyy gmail.com> writes:
On Friday, 3 June 2022 at 20:12:01 UTC, IGotD- wrote:
 On Friday, 3 June 2022 at 19:24:03 UTC, monkyyy wrote:
 On Thursday, 2 June 2022 at 17:42:42 UTC, IGotD- wrote:
 ****I know it's a bit strange because C++ is actually much 
 better than C****
?
When it comes to strings?
no, c > c++ in general because the sanest way to use c++ is as c + one or two features and c++ will be extremely slow to compile and iterate on. C is an extremely high bar, c++ "spread itself to thin", "has to many cooks", "jack of all trades, master of none"
Jun 03 2022
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 6/3/22 13:24, monkyyy wrote:

 no, c > c++ in general because the sanest way to use c++ is as c + one
 or two features
My short list to pick C++ and never touch C: - Constructor, destructor, etc. - Templates
 and c++ will be extremely slow to compile and iterate on.
C++ compilation speed is one thing that shows me humans can adapt to any situation and can accept anything. An example: 64-way parallel compilation on 20+ cores and the project builds in 2 hours. :/ Ali
Jun 03 2022
prev sibling parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 6/3/22 4:12 PM, IGotD- wrote:

 When it comes to strings? Depends what you are doing and how you are 
 doing it. C++ made a strange decision to include the null terminator at 
 the end of the strings even if it isn't really necessary. The result is 
 that you cannot slice strings and can lead to unnecessary deep copies. 
 In order avoid this C++ invented string_view and associated literals. 
 Now you suddenly have two types of strings and if you make an API you 
 might have to support both string and string_view. This is one of the 
 crazy things with "modern C++". Still it is more user friendly than the 
 old C library strings which also are prone to buffer overflows.
 
 D in this case did the right choice not including the null terminator so 
 that you can slice strings all you want and no extra string view.
D almost had 2 types for arrays, one that would allow resizing and another that would just be a slice. The point was to solve the stomping problem. But we fixed it a different way. Feast your eyes! https://forum.dlang.org/post/h5nbj3$17is$1 digitalmars.com -Steve
Jun 03 2022