The C Family Tree
Published: 2024-06-10 06:07:45

> [Image by Tomasz Steifer, Gdansk from Wikimedia](https://commons.wikimedia.org/wiki/File:Family_tree_test1.jpg)

## **Family Roll Call!**
Someday, I'd love to make simple video games as a hobby.  When this came up in conversation, I was informed that quite a lot of games are coded in C.  I'd heard of multiple C languages and started wondering how they were related to each other. 

My research began with finding which languages are actually part of the ‘C’ family.  I’d assumed it was a fairly small group and that they’d all have ‘C’ as the first letter in their names, like C++ & C#.  Turns out this is not the case, this family is quite large and varied!
But for now, I will be investigating just a few of the ones that matched my previous assumptions.

---

## **The Parent**
Let’s start with C, the Eldest of this branch of the alphabet family.  It is a general purpose programming language that was created near the start of the 1970s by Mr. Dennis M. Ritchie.  Who was a computer scientist at the company formerly known as AT&T Bell Laboratories.

Mr. Ritchie created ‘C’ for the purpose of writing operating systems for microcomputers, specifically for rewriting the Unix operating system. 
Unix was being rewritten because the assembly language it was originally created in had limitations that needed to be surpassed.  Such as it not being portable to other architectures, so you couldn’t adapt it to work on other hardware.

While I didn’t find an Official documentation website dedicated to C, 
I did learn that the [C Standards Committee](https://www.open-std.org/jtc1/sc22/wg14/) is in charge of maintaining the International Standard of C.  You can find links on their website for purchasing updated C reference materials.
I also saw several mentioning's of this book:  ‘The C Programming Language’.   Which was published in 1978 and co-authored by Brian Kernighan and Dennis M. Ritchie, the language's creator.  This book was considered by many to be “the authoritative reference on C” ([Wikipedia](https://en.wikipedia.org/wiki/The_C_Programming_Language)). 

Now for a look at some C syntax examples.
When declaring variables in C, you must first list the data TYPE before your variable name and value.  So creating a variable for my pets age would be:
```Int bunAge = 7;```
Where “int” stands for an integer (whole number).
If I wanted to store just the first letter of his name, I would use:
```char bunFirst = ‘P’;```
“Char” stands for ‘character’ and is used for storing only a single character.  Your 1 letter must also be between a pair of single quotes.
I'd rather keep his entire name on record in a string, but C doesn’t have a string type.  So to create one, you must write:
```char bunName[] = “Pippington”;```
You use char with [] to create an array of single characters.  Your value for this must be stored between double quotes.

Functions are declared in a similar way in that you must preface it with the name of the data type that will be _returned_.
Here is a function that will declare & return my pets age.

``` 
Int returnBunAge() {
Int bunAge = 7;
return bunAge
} 
```

---

## **The Child** 
C++, also referred to as CPP or C plus plus, is a direct descendant of C.  This language was ‘born’ in the early 1980s and was the brainchild of Bjarne Stroustrup, a Danish computer scientist who also worked for AT&T Bell Labs.  It was originally named “C with Classes”  in reference to the fact that it was an extension of C, but with the ability to create and manipulate Classes.  The name was changed to C++ in 1983, using the ‘++’ increment operator to infer that it was C but ENHANCED.

As previously mentioned, C++ was started as C with the added functionality of Classes.  Stroustrup’s motivation for adding classes and more to C was inspired by his research of the Simula programming language.  An object oriented programming language that was designed for running a variety of simulations. However, it was too slow to be useful for Stroustrup’s needs. So he began C++ in order to beef up the much speedier C with Siumla-inspired features.

Unlike the parent, C++ has an Official website that houses documentation: [isoCPP](https://isocpp.org/).  In addition to the languages documentation, it also lists information about relevant events, the status of the language, books & other online resources that will help you learn the language.  
Mr. Stroustrup is not only involved in maintaining the isoCPP website, but he also has his own site with C++ information: [Stroustrup] (https://www.stroustrup.com/C++.html).  

Now to check out some syntax examples & compare them.
Variable declaration in C++ works almost exactly the same as C’s where you must first specify the type the variable will be.
However, C++ has inherited and changed the C keyword, ‘auto’ to use with variables.
In C, auto was used when specifying the storage duration and linkage of objects and functions.
C++ uses auto to _automatically_  deduce the type of the declared variable. Meaning that C++ knows that this is an integer:
```auto bunAge = 5```
 
C++ also has the string data type!  You no longer need to combine char with an array, you can simply use:
```string bunName = “Pippington”```
Or auto to _automatically_  deduce the data type as a string.

Functions are also defined & declared the same way, but C++ has added the ability of function overloading.  Which refers to writing functions with the same names but different parameters.
So say I want to write a function that returns the sum of how much I spend on pet supplies.  Some of the items total cost is a whole number (integer), but some involve change, and so have decimals (A ‘double’, which refers to floating point numbers).  
So instead of having to give my 2 addition functions completely different names, like this:
```
int totalPriceInt(int a, int b) { return a + b; }
double totalPriceDouble(double a, double b) { return a + b; }

int wholeTotal = totalPriceInt(13, 9);
double floatTotal = totalPriceDouble(3.4, 8.12);

```
I can give them the same name and when used they will know what to return based on inputs and the type listed in the function call:
```
int totalPrice(int a, int b) { return a + b; }
double totalPrice(double a, double b) { return a + b; }

Int wholeTotal = totalPrice(13, 9);
double floatTotal = totalPrice(3.4, 8.12);

```

---

## **The Grandchild** 
C#, pronounced C-Sharp, was created in 2000 by Anders Hejlsberg, a lead architect at Microsoft, and released as an international standard in 2002.  While not _truly_ descendant of C++, C#’s design was heavily influenced by it.  It’s name was repurposed from an incomplete project that _was_ meant to be a variant of the C language.  The # symbol chosen because it resembles four ‘+’, implying it to be an enhancement of C++.

C-Sharp was created for Microsoft to work with its .NET Framework.  An extensive collection of libraries, frameworks, and tools for building applications for Windows, and later other platforms.  They wanted a simple and clean object-oriented language that worked well with .Net and Visual Studio, which were once internal use only.  However, they have since been released as free, open source resources. 

Official C# documentation can be found on Microsoft's website, along with information on how to use it with .NET and Visual Studio Code.  Like the isoCP site, they also keep thorough updated information and many tutorials for learning C#.  they also have a Discord channel and community forums.

And now, let’s compare the syntax to its ancestors.
C# appears to create variables in the exact same manner as C++.
But instead of using ‘auto’ to automatically deduce the data type, C# uses ‘var’.  

C# has Functions, but they are referred to as Methods in this language and always defined inside of Classes.

---

## **Conclusion**
Each generation of this particular branch has interesting changes and improvements. It was fun trying to hunt down the similarities and differences between them.  Someday I hope to have the time to research more C family members and their many branches.
As well as familiarize myself better with these languages.


## **Resources**
- [List of C-family programming languages](https://en.wikipedia.org/wiki/List_of_C-family_programming_languages)
- [Britannica](https://www.britannica.com/technology/C-computer-programming-language)
- [Wikipedia](https://en.wikipedia.org/wiki/C_(programming_language))
- [Bell Labs](https://www.bell-labs.com/usr/dmr/www/chist.html)
- [Dev Docs](https://devdocs.io/c/)
- [TLDP](https://tldp.org/HOWTO/Assembly-HOWTO/x133.html)
- [Simula - Wikipedia](https://en.wikipedia.org/wiki/Simula)
- [Stroustrup](https://www.stroustrup.com/C++.html)
- [isoCPP](https://isocpp.org/)
- [Free Code Camp](https://csharp-station.com/understanding-the-differences-between-c-c-and-c/ )
- [CSharp Station](https://csharp-station.com/understanding-the-differences-between-c-c-and-c/ )
- [SimpliLearn](https://www.simplilearn.com/tutorials/cpp-tutorial/c-sharp-vs-cpp )
- [Geeks For Geeks](https://www.geeksforgeeks.org/c-vs-c-sharp/ )
- [C# - Microsoft](https://learn.microsoft.com/en-us/dotnet/csharp/)