Sign in to follow this  
H R

Difference Between C, C++ And C#? And some other questions.

Recommended Posts

As far as the differences between C and C++ go, most of you have got it right. But the origins and nature of C# tends to be somewhat murky in this discussion.

 

I'll try to clear that up a bit.

 

Before microsoft created C# they created J, which was their answer to Java (created by Sun Microsystems). Sufficed to say, that language just did not take off as a platform and fell flat on its face. It is rumored that Microsoft was so ashamed of its creation that at one point they denied its existence. In any case with the advent of the .Net platform they took another stab and created C#.

 

The syntax of C# is very close to Java, more so than it is to C++. Like Java it has interfaces and a single-inheritance hierarchy.

What does that mean? Let's start with the whole single-inheritance hierarchy thing. C++ allows for multiple inheritance, that means a class can have more than one super class. There are inherant problems with multiple inheritance, however. Let me give you the classic Diamond Of Death scenario. You're given four classes. Classes B and C are subclasses of Class A, and Class D --using multiple inheritance-- is a subclass of both B and C. Class A sits at the top of the heirarchy, B and C sit on a level below and D is on the 3rd and last level(if you play connect the dots following the classes in the following order A-B-D-C-A you get a diamond).

Let say both classes B and C override the method 'foo()' of their super class A, but class D inherits from B and C without overriding any methods. How does D resolve calls to its inherited method 'foo()'. It can't. Hence the fabled 'Diamond of Death' (queue menacing sound).

The Java designers decided to implement a single-inheritance scheme to remedy this issue. That meant that a class can inherit-from/extend/subclass one and only one super class. To compensate for the loss of functionality that multiple inheritance provided, Java introduced interfaces. Think of them as classes whose methods have no body, that is, they have no implementation.

 

Interfaces look something like this:

interface Movable{	public void up();	public void down();	public void left();	public void right();}

Now, in addition to their extends keyword Java and C# also have the implements keyword for interfaces. When the implements keyword is followed by the name of an interface, a class is required to implement all the interface's methods as seen below:

class Car extends Vehicle implements Movable{	// ...other code   public void up() {	   // implementation goes here   }   public void down() {	   // implementation goes here   }   public void left() {	   // implementation goes here   }   public void right() {	   // implementation goes here   }}

A class can implement as many interfaces as it likes and since every class that implements an interface has to provide its own implementation of that interface's methods the DOD (Diamond of Death) scenario never arises.

Java also supports garbage collection(i.e. freeing memory occupied by unused objects) and in the true spirit of mimicry so does C#.

 

And that, as far as I know, is the difference between C# and C/C++. As for C# and Java, this is what one of my former professors told me "Java uses 'String', C# uses 'string'". Nuff' said :).

Edited by dimumurray

Share this post


Link to post
Share on other sites

VB is the easiest, it has a simple code syntax and it's ideal for beginners. However, VB.NET is nothing like VB. It uses a syntax which is quite similiar to C#, therefore VB.NET is like a easier version of C#. C++ is what most developers use, it's the most popular developing program yet.

Share this post


Link to post
Share on other sites

C is a Procedure Oriented Language.introduced by Dennis Rithchie.The approach used in the C Language is Top-down.But C++ is an Advanced version of C which is introduced by Bjarne Strousup.C++ is an Object Oriented Language.The Approach used in the C++ is Bottom-up.This is the main difference between C and C++.But C# is a modern lanquage which having some functionalities similar in C & C++.C# is also an Object Oriented Language.The main Advantage of C# is that,It gives more importance for Exception Handling.C# is a language which having the properties both in C++ and Java..C# is a Programming Language supports Multithreading. :P

Share this post


Link to post
Share on other sites

C is lowest form, and hardest to use.C++ is second up and is a little easierC# is the easiest of the three but doesn't have as much control (as far as I know the main difference is you don't get to choose memory locations, which is easier on programming but harder in terms of customization).

Share this post


Link to post
Share on other sites

What's the difference between C, C++ and C#?

C++ is different from C in that it is object-oriented. Think of it as a language that extends the capabilities of structs from C, enabling you to add functions to structs and to add include-like functionality to create several structs that have the same members.

C# is similar in syntax to C++, but takes away the complexities of pointers and manual memory management. It is targeted specifically at the .NET framework.


What is more closely related to working with ASP.NET, C++, C#, or VB?

ASP.NET is a web development framework and supports the use of C# and VB.NET. However, you can use class libraries that are created in any language that has a compiler targeting the .NET framework. What I mean is you can create a DLL in J#, another DLL in C++, and call the methods in the DLLs from a web user interface built with either C# or VB.NET.


Which comiler is best for C++ and/or C#?

For C++, you can use gcc if you are targeting the Linux/Unix platform. For Windows, you can use the Visual C++ or Borland C++ compiler as they include the libraries you need to develop for the Win32 platform.

For C#, you can get the .NET SDK from the Microsoft website which includes the C# compiler (csc.exe). You can also get the Visual C# Express edition. You can use the Borland C# compiler too, but you wouldn't get the libraries for development with .NET 3.0 or .NET 3.5 and newer language features wouldn't be supported.


Are there any benefits in choosing VB over C++ or C#?

As VB.NET and C# target the same platform, I do not see any advantages there. However, depending on your geographical location, you might be able to find more VB.NET developers or perhaps you can find a VB6 developer willing to 'upgrade' his/her skills to VB.NET

Share this post


Link to post
Share on other sites

I always saw C# as just being Vb. net parrot style withC++ syntax. C# appears to have exactly the same functionality
as VB .net so I wonder why Microsoft bothers sometimes.


Microsoft is simply trying to create a platform that is easy to switch to for both Visual Basic and C++/Java developers. They have been quite successful at making the Microsoft .NET Framework the platform of choice for most Small and Medium sized Enterprises.

Share this post


Link to post
Share on other sites

C# is better to use in any way. Its just a myth that C++ does graphics better. The truth about C++ and graphics is that more developer use's C++ because of that it is older and they have been using it for ages. My opinion; C programmers of any kind should emigrate to C#.

Thx for listening!

-reply by Kristoffer Frisell

Share this post


Link to post
Share on other sites

C# is better to use in any way. Its just a myth that C++ does graphics better. The truth about C++ and graphics is that more developer use's C++ because of that it is older and they have been using it for ages. My opinion; C programmers of any kind should emigrate to C#.Thx for listening!

-reply by Kristoffer Frisell

Share this post


Link to post
Share on other sites

C language:1.C is structure based language,commonly known as procedure oriented programming(pop)language.2.it follows top-down approach for execution.3.On performance basis nothing beats C,dats y major parts of operating systems like windows,linux,unix are still written in C.programs of fast games,cell phones,palmtops and consumer devices like microwave ovens,washing machine,cameras are written in C coz of speed of execution and amount of memory used.4.Contains only 32 Keywords.C++ language:1.C++ is an object oriented language, it is made by combination of C and Simula67.structure feature of C and Object oriented feature of Simula67.2.it follows Bottom-Up approach for the execution of program.3.By C++ special object oriented libraries can be build which can b used later by other programmers.4.Easy to maintain n expandable coz of inheritance,polymorphism etc. if any 1 wants to add new feature than another functions n data members can b created and inherited in d class while in C programmers are forced to make change in whole program or create new.5.contains originally 48 keywords.C# language:1.C# is originally designed to work with the .Net2.C# is platform independent language bcoz C# is just a language specification and so is not inherently tied to any os. The current situation is that any machine that has an implementation of the CLR can run a C# program.Some people will say dat it C# can not b used on Linux but it is not completely true bcoz You can build a .NET application on Windows and run that application on Linux. You just have to install Linux version of .NET runtime on the Linux box. 2.it can b said dat its concept of writing program is based on java like format of using 'public static void main()' instead of main().3.like java it provides security and self memory management by self activated garbage collector but it doesnt mean it is almost similar to java.welcome for ques...

Share this post


Link to post
Share on other sites

Both C and C++ give you a lower level of abstraction that, with increased complexity, provides a breadth of access to underlying machine functionality that are not necessarily exposed with other languages. C++ adds the convenience (reduced development time) of a fully object oriented language which can, potentially, add an additional performance cost. In terms of real world applications, I see these languages applied in the following domains:C - * Kernel level software, * Hardware device drivers, * Applications where access to old, stable code is required.C,C++ * Application or Server development where memory management needs to be fine tuned (and can't be left to generic garbage collection solutions). * Development environments that require access to libraries that do not interface well with more modern managed languages. * Although managed C++ can be used to access the .NET framework, it is not a seamless transition.C# provides a managed memory model that adds a higher level of abstraction again. This level of abstraction adds convenience and improves development times, but complicates access to lower level APIs and makes specialized performance requirements problematic.It is certainly possible to implement extremely high performance software in a managed memory environment, but awareness of the implications is essential.The syntax of C# is certainly less demanding (and error prone) than C/C++ and has, for the initiated programmer, a shallower learning curve.C# - * Rapid client application development. * High performance Server development (StackOverflow for example) that benefits from the .NET framework. * Applications that require the benefits of the .NET framework in the language it was designed for.

Share this post


Link to post
Share on other sites

Everyone has mentioned about the stuff that you can do with C, C++, and C# and there's nothing left for me to say, really. I guess all I can do is complain about each of the three languages :-PCLet's begin with C. It is a quick and easy language to get started with, but working with pointers seems to be hard for many to manage. After you go beyond a few thousand lines of code, the source code becomes unmanageable for the average software programmer.C++C++ was meant to be an extension of C and is backward compatible for the most part. Pretty much anything that you can do in C also compiles and executes perfectly well in C++. But wait, that's a good thing. The negative is that the newer features it provides can slow down execution a bit. Object oriented development is a great way to organize your code and enforce some degree of separation between the various classes in your application (see the General Responsibility Assignment Software Patterns - GRASP for how this is done) but all of this includes overhead. You didn't think there was such a thing as a free lunch, did you?C#After having dealt with pointers, crashing applications, segmentation faults, illegal operations, and all of their little buddies, somebody thought it would be a really cool idea to clone Java. Yup, that's right. C# is a Java clone with some aspects of the C++ syntax worked into it. Running byte code (For C#, it is referred to as the Microsoft Intermediate Language) over a virtual machine comes from the Java world and C# has it. The virtual machine provides garbage collection and memory management, just as Java's virtual machine does. However, all of that comes with extra bloat. C# applications are hardly as efficient as C++ or C applications simply because of all that the platform has to offer, but it does make programming easier for novices.I don't have a dislike for any of the three languages. Each has its place. C has found extensive use in system programming - for creating operating systems, device drivers, protocol stacks et al. C++ piggy-backs on the success of C while providing some degree of sanity to the spaghetti code. C# is the language for rapid development on the Windows platform. C# has nothing in common with C or C++ (the name is a marketing strategy!) except for some of the syntax but is in fact a clone of Java. If you want to write software as you do for Java but want to, for some bizarre twisted reason, want to prevent MacOS and Linux users from using it, you can pick C# as the programming language for your project.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this