# What's the relationship between C and C++?

**URL:** <https://boards.straightdope.com/t/whats-the-relationship-between-c-and-c/950446>\
**Category:** Factual Questions\
**Created:** [September 10, 2021, 10:58am UTC](https://boards.straightdope.com/t/whats-the-relationship-between-c-and-c/950446 "2021-09-10T10:58:48Z")\
**Posts on this page:** 1\
**Showing post:** 43

<div class="post-metadata">

**Author:** ![Stranger\_On\_A\_Train](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stranger\_On\_A\_Train](https://boards.straightdope.com/u/Stranger_On_A_Train)\
**Post date:** [September 10, 2021, 7:55pm UTC](https://boards.straightdope.com/t/whats-the-relationship-between-c-and-c/950446/43 "2021-09-10T19:55:50Z")

</div>

> [@Sam\_Stone](#):
>
> I completely disagree with that. Object oriented design works well at every scale. I just did a little micronctroller project in C++ for an LED lamp, and I certainly could have just written a big file with a bunch of functions. But it was just better to build objects and interfaces for the lamp, the effects, the commands, etc. It’s easily extensible, very understandable and maintainable.

Sure, you can use OOP at any scale, but the question is whether you really need to or are getting any real advantage from doing so. Making objects and associate methods with abstracted interfaces makes it easier to add functionality than “a big file with functions”, but I’m guessing your line count of actual operational code is probably in the few tens which anyone could sit down and work through in a half an hour unless you’ve actually made the effort to obfuscate the code, so the time you save in extensibility is probably a wash for the extra overhead. And frankly, unless you are careful about how you apply OOP principles and document interfaces it can end up being much harder for another programmer to understand, which is fundamentally my complaint about casual and reflexive use of OOP.

There are, of course, other reasons to use OOP, particularly if you want to use abstraction to make your code reusable. As an example, I wrote a Python library to do signal processing and cohort statistics for dynamic environments from accelerometer time history data, but I used a class factory so a user could come along and inherit the base signal class and then add methods and properties to do different things with time history data from pressure transducers, thermocouples, stain gauges, et cetera and the be able to use the same cohort stat methods to generate summary statistics. In that case, it was worth the extra overhead because I can use it to handle and manipulate any time history data, and modifying the class factory (which actually has its own set of abstract interfaces) is trivial. In fact, the class factory is designed to be actually import parameters and predefined methods from an external spreadsheet (as well as the predefined classes in the module) so unless the user needs some kind of visualization or processing methods that aren’t available in the module they can actually generate a whole new class type without doing any programming at all. Unfortunately, I have not been able to wean users away from their bag o’ functions Matlab scripting and into Python, but that is another issue.

Anyway, someone who is experienced and conversant can write good OOP code probably about as fast as functional code, but a lot of OOP code is not well thought out or provides any real utility at the cost of making the project harder to understand or reuse instead of easier, which is my main gripe about ‘needing’ to use OOP. In other words, if you can’t think of a compelling benefit to use OOP design in your project, you probably either don’t need it or don’t understand OOP well enough to apply it correctly.

> [@GreenWyvern](#):
>
> I just did a test to find the smallest Object Pascal (Free Pascal) program I could write.
> 
> Here it is in its entirety:
> 
> ```auto
> program HelloWorld;
> 
> begin
> WriteLn('Hello world!');
> end.                     
> 
> ```
> 
> It compiles and runs!

There is nothing about that program that is object oriented, or even functional since it is really just a single imperative statement in the main body.

> [@DMC](#):
>
> Perhaps you might like something like [Julia](https://julialang.org/). It doesn’t have quite the ecosystem of Python, but it’s definitely gaining ground in some Python-centric verticals.

I’ve been trying to find an excuse to use Julia for something because I would really like to learn it but I’m honestly hard pressed at this point to come up with any data analysis and visualization that I can’t just as easily do in Python with NumPy and SciPy, and the milliseconds I might gain in additional performance would be lost in time spent learning Julia and having to interface with existing Python libraries for functionality not directly available in Julia modules. Maybe when I start writing that astro code that has been sitting in my personal ToDo pile for the last decade…

> [@abcdefghij](#):
>
> C++ is too ugly to be a Ferrari. Also, a Ferrari isn’t actively trying to kill you.

C is a [Piper Cub](https://aerocorner.com/aircraft/piper-j-3-cub/). C++ is a [Caproni Noviplano](http://www.aviastar.org/air/italy/caproni_ca-60.php).

Stranger

---

_[View the full topic](https://boards.straightdope.com/t/whats-the-relationship-between-c-and-c/950446)._
