On Monday, 10 July 2017 at 21:30:44 UTC, Walter Bright wrote:
You can't use RTTI or Exceptions, for example. Those generate bloat even if they are not used - a compiler switch is typical to disable them. It's not true that C++ is "pay only for what you use".

If the C++ usage is "C with member functions", then yes, it'll work and be useful.

Sure, people don't use exceptions and RTTI and other expensive things on microcontrollers. But, as you say, they use it for less expensive or zero cost things like member functions, operator overloading, templates (not very common, but I've seen some interesting 0-cost wrappers that increased the safety of setting registers), etc. But I'm not here to advocate C++, I've only used it incidentally for microcontrollers (AVR, the Arduino libraries are C++, urg).

For example, ints in C are 16 bits. In D they are 32. This means that integer operations are expensive.

I don't understand this point of view. You are literally saying that writing "int x" is more expensive in D than in 16-bit C because they mean something different. Uhh, so just write "short x" in D? That's the equivalent code. Why would you write code that's character-by-character the same but means a different machine type?

If that's because short is more inconvenient in D than in C, I can understand that! But C also has a lot of annoying limitations, I feel that overall it's still a win.

If you give me more concrete examples I can try to address them. Just keep in mind that it's still fairly low level D code. I'm not throwing new Exceptions! But you can use modules, static ifs, templates... Modules alone sometimes feel like enough benefit...

Reply via email to