მეგატვინი ჰმმ
QUOTE | 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. 19 Answers Mark Miller Mark Miller, Have been programming since I was 12 30.2k Views • Mark has 260+ answers in Programming Languages. Contrary to the way it looks, C is what I'd call an "expression-oriented" language, with some imperative and (minimally) declarative elements layered on top. Imperative elements govern control flow. Expression elements mostly deal with computation, though the ?: operator governs control flow, along with giving a result. Structs/unions, along with bitfields, are a declarative feature that allow the programmer to create offsets inside a defined area of memory, and/or create types which allow the program to allocate more areas of memory, which can be navigated by offsets.
C++ layers declarative syntax on top of the aforementioned features of C, to define an extra layer of scope for functions, with parameterized typing, called "classes." It greatly expands upon the concept of the struct in C, by attaching strong typing to functions (the types of which can be parameterized), and heap allocations (which can also be parameterized), and adding an implied "this" pointer to functions that are associated with structured data. Other features include:
A table of pointers inside of these expanded structs, which may exist inside of heap allocations, to functions that are defined in derived classes, to enable "downward" polymorphism, when functions associated with structured data are called. A new type of reference called an "alias." I might call it a "roving variable." Like a pointer, it can be made to reference different areas of memory, but like a variable, it can be used to assign rvalues of its type to memory locations without the need to explicitly dereference it. An alias doesn't function like a variable by itself. It needs a defined address space (a declared variable, or defined structure of some sort, that is known to it) in order to function as a variable. A designator called "const" that allows values to be assigned to variables once, but not modified. A meta-structural feature called "templates" that allows types to be parameterized (these types are filled in when the source is compiled). A little bit of meta-programming, where during run-time some information can become known about the type of an object.
Lambdas were recently added to C++. From what I understand, these are functions that are defined inline, and use an abbreviated syntax.
Like with C, C++ takes a layered approach to these different aspects. As a result, C++ does not necessarily warn you if you do something like an assignment inside of a conditional test expression.
C# adopted some syntactic features of C++, but it doesn't compile and run the way C++ does. C# holds your hand more than C++ does. It doesn't allow certain expressions to be used inside of certain constructs (like an assignment inside a test condition), as some things are considered bad form, and probably a mistake.
Like with C++, what C# calls classes are an expansion on the struct concept from C, but there are no pointers in C# code, unless you explicitly go into "native" mode. I forget how this is done, but it is possible to go down to the machine level, inside a "confined" space, inside a C# program. The runtime keeps the pointers, and hands references to them to the running code. This is to enable garbage collection, which C++ doesn't have.
A consequence of this is that deallocating memory is explicitly deterministic in C++, but it's not in C#. Memory is made available for garbage collection in C# when a variable no longer refers to a value or object, but when that memory is deallocated and cleared is determined by the runtime. In C++, memory can only be deallocated explicitly, using a "delete" command.
C# has two types of variables: "value" and "object." Variables of object type are stored on the heap. Value type variables are not. Value type variables behave rather like "native" variables in C++ (types like "int"), except that they are classes, and the values that are assigned to them are classes or structs. The way you can tell the difference between the two is that value type variables can take a literal. You can say:
int a = 10;
Variables of object type have to receive an object that was brought into existence by the "new" operator, which allocates the object on the heap. This behavior will be familiar to C++ programmers.
It is possible to convert between the two types of variables, doing what's called "boxing" and "unboxing." In C++ this would be accomplished through explicit or implicit cast operators.
Variables of object type function rather like aliases in C++, except they don't need a defined address space. They just refer to objects in memory (or null, if they refer to nothing). There is some "magic" under the covers about how the runtime stores these values, and arrives at the stored values (when retrieving them), since again, there are no pointers. Objects are just bound to object variables. The programmer is not supposed to concern themselves with how. There is no relationship between a variable of object type and where an object is stored in memory. To make another analogy, object variables function rather like keys in a hash table, referring to objects that are stored along with the keys.
Object variables can be re-assigned to different pieces of memory by reassigning them to different objects, though the runtime arranges what memory is accessed. The programmer has no explicit control over that. All the programmer knows is that a variable may be referencing something else when s/he reassigns a variable to another object.
Similar to C++, in C# you define functions that are associated with structured data, though unlike C++, you cannot define free-standing functions that are not associated with a class.
C# implements the same basic polymorphic function logic within objects as C++ does, though how it does it I don't think is made known to programmers.
Generics were eventually added to the language, which are analogous to templates in C++. They allow types to be parameterized.
C# has lambdas, which can function like closures, like C++'s recent addition of lambdas. Before .Net got lambdas, Microsoft introduced anonymous functions, which functioned like lambdas, but were more verbose, and were generally used to handle event logic.
In more recent versions of C# it has been possible to extend class definitions, so that programmers who use a framework can add methods to an existing class without having to create a derived class, modifying the original source code, or re-compiling it. C++ has not had this capability.
C# modules (DLLs) can be called up by version number. I haven't heard of any implementation of C++ that has that capability.
C# modules can be incrementally downloaded over the internet and late-bound into a running program, as needed. C/C++ hasn't had that ability in their runtimes, except via. binary DLLs in Windows, or .so libraries in Unix (or some equivalent on Linux). In C/C++ it's done through OS calls. In .Net it's done through calls to the Framework's library.
From what I've understood, C has been more portable between platforms than C++ (though perhaps this has improved since I last used C++, which was in 2006). C# doesn't have much portability. If you want to use the most up-to-date version of C#, you have to use it on a version of Windows (with one exception, which I talk about below). If you're able to skimp on the version, there is an open source implementation of the .Net runtime called Mono that runs on multiple platforms, with its own C# compiler. It is able to emulate Windows GUI functions in client apps.
Microsoft has had a project going for years now called "Silverlight" that brings .Net into the browser, and from what I remember, C# is compatible with it. Silverlight runs on multiple browsers, on Windows and Mac. I vaguely remember that it runs on Linux as well.
From what I've understood, the only browser that runs C++ code is the Google Chrome browser, in what's called "native client."
I forget exactly when this happened (I'm thinking mid-2000's). Microsoft introduced Managed C++, an implementation of the language that can run using managed memory in the .Net runtime. I looked at the first version, and it was more verbose than native C++. I think they've cleaned up the syntax since then. Like with C#, it had "value" and "object" type variables, and you had to specify these explicitly (you could not use '*' to declare "object" variables. Instead you used a "ref" designator. However, you used "->" to refer to managed fields and methods). What's unique about Managed C++ is that you can mix native C++ code with managed code rather seamlessly, and it's possible to transfer values from native C++ code into managed memory, and thereby access them from managed code.
Another unique feature of Managed C++ was that it was (at one time, I don't know if they still allow this) possible to get an address to managed memory, and to go through it, and modify memory, using a native pointer type, just as you could in native C++. This, of course, was considered dangerous, as it would allow a sloppy programmer to corrupt managed memory. But it was possible. Updated 23 Nov 2014 • View Upvotes More Answers Below. Related Questions What is the difference between C# & C-sharp? What is the difference between C++ and C#? What are the differences between C++03, C++11 and C++14? What is the difference between c++ and c++ 11? What are the differences between C# and Objective-C? Ron Maimon Ron Maimon 22.7k Views • Upvoted by Kunal Suri, Coded in Java, C++ and Python. 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. Written 10 Jan 2014 • View Upvotes Dorin Lazăr Dorin Lazăr, Coder 22.3k Views Let's start with the common points: all three of them (four of them, if we add Java) use the same principles in syntax: the C way.
C was first, and a history of C will make you understand why C is important. C, however, in its goal to become a portable assembler (a common sense common subset) had other priorities, and wanted to be as close to the metal as possible.
C++ includes all that C has, and adds to that encapsulation, polymorphism, templates and a whole standard library based on templates. Using data containers becomes much easier. The differences between C and C++ are subtle - where you could just assign a void * to a char *, for example, you have to do a proper cast; type checking is more strict in C++. But other than that, C++ is just a cleaner version of C, with OOP and metaprogramming added.
C# and Java discard C for C++. They take C++, throw away the pointer notation, and all variables become hidden pointers (except for the value types, primitive types, due to performance reasons). They add forcibly garbage collection, metadata to your classes, all the objects will be derived from a base class, called object or Object, which adds automatically virtual methods to objects, and they never compile to native code; instead they compile to an evolved machine language called IL for C# and bytecode for Java. This makes them require an interpreter to run said code, and transform it in native code, or just interpret the code and run it like a Virtual Machine. Since probably that was the initial approach, Java's interpreter is called JVM (Java Virtual Machine), while C#'s is called CLR (Common Language Runtime). But in the end, to obtain performance, the interpreters try to actually generate native code, so they all come with a translator of intermediary code to native code. This is the so-called JIT (Just In Time) compilation.
But the interpreted code is a performance issue, and the supporters for the languages create new ways to improve said performance. For example, Microsoft chose to actually run the JIT before even loading some modules, only one time, so when the .NET framework gets an update, you'll see some processes busy for a long time: they will transform your common language code to native code before you even use them, and store a cached version to be available for all programs.
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# does it less than Java, but Java has these purists that for a lot of time refused to do things non-OOP (and that is usually bad, because OOP is just one paradigm, but it cannot cover everything without huge performance issues).
C# and Java are also 'owned' languages. If you choose C#, you are tied to Microsoft products (although Mono lives on a developers promise from Microsoft and the fact that C# is defined as an ECMA standard). Microsoft drives the language, as well as the .NET framework that actually gives value to C# as a language.
Java used to be owned by Sun, which now has been taken over by Oracle. I won't say more, but as we speak, Oracle has some long standing lawsuit against Google for using Java 'not how we wanted you to use it'. So there's a word of warning there, as well as the fact that Oracle won't be able to drive a language the same way Microsoft does. And C# is really ages ahead of Java.
In the mean time, C++ has this C++11 extension. This extension, and the coming C++14, aims to improve the language, to make it more of a modern language. You can see new smart-pointers, lambdas support, ranged loops and all sort of improvements for the developer that also keep the overhead of not using them to 0. C++ always had this don't pay for what you don't use approach, that makes it a more mature language.
Beyond this, it's all just a big, big flame war. Written 10 Jan 2014 • View Upvotes Matt Jones Matt Jones, CTO of Plum Voice 36k Views It helps to think of programming languages in terms of how closely they are able to control what a computer is actually doing. These are commonly classified as low-, intermediate- and high-level programming languages. Computers execute machine code, and assembly language is considered the lowest level programming language; it is a human readable version of machine code. C was created to provide a structural programming language that is easier to use than assembly. It is considered a low-level programming language with little to no loss in performance relative to assembly. This made C the natural choice for building operating systems and low-level software on computers because it allowed for easier development at near-assembly performance. C++ is essentially an extension of C. The original C++ compilers just pre-compiled directly into C, which was then compiled to machine code, while modern C++ compilers can easily compile C or C++ into machine code. C++ was designed to allow developers to use all of the existing features of C but provides a number of extensions to support object-oriented programming techniques in an intermediate-level programming language. C# is a complete outlier in this list. Despite it's name, it has far more in common with Java than C or C++. C# is an object-oriented, high-level programming language. Like Java, C# provides a number of features to make it easier for a developer to code in this language such as type checking, bounds checking, uninitialized variable checking, and garbage collection. While the language does not technically specify how it is executed, C# is most commonly compiled into byte-code (rather than machine code) and executes on a virtual machine (like Java) that converts the application into machine code on the fly. Developers who are focused on performance still pick C or C++ as their language of choice. Nearly all operating systems (kernel and low-level system software) are written in C, C++ or some combination of the two. Most high-profile server and desktop software is also written in C++. For example, most web browsers, office suites and games are written in C or C++. C# remains a common choice for internal/enterprise applications but is less common for commercial software. This is a useful reference for the languages used to develop modern high-profile software: The Programming Languages Beacon Written 10 Feb 2014 • View Upvotes Jürgen Pietsch Jürgen Pietsch 4.7k Views C and C++ are one family. In fact, every C program will also compile on C++ and almost always behave identically. C is only a very thin layer on top of assembly language, thin enough to allow direct hardware programming in many cases. There is nothing that prevents you from horrible disasters. You have to do your own memory management, your own initialization, your own everything ... Except for leading the program into memory and returning a value to the caller you have to do everything yourself. Of course there are plenty of libraries you can use. Every compiler comes with a standard C library so that common interactions between your program and the operating system are ready to be used.
C++ is the same plus it adds object oriented programming and some other features. It also adds some runtime code to allow things like exception handling. Still all the important stuff is left to the programmer and it adds kinds of new options for disaster. C++ has even more libraries for all kinds of things.
C# is only a remote vision of them. It's actually more like Java in many ways. It looks more like Java than C++, It is not compiled into machine language but instead into the .Net byte code, it has managed garbage collected memory handling, it is object oriented. Making disastrous mistakes is a lot harder because C# is usually able to clean up behind itself. Written 15 Oct 2014 • View Upvotes Jacob VanWagoner Jacob VanWagoner, computers are idiots, but they're *really fast* idiots. 7.5k Views • Jacob has 140+ answers in Computer Programming. Let's just start by saying C just is.
To get C++, take C and duct tape on support for object-oriented programming and throw in a bunch of libraries that utilize this object-oriented stuff. Also tape on features like references (basically pointers like in C, but managed so you can't screw it up like a pointer), and change dynamic allocation of memory from requiring a function like malloc() and instead letting it be done by a keyword operator like new.
C# is quite different. It looks a lot like C and C++, but take away pointers, give it a multi-pass compiler so you don't have to use header files and function prototypes (you can just write your functions et al in the same place you declare them), make the "namespace" a lot more important, and make it easier to write programs quickly by adding MOAR STUPH in the libraries. Written Oct 15, 2014 • View Upvotes Reed Oei Reed Oei, I've programmed in Python, Julia, and C#, dabbled in some others. 3k Views C and C++ are very similar, relative to C#, and the largest differences between the two are in C++'s Object orientedness and generics. Generally speaking, C++ is a much more modern language, such as in C++11 also supports things like lambda (anonymous functions) and type inference with the "auto" keyword (although it is still statically typed.
C# is very different, because, unlike in C++ where you can define functions outside of classes, everything in C# is part of some class. It also supports generic and type inference with "var". Additionally, C# has a garbage collector and you cannot manually manage pointers and such (unless you turn it on). Instead, classes are automatically pointers, and structure are not, so if you assign x to y, if they are both a certain class, and change y, it will also change x.
Syntax wise (curly brackets, keywords) all three are fairly similar. All use, int, bool, void, float, and chat, for example, as well as for and while, if, else if, and else. Written Oct 15, 2014 • View Upvotes William Emmanuel Yu William Emmanuel Yu, I love learning new programming languages 2.6k Views • William has 1,600+ answers in Computer Programming. They have all been built by very intelligent people. The main difference is C++ and C# are object oriented and C isn't. Written May 16, 2015 • View Upvotes Miljenko Cvjetko Miljenko Cvjetko, enjoying discovering differences between languages 4.9k Views They all have in common curly braces {}.
c is procedural language very powerful, used often in OS programming and embedded systems when performance is needed, because c can go very close to the metal almost like assembler. But (always but) it can go pretty high with object oriented concepts though it does not support OO by itself.
OTOH c++ is superset of c, meaning every c program is c++ program, but using c (c style) in c++ environment is not very good. c++ is OO programming language supporting multiple inheritance, templates (generics in c#), template specialisation and in last versions lambda expressions thus aiming toward functional programming language like haskel and f#.
c# came after c++ and java (late 90's) and picked the best of both worlds and ignored/threw away some stuff which make compiler construction and program design very complex - multiple inheritance (I miss that a lot in c#, but you can overcome it). c# introduced gradually features like anonymous types, methods and delegates, extension methods leading to features like LINQ which add functional programming elements what makes c# single inheritance hybrid (OO and func) language that supports generics and great asynchronous programming model with async/await. c# aims (like c++) towards productivity in higher level apps without rejecting performance (and this will be soon proven by new projects like .net native aka project-n, RyuJIT from MS and some existing tech from Xamarin)
I could go on and on with this, but I think I gave my 2 cents Written Oct 15, 2014 • View Upvotes Shehala It Shehala It, Shehala 2.8k Views 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. Written Jul 8, 2014 • View Upvotes Vivek Nagarajan Vivek Nagarajan, Programmer for 25 years 3.2k Views • Vivek has 17 endorsements in Computer Programming. C is an imperative programming language, quite like a portable assembly language with very trivial semantics - A C compiler can be extremely simple, since a line of C code maps almost one to one with assembler C++ is a multi-paradigm language that supports imperative, OO, generic, declarative (using templates) and functional (using lambdas or functors) programming at once. The evolution of C++ style has been to slowly move away from a OO dominant approach to a more functional/generic way of programming. No one who knows their C++ will refer to C++ as C with OO C# takes all the best features of statically typed languages (except for templates and compile time computation) and combines them into a clean and performant language. It supports some amount of dynamism and new paradigms like LINQ.
While most C++ compilers can compile C code and C# code looks somewhat close to C++, the languages are very much more different than they look.
The part of C++ that is not C is much larger than C itself.
Actually, Java is closer to C# than any other language ( C# also borrows a lot from Delphi, given that Anders Hejlsberg was the creator of both languages) and C is more closer to Pascal in terms of semantics than it is to C++.
The language that is closest to C++ is in fact D
The term C/C++ itself is very much of a misnomer as in reality they have little in common. Written Oct 16, 2014 • View Upvotes Grzegorz Gołda Grzegorz Gołda, Coding since 1993. C++, JS and Erlang Developer. GameDev and other fun stuff 2.8k Views 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. Written Oct 16, 2014 • View Upvotes Brian Connors Brian Connors 2.8k Views I'm not sure this will add anything to what's already written, but here goes:
C is the "last common ancestor" of a family that began with BCPL in the UK. BCPL spawned B at Bell Labs thanks to Unix cocreator Ken Thompson, which was essentially BCPL a with a more concise syntax; the problem was that both of them dealt only in one data type, the 32-bit word. Ken Thompson and Dennis Ritchie then extended it with support for strigs and custom datatypes and rewrote the Unix kernel in C to port it to the PDP/11. Although there have been some significant changes over the years, C remains a procedural, structured programming language that is especially good for low-level programming.
C++ was created by Bjarne Stroustrup at Bell Labs as well, by adding object-oriented constructs based on Simula (an Algol derivative). It differs from the other pioneering OO language, Smalltalk, by generally expecting to handle type matching issues at compile time rather than runtime. It's also an immense and rather Byzantine language that allows you to combine several programming paradigms in one program if you're so inclined.
C#, on the other hand, is a Microsoft-created derivative of Objective C by way of Java; it's a dynamically typed language that runs on a virtual machine, and eliminates a lot of the more awkward things about C and C++ like the preprocessor, which Java dispensed with early on.
The C language family is actually fairly large, with at least five major close relatives (six if you count Perl, which is a bit of a stretch, but it does use a lot of C syntax). They all have different advantages and disadvantages, and trying to say which is "better" is a sure route to a fruitless argument. The issues involved, however, make for a very, very long list that Quora just isn't suited for. Written Dec 14, 2014 • View Upvotes Carlos Matias La Borde Carlos Matias La Borde, Software developer 2.2k Views • Carlos is a Most Viewed Writer in Computer Programming. 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. Written May 15, 2015 Abhishek Kumar Abhishek Kumar 1.9k Views 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 multi-paradigm 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 OOP features 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 Polymorphism(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++. Written Mar 23, 2015 Bodro Vat Bodro Vat, Software engineer enthusiast 1.5k Views 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. Written May 16, 2015 Kshitij Mishra Kshitij Mishra, A sofware Engg too 2.1k Views If you are looking a=for some deep shit.. Go Google... Else if if you want a little practical view , Continue Reading. 1.You see C is an older language, it worked miracles and the way people communicated to the machine i.e the System.
2.Functional driven approach to algorithms that time was at peak due to pre existence of assembly level and other high level language , the prdecessor of C too :O I guess U know
Lately, Computer Engineers realised that the high flow among data in the various modules caused more problems . Solving problem through normal geeky way turned out boring. So people like you and me who are reading this got interested to know what can be done with data..
So C++ was made , it revolutionized industry and showed businesses the path which all of the are in. And We see the beauty of data abstraction. classes what they can do{ Java too has clasees mind it .
C# : sadness to me JAVA is better to communicate to the system Written Jun 10, 2013 • View Upvotes Gabriel Cojocaru Gabriel Cojocaru, www.gabrielcojocaru.com 1.8k Views C - an older programming language that is described as Hands-on. As the programmer you must tell the program to do everything. Also this language will let you do almost anything. It does not support object orriented code. Thus no classes.
C++ - an extention language per se of C. In C code ++ means increment 1. Thus C++ is better than C. It allows for highly controlled object orriented code. Once again a very hands on language that goes into MUCH detail.
C# - Full object orriented code resembling the style of C/C++ code. This is really closer to JAVA. C# is the latest version of the C style languages and is very good for developing web applications. Written Jan 10, 2014 • View Upvotes Mohamed Ramdan Mohamed Ramdan, coder , student 1.5k Views 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 . Written Oct 15, 2014 Related Questions What are the major differences between Java and C#? C# (programming language): How is C# different from C++? C++ (programming language): What is the difference between * and -> in C++? What are the key differences between C and Objective-C? Objective-C (programming language): What's the difference between primitive types and NS types? C (programming language): What is the difference between for( and while(1)? C# (programming language): What is the difference between these two initializations of an array? Nevermind, I got it. C (programming language): What is difference between rand() and srand() functions? Objective-C (programming language): What is the relation between frame and bound in UIViews? C++ (programming language): Should I really worry about the different compilers of C++? C (programming language): Can you write a C program to patch the library calls so that it calls a different library function than what is intended? C# (programming language): How do I create a thread for a function which belongs to a class different from the one in which the function creating the thread is a member ... C (programming language): What are some must-read books for a C programmer? Visual C++: Where can I find a good book on data structures using VC++ or any online tutorial or videos? C++ (programming language): In C++, why do you use references? |
|