Hacker News new | past | comments | ask | show | jobs | submit login

You can write C++ code that works like an equivalent C program, but that code also looks like the equivalent C program -- only with slightly less modern syntax.

Writing good, modern C++ means using the external template libraries and all kinds of (relatively) heavyweight goodies. The trouble is it's difficult to predict the space cost of those goodies -- so on systems where that matters it's just easier to think in terms of C.




Regardless of if you're coding in C or C++ for micros, you're not going to be using much, if any, of the standard library anyways. You'll probably be rolling your own routines for a lot of stuff because so many libraries, even those for micros, are rather oversized for when you're truly constrained.

I've used templates in C++ libraries for the purposes of varying memory constraints and mcu capabilities. Being able to write a library once and deploy it on 8 bit and 32 bit chips without FPUs and chips with fpus means saving a lot of time, and it writes code that's just as efficient. Finally, a lot of C/C++ compilers for small devices have routines to give a pretty good guess as to how much RAM your code's going to need, so you can figure out ahead of time if a routine is really worth it.


You can use templates and objects at practically 0 cost, and significant abstractions can be built with these mechanisms. Presumably, this is a night and day difference for some people.


Last I checked C didn't even have overloaded functions. I'd choose "no fancy features" C++ over C any day.


It's certainly the case that you can make use of C++ features sparingly and get the benefits of both C and C++; but I think the notion that "good, modern C++" is somehow supposed to be highly abstract and thus bloated up unnecessarily, is in itself problematic.

My original comment was more about the fact that despite using C++ and Java exampees, this book is quite strongly lacking any advice in the "use templates and other abstractions sparingly" direction.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: