Is C++ good for pic micros,,?

LesJones

Joined Jan 8, 2017
4,511
Hi Dave,
Here is a link to a Raspberry Pi publication on basic "C" programming. I used it to help write a program to log data sent as text via HC-12 modules from remote sensors (Temperature, humidity, voltage and current.). The data from the sensors was converted to text messages using a PIC12F1840. (That was the easy part as it was written in assembler.) Like you I find assembler much easier to understand than "C"

Les.
 

MrSoftware

Joined Oct 29, 2013
2,273
There is nothing wrong with C++, I've used it on small chips from arduino (atmega 328p, 8-bit) to beefier chips like several of Nordic's nrf5x series offerings. Saying C++ is too big and complicated so don't use it, is like saying the USA is too big a country to visit so never take a trip there. You don't have to use every feature of C++, just like you don't have to visit every street in the USA. C++ is a superset of C, only use the features that make sense for what you're doing. Also compiler settings can make a big difference. For example you can set the compiler to build binaries focused on speed of execution, though sometimes at the expensive of size. Or for smallest size, though sometimes at the expense of speed. Etc.. Surely there are cases where assembly makes more sense, but likewise there are plenty of cases where C or C++ can make your life a lot easier. For the last 20 years I've worked mostly in software, and mostly with C and C++, and this is my perspective.
 

nsaspook

Joined Aug 27, 2009
16,330
There is nothing wrong with C++, I've used it on small chips from arduino (atmega 328p, 8-bit) to beefier chips like several of Nordic's nrf5x series offerings. Saying C++ is too big and complicated so don't use it, is like saying the USA is too big a country to visit so never take a trip there. You don't have to use every feature of C++, just like you don't have to visit every street in the USA. C++ is a superset of C, only use the features that make sense for what you're doing. Also compiler settings can make a big difference. For example you can set the compiler to build binaries focused on speed of execution, though sometimes at the expensive of size. Or for smallest size, though sometimes at the expense of speed. Etc.. Surely there are cases where assembly makes more sense, but likewise there are plenty of cases where C or C++ can make your life a lot easier. For the last 20 years I've worked mostly in software, and mostly with C and C++, and this is my perspective.
For the software end of the street I agree but the difference between a good C embedded programmer and good C++ programmer is using the C++ programming features and C++ OOP style to the best possible extent to catch errors at compile time. For small embedded becoming a good C programmer is a natural progression for hardware directed applications that don't need generalization of objects because it's basically a one and done. A subset of C++ provides little for no advantage in the end product that runs indefinably over C with classes for OOP abstractions and you can do that directly with C or assembly.
 
Last edited:
Top