What is the difference between C# and C#.NET?

What is the difference between C, C++ and C#?

  • As C is the base of C++ and C# which means they must be having some advantage over C but still C is used in many places. And is there any difference in C and C++ other than OOP.

  • Answer:

    C is a great language, gnu C is probably the greatest language of all time. The reason is that it is both very low level, and yet it has no barriers to scaling up to making arbitrarily complicated projects. It is the only language that a former assembly programmer can program in without tearing the hair out. Perl is a close runner up here, but the hair (slowly) comes out. With other languages, you're bald. There is a fundamental principle in C that is not respected in any other language: complete binary data transparency. in C, you know exactly what you get with your data. That means if you say "struct froo {int i;double x; char c;}. you know exactly what you are getting in memory, byte by byte, even usually in what order. the stuff that isn't specified in the standard is often standardized by the compiler anyway, and on non-aligned architectures like Intel, it's exactly what you think it is--- an int, followed by a double, followed by a char, exactly 15 bytes long. No type modifier, no added information, like a UNIX file, it's just clean data exactly like what you wanted. It will place consecutive data consecutive in memory. Stuff you allocate in a function gets allocated on the stack exactly as you declare it (usually in the same order), stuff you allocate with malloc goes on the heap exactly where you think it is (the information about the page allocation is slightly behind the data in Linux if I remember right). The memory layout of all your data is under your control, and there are no compiler generated surprises, because the compiler hardly does anything, and it doesn't do anything without you asking for it specifically. C also can compile lightning fast, if you don't use C++, it was compiling on 1970s hardware, and it has a preprocessor that's faster than cat. The algorithms are also transparent, you can see more or less exactly what machine code will get emitted from your instructions. Here C is not completely ideal, because its expressions are modelled on previous high level languages, and so it is lacking three things that it really should have had: 1. a primitive swap--- you can't primitively swap the value in a with the value in b. 2. carry sensitivity--- you can't talk about the carry on an add, it's unspeakable. 3. high-bits of multiplication--- you can't talk about the high 32 or 64 bits of a times b, also unspeakable. The ANSI standard included one useless thing that makes writing an ANSI compiler hell: named bitfields. Those are so useless, everyone uses masks, and they get turned into masks anyway, and still these stupid bit-fields wreck any cheap and quick ANSI compiler. I hope tcc (the tiny c compiler) avoids implementing bit-fields, but they are striving for ANSI compatibility. All of these are there in the architecture, and are available to an assembly programmer. Gcc will figure out when you are swapping often and put in a swap, but if you want to implement a bigint, you need assembly, because you can't access the carry or the high bits from C. This is the only intolerable annoyance left in C for the assembly programmer. aside from these three annoyances, anything else you do in assembly you can do in C. I am assuming you are using gnu C, which includes computed goto, named enum, named initializer, nested functions, and all the other gnu extensions which should have been in the ANSI standards to begin with, but weren't (some of them are there now). Gnu C also has a named return value extension which doesn't work in C, but should. C also doesn't stop you from doing tsk, tsk, naughty things. You can get a pointer to your own code, and rewrite your program's machine code (with appropriate system calls). You can allocate a block of code and emit machine code into it, and jump to this code. You can "goto" anywhere you want. You can wreck your own stack. You can access all the operating-system allocated information about the pages of memory you are writing to. And if insist that you really want to fiddle with the registers, you can, because you can embed assembly anytime. You can also control the register allocation in gcc, you can micromanage the compiler as far as you like. This made C the superstar of languages, because it really understood what assembly programmers wanted. Since it could be used to write an operating system, it replaced assembly programming in the 1980s, and this is probably irreversible, even though the major motivation, lack of a standard architecture, is now moot, because Intel architecture is standard today. C++ took C and added object orientation. Some of C++ is harmless and nice, like // comments, structs with automatic typedef, default values functions, and namespaces (which really help keep the code separate and modular). Even making structs include functions is no big deal, it does make the code a little prettier. But C++ became C++ rather than a dialect of C when it went on to break the commandment: thou shalt keep the data binary transparent, It broke it in such a seemingly harmless looking way, though, that Stroustroup probably said "What's the big deal?" The culprit was the virtual function table. There are two kinds of classes in C++, the ones that are virtual and the ones that are not. If you don't use any virtual functions, you might as well be using a really annoyingly nitpicky C. But when you declare functions virtual, then you get a non-transparent change in your data structure. At the beginning of every instance of your structure you get a pointer, and this pointer points to a virtual function table, and this virtual function table has a list of pointers to all the functions you declared virtual, which are the ones that get called when you try to call the function of this name on the given data type. When a class inherits from your class, it gets a copy of your virtual function table, and it can override the virtual functions and redeclare them. Then the pointers in the function table are overwritten. This is all done by the compiler, at compile time, by arranging the virtual function table, and that's nice. But it is not nice in one way: the data is there and is inaccessible by the program! Commandment broken. What does this mean? It means that suppose you declare a class of "number types", which makes virtual addition. Then when you declare a quaternion to be (number_type A,B,C,D), you get four number-type objects, which contain a virtual function table pointer each. That's 8 bytes of function table pointer + 1 byte data. Overall, 4 bytes data, 32 bytes of function pointers! And it's stupid--- you know for sure that the four objects are all the same number-type, but because the virtual function table is welded onto the data-type, you can't separate it out. Breaking the commandment comes back to byte you. This means that C++ is useless for designing a number class which can generate efficient codes for various mathematical objects, you still need to roll your own. If you do write a general thing, it has to be a template, and this is itself a nightmare that C++ introduces to get around these limitations. If you use standard C++ for these cheap things, the quaternion multiplication becomes horribly inefficient, and you might as well be using a high level language. The other problem is that you aren't allowed to modify the virtual function table at runtime, it's hard wired by the compiler. This means if you decide you want to change the way a particular class should do x or y, you can't overwrite the function table pointer, it's not accessible to you. You can hack it up in gcc, it is possible, but it is hard because the language is violating the data transparancy commandment. This feature is what Java and C# add. They make it that you can construct classes and modify them whenever you like, at runtime. But they are never low level, because as much as they promise compilation to machine code, it's never going to happen, it was just hype. So they stay useless for high performance scientific computing, which is always at the machine limits. They also violate the commandment much more freely, so that you can't even use dirty pointers. I am sort of annoyed with this, as it is easy enough to design a syntax for object orientation which does not violate transparency of data. Just nobody chooses to do this, because it makes the language stay low level, and in fact, makes it go even lower level. Good. I think that's the right next step.

Ron Maimon at Quora Visit the source

Was this solution helpful to you?

Other answers

Almost everyone here, except Vivek Nagarajan, is talking BS. Modern C++ is so remote to C that is so clear last time you saw it was long ago. Take a look at Alexandrescu's book on modern C++ design patterns and try to find similarities between C and what this book is about. And obviously C++'11 and coming C++'14 are making it even more remote.

Grzegorz Gołda

The difference between C#/Java and C is too big, but the differences between C#/Java and C++ are easier to pick and the most important, other than said updates to the language, are the adoption of a pure OOP approach to programming.C is an old systems programming language (all the way from the 60s), created by Dennis Ritchie (RIP) for AT&T/Bell Labs and their UNIX system. It's very low level and works like computers actually work. It's also very very fast because of that.C++ is an improved version of C created by Bjarne Stroustrup in the 80s, it was originally just C with classes and object orientence, but nowadays it's a huge and complicated language. It's also a superset of C, so all valid C code is valid C++ (the other way doesn't work though). Still very fast.C# is Microsoft's language for the .NET Framework. The syntax itself looks like C and C++ but the language itself is totally different. It's much higher level (easier to use, does more things for you). It's very similar to Java, but has some more features. Not as fast.see more on:http://www.rajinfo.comRaj Computers Academy is always striving to keep abreast with latest trends in the basic computer courses with best professors.

Raj Computers Academy

C is a functional programming but it wasn't enough for big projects so C++ came out to be an object oriented and much easier for Bigger projects . someone mentioned that C behavior is much more expected than c++ i don't really know why . C# is like the java of microsoft . microsoft made it to be the best language among all and have all of it's advantages .

Mohamed Ramdan

C is one of the oldest ones. After the machine language, C was the one that gives life to others. That's why it is harder than the other ones. Because every other language which created after "C", was created from C to be less harder. So that they made a research on "C" to narrow down it's complicity.C+ is an interesting one. Because it is absent. There are no any language which named as "C+".C++ comes from C, as you can see it took the increasing presentation of the programming languages. Yes, it means C++ is kind of "C + 1". So it is a bit nicer and simple. You can say that. But it is good to remember that, with C++, Object Oriented Programming language concept born. So still, C++ too a bit hard when you tried to compare it with newer ones.C# is one of the newer one. Easy to understand when compared to others, they always keep it updated for having a better usage and understanding. Lots of functions, API's and countless things to use for you to implement them with a little bit pushing. You can connect to databases or make a phone application with C# that is very easy when compared to C and C++ languages.Always remember that, new languages are made for having a better usage, low number of codelines, easy to implement kind of things. Otherwise, this would not have a point to make a new one.

Orçun Yılmaz

Very different, IMO. C is probably the hardest of the three, C# is the easiest. I think C++ probably has the most uses or at least is used in a lot of underlying frameworks for things. Although C# can be used with ASP for the web, in general for desktop apps it's basically just VB mixed with Java. All good langauges, just for different things. If I wanted to really grok some lower level concepts and have as powerful a language as possible I'd pick C (though again it can be kinda hard). If I wanted to do some pretty hardcore application development I'd go with C++. I don't want to throw C# under the bus here, because I like it a lot, but unless you go with Mono it's going to be pretty much Windows only, and it's much better for GUI prototyping and all around higher level stuff than the other two.

Carlos Matias La Borde

C is a procedural/imperative language, you have functions and global variables (although you can limit this to file scope and should do so most of the time).C++ can largely be seen as an object oriented extension to C, or a multi paradigm extension. I think that C and C++ are both influencing each other. You should know that there is not juts one C and C++, but those languages evolve over time.There is no such a thing as C+ yet, and if there has been, it was not very successful, cause nobody has even heard of it.C# is Microsoft's answer to Sun's(at the time) Java. It is often easier to use than C++ while only a few features are sacrificed, like multiple inheritance. And you don't need that often and can inherit from one base class and one or more interfaces instead.In both C++ and C# you can do object oriented programming and you have some features taken from functional languages. A very important difference is that in C# you have garbage collection, you don't need to delete your own objects. C# has delegates and events, but you can achieve similar in different ways in C++. There is no real winner here, except when your program needs to run (also) on other operating systems than Windows. If so, go for C++ (or C). Other alternatives are not in your list, but Python is great.

Richard Rombouts

Lets say C++ is made as an extension of C to introduce object oriented features in the language. Programs made in C can be build with C++ compiler and C++ programs frequently use libraries build in C.  C# is a much newer language build by Microsoft more similar to Java than to C++. It contains a garbage collector and can be executed only on a virtual machine, usually only on Windows. These languages have a different purpose, so it depends on a project which one would be the best.

Bodro Vat

C: C is the first "C" language and the oldest. Or as you know, just "C". It is a very basic language with static types and basic functions and control structures. Lacks object oriented features. Since C++ is a perfect superset of C, the only thing that identifies a C file is its ".c" extension and its decision not to use C++ features. In theory therefore, it is a dead language. When someone now uses "C" it is basically a style choice not to use objects, either because they are learning basic programming or because they want to "keep things simple" for performance or stylistic reasons.C+: To my knowledge, there is no such thing as "C+". From wikipedia: The name (C++) stems from C's "++" operator (which increments the value of a variable) and a common naming convention of using "+" to indicate an enhanced computer program.C++: C++ adds object oriented features to "C", as well as a number of other modifications. It is a superset of "C", so includes all of C and more.Objective-C: Made by Apple, this language is another superset of C. It originally translated to C++, but later became its own language. It does not directly support C++, but if you use a ".mm" file, then you can write in Objective-C++ which is a superset of C++. The languages and syntax are very compatible.C#: This is a Microsoft language and uses C syntax or C related syntax. I don't know much about it, except that it is Object Oriented and took much of its inspiration from Java. Java also shares a general syntax similarity to C and C++.

Thomas Johnson

C++, as the name suggests, is a superset of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code. Here are the 10 major differences between C++ & C… 1. C follows the procedural programming paradigm while C++ is a http://durofy.com/programming/c-as-a-multi-paradigm-programming-language/ language(procedural as well as object oriented) In case of C, importance is given to the steps or procedure of the program while C++ focuses on the data rather than the process.  Also, it is easier to implement/edit the code in case of C++ for the same reason. 2. In case of C, the data is not secured while the data is secured(hidden) in C++ This difference is due to specific http://durofy.com/programming/the-basics-of-object-oriented-programming/ like Data Hiding which are not present in C. 3. C is a low-level language while C++ is a middle-level language (Relatively, Please see the discussion at the end of the post) C is regarded as a low-level language(difficult interpretation & less user friendly) while C++ has features of both low-level(concentration on whats going on in the machine hardware) & high-level languages(concentration on the program itself) & hence is regarded as a middle-level language. Note: This is a relative difference. See updates at end of this post. 4. C uses the top-down approach while C++ uses the bottom-up approach In case of C, the program is formulated step by step, each step is processed into detail while in C++, the base elements are first formulated which then are linked together to give rise to larger systems. 5. C is function-driven while C++ is object-driven Functions are the building blocks of a C program while objects are building blocks of a C++ program. 6. C++ supports function overloading while C does not Overloading means two functions having the same name in the same program. This can be done only in C++ with the help of http://durofy.com/programming/the-basics-of-object-oriented-programming/(an OOP feature) 7. We can use functions inside structures in C++ but not in C. In case of C++, functions can be used inside a structure while structures cannot contain functions in C. 8. The NAMESPACE feature in C++ is absent in case of C C++ uses NAMESPACE which avoid name collisions. For instance, two students enrolled in the same university cannot have the same roll number while two students in different universities might have the same roll number. The universities are two different namespace & hence contain the same roll number(identifier) but the same university(one namespace) cannot have two students with the same roll number(identifier) 9. The standard input & output functions differ in the two languages C uses scanf & printf while C++ uses cin>> & cout<< as their respective input & output functions 10. C++ allows the use of reference variables while C does not Reference variables allow two variable names to point to the same memory location. We cannot use these variables in C programming. MORE - 11. C++ supports Exception Handling while C does not. C does not support it “formally” but it can always be implemented by other methods. Though you don’t have the framework to throw & catch exceptions as in C++.

Abhishek Kumar

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.