<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MrAureliusR</title>
    <description>The latest articles on DEV Community by MrAureliusR (@mraureliusr).</description>
    <link>https://dev.to/mraureliusr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F348786%2F66c3a71e-3d8b-4ba1-927e-a3953916345b.png</url>
      <title>DEV Community: MrAureliusR</title>
      <link>https://dev.to/mraureliusr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mraureliusr"/>
    <language>en</language>
    <item>
      <title>Pushing myself to C++</title>
      <dc:creator>MrAureliusR</dc:creator>
      <pubDate>Tue, 10 Mar 2020 18:31:32 +0000</pubDate>
      <link>https://dev.to/mraureliusr/pushing-myself-to-c-al</link>
      <guid>https://dev.to/mraureliusr/pushing-myself-to-c-al</guid>
      <description>&lt;p&gt;I have been developing and designing embedded devices for quite a few years now. I started out using C exclusively, then started mixing in assembly (which I still love!). For quite a long time, I was one of those grumblers complaining about object oriented stuff not belonging on embedded hardware. (I still have yet to be convinced that CircuitPython or Rust on microcontrollers is a good idea, but that's another story altogether).&lt;/p&gt;

&lt;p&gt;But then a friend of mine wrote and published a book targeted pretty much directly at developers like me -- &lt;a href="https://www.amazon.ca/Hands-Embedded-Programming-versatile-solutions/dp/1788629302"&gt;Hands-On Embedded Programming with C++17&lt;/a&gt;. I started reading it, and decided what the heck, I'll give it a try. (Maya is a great writer, by the way!) So I created a new folder in my ~/workspace folder (which is a big commitment) and created a simple C++ program for the AVR ATmega328p. I chose that processor because I have about a thousand random Arduino clones laying around, and about a hundred AVR programmer clones also, making it very easy to use a quick and dirty dev platform.&lt;/p&gt;

&lt;p&gt;I created a (gasp) &lt;em&gt;class&lt;/em&gt; for the peripheral I was using! I even made a (shock and horror) &lt;em&gt;constructor function&lt;/em&gt; for that class! Typedef structs full of function pointers, this is not. Though I still struggle with understanding some of the more advanced OOP concepts, and though I still fall back to C and/or assembly when I need to get something done fast, I've been forcing myself to use C++ more and more for my personal hacking projects.&lt;/p&gt;

&lt;p&gt;I must say, from an organizational point of view, having abstraction for peripherals in a microcontroller is very appealing to me. The classic C way of doing the same task is to create a separate .c and .h file for each peripheral, and then create a struct type with the important functions and variables that the peripheral needs. This has some obvious downsides -- primarily the fact that people seem to panic whenever function pointers are mentioned, but also that managing multiple instances of that struct type can be costly and complex, especially if it's implemented as an API for others to use.&lt;/p&gt;

&lt;p&gt;I'm still working my way into things like inheritance and operator overloading, which seem very neat as well. What I am worried about, however, is my ability to quickly prototype new things. I find that it takes me longer to write the equivalent C++ code, though this is likely just due to being less familiar with the language features, and may disappear over time. But to get to that level of familiarity, I need to force myself to use C++ in my personal projects, which again can be difficult if I just want to get something done.&lt;/p&gt;

&lt;p&gt;I would love to hear about other embedded developers who have transitioned to using C++ from C, and whether their initial attempts looked like C++ code that got in a trainwreck with a C codebase.&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>c</category>
      <category>embedded</category>
    </item>
  </channel>
</rss>
