Iris Classon
Iris Classon - In Love with Code

Stupid Question 115: What is the connection between C, C++, objective C and C#?

[To celebrate my first year of programming I will ask a ‘stupid’ questions daily on my blog for a year, to make sure I learn at least 365 new things during my second year as a developer]

Is there a connection between C, C++, objective C and C#?

Just a quick rundown:

C comes first, in 1969. It’s an imperative language / procedural language.

C++ comes about in 1979. At first called C with classes it implies what it is, it adds quite a few things to C – for example object oriented features. C++ is basically an enhancement to C in the beginning, until the features are so many and covering that the language stands on its own.

Objective C was born in 1983 and it extends C – many of the new features are SmallTalk inspired, and object oriented.

C# is not based on C, but inspired by C (big difference) and came about in 2001 as the newest kid on the block. At first the name of the language was COOL – which stood for C-like Object Oriented Language. The intention was to create a language that was object oriented, was C-like, but without the flaws found in the current major programming languages.

Comments

Leave a comment below, or by email.
Joel Lucsy
12/29/2012 3:06:45 PM
Er, you may want to check your dates. You say first C in 69, then C++ in 63. 
Iris Classon
12/29/2012 3:09:55 PM
Reply to: Joel Lucsy
Thanks, changed that LOL - it's getting late :) 
Jak
12/29/2012 3:56:45 PM
Having programmed in all four languages I find it easier to think of C# and Objective-C as completely standalone languages, with C++ acting as an 'upgraded' C (object oriented and such). Objective-C is a 'strict superset' of C but in most cases, projects in Obj-C use the functions that are unique to the language, rather that the C frameworks/libraries. As for C#, there isn't much C left in it - and, if you needed to program in C in a C# environment, chances are, you will just program in C rather. As for C++ and C, I believe their main similarity comes from the fact that C++ is extremely versatile - and, when used procedurally, resembles C-type coding quite a lot. 
Johan Sundström
1/3/2013 6:03:53 AM
Hi,

comparing C# with other C-like languages without bringing in Java is not entirely fair in my opinion. In reality the C# has adopted a lot of the good stuff from the Java platform (it has also omitted some of the worst stuff). BTW Java is also a C-like language. 

Whereas C, C++ and Objective-C programs runs as native binaries both C# and Java execute in a managed environment. Both in C# and in Java you have useful abstractions that are not immediately available in native languages (for instance garbage collection) - that does not make the language syntax and semantics so different per se, but the usage patterns for the languages can be quite different.  

Cheers,

Johan 
Andy Dent
1/6/2013 8:28:08 AM
Another way to look at this is "how do people think in these languages"?

C - fundamentally procedural. Advanced idiomatic C tends to use structures of functions for indirection, much like the operating system vectoring of calls that I learned in the mid-80's (VAX/VMS).

Objective-C is a far more dynamic language than non-users realise. It's idiomatic C at the function level but the dominant style is very much from Smalltalk. Smalltalk was an object-oriented message passing language, not a class-oriented language. Objects in Smalltalk can actually change type, although that's not common in Objective-C. 

C++ started out as a language for class-oriented OO but morphed along the way with the introduction of templates so is a very multi-paradigm language. It's not dynamic like Objective-C and some of the things it  allows are unlike any of the other OO languages. In particular, the use of templates allows for thinking and writing in abstractions but compiling down to very efficient code that has very little runtime binding and is hence predictable. This is more so than the idiomatic C using function pointers! You can write very high-level, abstract stuff in C++ without it being at all OO.

C# has been evolving towards being a multi-paradigm language since v4 with the interesting growth of declarative logic (LINQ) and more functional features for applying operations to collections. It's class-oriented OO to the core. However, the "dynamic" data type is an interesting escape mechanism. 
Tanj
4/30/2014 2:22:02 PM
Reply to: Johan Sundström
Managed vs. Native is a false dichotomy, they are different dimensions.  C# compiles to native code (there were a few interpretive implementations but it is not designed for that), and in many cases runs just as fast as C or C++.  The managed aspect relates to how memory is organized and the presence of security features such as bounds checking and automatic initialization.  C and C++ are unmanaged.  You have to do everything yourself and you can shoot yourself in the foot any way you like (the joke is C gives you a pistol to do it, C++ an assault rifle).  In C# when you aim at the foot the safety is forced on (but, you can still do other kinds of damage). 


Last modified on 2012-12-29

comments powered by Disqus