Difference between C,C+,C++,C#

VIAN

Diamond Member
Aug 22, 2003
6,575
1
0
C is the original general programming language.

C++ is C, but with some extra things that make it much more complete as a general programming language.

C# is a copy of Java. It's a more specific programming language than C++.
 

slugg

Diamond Member
Feb 17, 2002
4,723
80
91
C#, like VIAN said, is a copy of Java. It compiles into bytecode which is read by a virtual machine or interpreter. It shares a similarity with C++ being that its object oriented (OOP, or Object Oriented Programming), which is basically the "big thing" in programming now. If you can program in C#, you can program in Java and vice versa. For what it's designed to do, it's actually a very good language and I'd recommend it as a learning language (Java might be better since you can find more info on it... but its really the same thing). C# and Java syntax is SIMILAR (but not the same) in many ways to that of C++ and C, so if you can program in C#, you shouldnt have too much of a problem reading and editing C or C++ code. For example, I started on Java and I picked up C++ in no time at all :). I don't know about C#, but Java is definitely cross platform. You can create a Java application and have it run on windows, linux, mac, you name it. Java is more common than you'd expect. Java powers JSP (JavaServer Pages) technology, which is Sun's version of PHP or ASP (ebay, for example, is powered by JSP). Java is also used as a base for many scripting languages in games (for example, UScript which powers the Unreal engines, is based on Java), mini applets for cell phones, and other random things. IBM also uses a lot of Java technologies with their servers. It's really a great, but underappreciated language :). Since Java and C# are slightly simplified and run within specific parameters, they're considere'd "high level" languages. Other "high level" languages are Visual Basic and Perl.

Unlike C# and Java, C and C++ compile into binaries which are executed natively. The pros to this is speed and power. Programs written in C++ and C are definitely faster than their C#/Java counterparts, and could potentially do more since they run on the native machine instead of a virtual machine. The downside to this is that BECAUSE these programs run on the native machine, they're potentially hazardous and could crash your computer if you wrote something incorrectly (like if you had a stacked datastructure and blew the stack... you'd probably crash your whole computer). C# and Java programs would simply just crash the instance of the virtual machine, but your computer is left unharmed. Due to the speed and power, more demanding applications are typically written in C++ (or even partly in assembly, which is even faster). An example would be a PC game. Half-life 2 is written in C++, and part of its graphics engine is written in assembly. It's obvious why a program like that would need every bit of speed achievable :). Also, C and C++ tend to be more complicated than C# and Java since they're a lower level language than C# and Java. Assembly, though, is an even LOWER level, so its even harder.

And BASICALLY, the difference between C++ and C is that C++ is object oriented, and C is not. Yes there are other differences, but that's the main one.

As always, there are exceptions to every rule, but in a NUTSHELL, that should answer your question! If you have any more i'd be glad to help :)
 

gregor7777

Platinum Member
Nov 16, 2001
2,758
0
71
Originally posted by: slugg
C#, like VIAN said, is a copy of Java. It compiles into bytecode which is read by a virtual machine or interpreter. It shares a similarity with C++ being that its object oriented (OOP, or Object Oriented Programming), which is basically the "big thing" in programming now. If you can program in C#, you can program in Java and vice versa. For what it's designed to do, it's actually a very good language and I'd recommend it as a learning language (Java might be better since you can find more info on it... but its really the same thing). C# and Java syntax is SIMILAR (but not the same) in many ways to that of C++ and C, so if you can program in C#, you shouldnt have too much of a problem reading and editing C or C++ code. For example, I started on Java and I picked up C++ in no time at all :). I don't know about C#, but Java is definitely cross platform. You can create a Java application and have it run on windows, linux, mac, you name it. Java is more common than you'd expect. Java powers JSP (JavaServer Pages) technology, which is Sun's version of PHP or ASP (ebay, for example, is powered by JSP). Java is also used as a base for many scripting languages in games (for example, UScript which powers the Unreal engines, is based on Java), mini applets for cell phones, and other random things. IBM also uses a lot of Java technologies with their servers. It's really a great, but underappreciated language :). Since Java and C# are slightly simplified and run within specific parameters, they're considere'd "high level" languages. Other "high level" languages are Visual Basic and Perl.

Unlike C# and Java, C and C++ compile into binaries which are executed natively. The pros to this is speed and power. Programs written in C++ and C are definitely faster than their C#/Java counterparts, and could potentially do more since they run on the native machine instead of a virtual machine. The downside to this is that BECAUSE these programs run on the native machine, they're potentially hazardous and could crash your computer if you wrote something incorrectly (like if you had a stacked datastructure and blew the stack... you'd probably crash your whole computer). C# and Java programs would simply just crash the instance of the virtual machine, but your computer is left unharmed. Due to the speed and power, more demanding applications are typically written in C++ (or even partly in assembly, which is even faster). An example would be a PC game. Half-life 2 is written in C++, and part of its graphics engine is written in assembly. It's obvious why a program like that would need every bit of speed achievable :). Also, C and C++ tend to be more complicated than C# and Java since they're a lower level language than C# and Java. Assembly, though, is an even LOWER level, so its even harder.

And BASICALLY, the difference between C++ and C is that C++ is object oriented, and C is not. Yes there are other differences, but that's the main one.

As always, there are exceptions to every rule, but in a NUTSHELL, that should answer your question! If you have any more i'd be glad to help :)


Always nice that people here are willing to write up intelligent and helpful posts for others. Good on you
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Originally posted by: screw3dC+ is not a serious/real programming language.

My first thought was "WTF?", then I noticed the lack of the second plus :)
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
C is a procedural language ( http://en.wikipedia.org/wiki/Procedural_programming ) that was created to serve as a low-level system programming language. It logically followed the much-forgotten B language (not a joke), but was designed to be more powerful overall. The language is considered "old" by newer programmers because of the "stranger" ways you have to go about doing the standard tasks that many programs operate with. Dynamic memory access, containers and I/O are the main differences you'll see when comparing C to its "brother" C++ (there are, of course, more differences, but in lower-level programs, you may not see them as easily as the aforementioned).

C++ is a quasi-OO language. The reason it isn't fully Object Oriented is because it still carries a lot of the ideas of C, a procedural language. C++ kept a lot of the strong-points of C but added the benefits of an Object Oriented language such as classes (where in C, you would've used a struct). C++ is more popular than C at the moment because of the huge focus on Object Oriented in institutions of higher learning and businesses. OO can help create a neat environment and allow for more reusability between products/projects. Note that even though C++ is more common, there are still applications of programming that require C or recommend it. OpenGL was written in C and uses C command calls (which makes it really awkward to use sometimes :eek:). MPI (a multiprocessor interface API) requires the code to be written in C.

C# and Java are Object Oriented languages that're interpretted at runtime. It may sound odd, because you still compile them, but as others have mentioned, they're compiled into "bytecode", which is a standard that any implementation of a Java Runtime Environment should be able to understand regardless of the environment. These languages are easier to use and are quite a bit safer. The fact that some features are abstracted away from the programmer is what makes these languages a bit unappealing to some programmers. I mean c'mon.. we love power ;).

EDIT: Fixed the description of C# and Java. Silly me forgot to mention that they're OO :eek:.
 

Rangoric

Senior member
Apr 5, 2006
530
0
71
I don't consider the JIT version of C# and Java to be interpreted.

This includes all .Net versions of C# and most version of Java.
 

slugg

Diamond Member
Feb 17, 2002
4,723
80
91
^^ another reason why a lot of (naive) programmers don't like Java/C# is that they don't realize what it's meant FOR. Sure if you try to make a first person shooter engine out of Java, it's going to suck! If you use it for what it's meant to do, which is more like smaller more specialized programs, Java is actually great. If you ever want to get into programming, I _highly_ recommend starting with Java. Once you learn all your programming concepts in Java, its VERY VERY easy to migrate to C++ (which then makes it easy to migrate to C), Visual Basic (another misunderstood, awesome language), and C# and Java are really the same thing (I don't really know, but my understanding is the C# is "microsoft java", meaning that it's just Java with some added windows API and .NET stuff. Don't quote me though :)). Also, random scripting languages and little things will be really easy to pick up. For example, I didn't know jack about PHP and I managed to do a whole project on it for school last year relying solely on my Java programming experience. I was also able to just look at UScript, the Unreal Tournament 2004 scripting language, and pick it up in a few minutes (well, enough to edit some things around and have fun). Not to mention the fact that Java is safer ;)

As for objective C, it's not that popular. The only applications I've heard of that really use objective C are some apps on the Mac OS platform. Then again, I didnt ever learn anything about objective C, so I'm probably WAY off on that one.

edit: oh yea and like Aikouka said, C++ isnt FULLY object oriented. C# and Java are probably the most object oriented languages to date, and this is good. The future is OOP (object oriented programming) and if you're going to learn how to program, you better fully understand OOP at some point. Java and C# is PERFECT for this, since EVERYTHING (ok technically not EVERYTHING, but you all know what i mean) in the language is an object, it'll force you to pick up OOP concepts at a rapid rate.

As a side note, to further support why Java is great to learn on (has my opinion been clear yet? lol), there is a readily available and FREE development environment (IDE's, or Integrated Development Environment) for Java specifically written to LEARN Java, and programming as a whole. It's called BlueJ, and its 100% free with no fine print :)
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
Originally posted by: Rangoric
I don't consider the JIT version of C# and Java to be interpreted.

This includes all .Net versions of C# and most version of Java.

I fixed that description as they're not interpretted languages (no idea why I left out the fact that they're Object Oriented). They are, however, still interpretted whether it be before the program commences (like Java and C# do) or on-demand (like VBScript). The proper term for their interpretted-ness is Dynamic Translation or JIT (Just-In-Time (Compilation) for anyone who's not familiar and like you mentioned), so I should probably use that.

EDIT: Addendum:

You know what I found to be a fun little language to play with? VBScript. Not fun as in "malicious" but I ended up getting bored and writing my own scripting language in VBScript (yes, the redundancy is quiet apparent) that was quite featured for what it could do (loops, functions, nested variables (... my favorite feature ^_^), etc) and all in a little tiny (12kb .vbs) file. I also wrote it to be an easy to use language in that it tried to be as high-order as possible as I tried to anglicize the language (make it close to how you would say something in English).
 

slugg

Diamond Member
Feb 17, 2002
4,723
80
91
^^ but isnt Visual Basic practically English? To me at least. LOL

edit: and about JIT... Yea, it's shady. You could argue both ways. I'm sure there's a definite answer somewhere on weather or JIT is considered interpreted but I have no clue. However, 90% of the time, when you're talking Java, you're talking JVM (java virtual machine). So basically, if you want to speak in generalities, its safe to say that C# and Java are in fact interpreted languages. But like I said in my first post, there are exceptions (JIT compiling possibly being one). There are also some compilers out there that will compile from Java into a native binary (i know Borland's JCreator does this, I'm sure there's more).

BUT originally I tried to give a simplified answer in response to the OP, instead of trying to confuse him with extra minor details :p
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
Originally posted by: slugg
^^ but isnt Visual Basic practically English? To me at least. LOL

Oh, if you thought VBScript was Englishy enough... just wait until you see my language. It isn't called Stupid Simple Scripting Language (S3L) for nothing :p.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: slugg
C#, like VIAN said, is a copy of Java. It compiles into bytecode which is read by a virtual machine or interpreter. It shares a similarity with C++ being that its object oriented (OOP, or Object Oriented Programming), which is basically the "big thing" in programming now. If you can program in C#, you can program in Java and vice versa. For what it's designed to do, it's actually a very good language and I'd recommend it as a learning language (Java might be better since you can find more info on it... but its really the same thing). C# and Java syntax is SIMILAR (but not the same) in many ways to that of C++ and C, so if you can program in C#, you shouldnt have too much of a problem reading and editing C or C++ code. For example, I started on Java and I picked up C++ in no time at all :). I don't know about C#, but Java is definitely cross platform. You can create a Java application and have it run on windows, linux, mac, you name it.
Java support is still a big pain on many platforms. That will change soon enough at least for sparc and i386 platforms, as sun open sources java but we're still a long way from anything practical and more obscure architectures still won't have good jits.
Java is more common than you'd expect. Java powers JSP (JavaServer Pages) technology, which is Sun's version of PHP or ASP
That's a stretch. asp.net is closer.
(ebay, for example, is powered by JSP). Java is also used as a base for many scripting languages in games (for example, UScript which powers the Unreal engines, is based on Java),
Are you implying that unreal engines require a jvm or just that UScript is syntactically similar to java?
mini applets for cell phones, and other random things. IBM also uses a lot of Java technologies with their servers. It's really a great, but underappreciated language :). Since Java and C# are slightly simplified and run within specific parameters, they're considere'd "high level" languages. Other "high level" languages are Visual Basic and Perl.

Unlike C# and Java, C and C++ compile into binaries which are executed natively. The pros to this is speed and power. Programs written in C++ and C are definitely faster than their C#/Java counterparts, and could potentially do more since they run on the native machine instead of a virtual machine.
I'm probably going to get yelled at for this, but the 'faster' part is not nearly so simple. Jits can do a lot of optimizations that static compilers can't and, as the technology improves, jit languages will become faster.
The downside to this is that BECAUSE these programs run on the native machine, they're potentially hazardous and could crash your computer if you wrote something incorrectly (like if you had a stacked datastructure and blew the stack... you'd probably crash your whole computer).
Of course you won't crash your computer. The worst you could do is crash your program. Unless you're using an operating system from like the 80s or something.
C# and Java programs would simply just crash the instance of the virtual machine, but your computer is left unharmed.
Again, untrue. In c# and java you can't do anything to the stack, nor can you do anything to the virtual machine (provided it doesn't have glaring bugs).
Due to the speed and power, more demanding applications are typically written in C++ (or even partly in assembly, which is even faster).
Only if you really, really know what you're doing. There's nothing inherently faster about assembly language unless you know how to take shortcuts that a c compiler won't. For that to work you need to know a lot about processor architecture (pipelining and such), but it'd still never scale to the point that you could write much of significant size.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: slugg
C# and Java are probably the most object oriented languages to date,
Not by a long shot. Look at smalltalk and other such things. Heck, python's more oo than c#/java. Also, to nitpick, c# is more oo than java because its native types are directly backed by objects whereas java treats them as true natives. And in c# there's a limited ability to treat methods like objects for delegates and stuff. In java you have to hack it up with nested classes and whatnot.
and this is good. The future is OOP (object oriented programming)
It's one path to the future but I doubt it's the most important. I personally think functional programming (or at least something related to that paradigm) is more interesting because of the possibilities for seamlessly using multiple processors.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: Aikouka
I fixed that description as they're not interpretted languages (no idea why I left out the fact that they're Object Oriented). They are, however, still interpretted whether it be before the program commences (like Java and C# do) or on-demand (like VBScript). The proper term for their interpretted-ness is Dynamic Translation or JIT (Just-In-Time (Compilation) for anyone who's not familiar and like you mentioned), so I should probably use that.
You're confusing things big time. Interpetted != jitted

Interpreting means you read the bytecode, figure out what it does, execute those commands on behalf of the bytecode and throw it away to be interpreted next time it executes. JIT compilation means you read the byte code, compile it into machine code and then execute the machine code as well as storing it in memory for the next time the code executes.

JIT has more startup overhead and uses more memory but is way faster for any significant amount of computation. A virtual machine is free to use either technique or to use both at the same time (only waste time compiling the code that will run a lot). It makes no difference because your program still executes the same.

Ok, I'm done trolling, for now... :p
 

slugg

Diamond Member
Feb 17, 2002
4,723
80
91
christ... talk about tearing us apart. Aikouka and I were answering the original poster's question in a simple form... I especially mentioned a few times that i was speaking in generalities and that YES there are exceptions to the rule... calling me and Aikouka straight up wrong because we left out minor details just because we were trying to explain the jist of the whole concept to someone in a way they'd understand it was not only counterproductive, but a bit childish. I mean think about it, you just shoved what we said in our faces without offering anything useful to the thread. I guess if "showing us up" was that important to you, then go ahead and take your 15 minutes.
 

Templeton

Senior member
Oct 9, 1999
467
0
0
Originally posted by: slugg
christ... talk about tearing us apart. Aikouka and I were answering the original poster's question in a simple form... I especially mentioned a few times that i was speaking in generalities and that YES there are exceptions to the rule... calling me and Aikouka straight up wrong because we left out minor details just because we were trying to explain the jist of the whole concept to someone in a way they'd understand it was not only counterproductive, but a bit childish. I mean think about it, you just shoved what we said in our faces without offering anything useful to the thread. I guess if "showing us up" was that important to you, then go ahead and take your 15 minutes.

Oh please. You may well have been speaking in generalities, but in a number of cases those generalities were flat out wrong. What's the harm in kamper providing accurate information? Your not doing the op any favors by swaying him away from a set of languages with inaccurate info. (Java / C# are interpreted and will be slower) You should try taking the above posts as a chance to improve your knowledge and the knowledge of the greater community rather then as a personal attack; you might see the usefulness in them then.
 

Cooler

Diamond Member
Mar 31, 2005
3,835
0
0
Originally posted by: Templeton
Originally posted by: slugg
christ... talk about tearing us apart. Aikouka and I were answering the original poster's question in a simple form... I especially mentioned a few times that i was speaking in generalities and that YES there are exceptions to the rule... calling me and Aikouka straight up wrong because we left out minor details just because we were trying to explain the jist of the whole concept to someone in a way they'd understand it was not only counterproductive, but a bit childish. I mean think about it, you just shoved what we said in our faces without offering anything useful to the thread. I guess if "showing us up" was that important to you, then go ahead and take your 15 minutes.

Oh please. You may well have been speaking in generalities, but in a number of cases those generalities were flat out wrong. What's the harm in kamper providing accurate information? Your not doing the op any favors by swaying him away from a set of languages with inaccurate info. (Java / C# are interpreted and will be slower) You should try taking the above posts as a chance to improve your knowledge and the knowledge of the greater community rather then as a personal attack; you might see the usefulness in them then.
Java used to be much slower then it is now but for the most efficient coding for assembler/C is still the best. It also does not help that the JVM eats a larger amount of memory to run then a C/C++ complied code.

 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
Originally posted by: kamper
C was a high-level language when they created it ;) Heck, when I took my first C class they introduced it as a high level language (and I'm still in school).

I was referring to low-level as the scope to which the language is used. C is high order in the scope of all languages as it exists in a higher plane than Machine Code and Assembly; however, when it comes to scope of where C is used, it has a lower order than you'd see Java programs at :p. That was the point I was trying to convey, although it seems I worded it poorly.

Originally posted by: kamper
You're confusing things big time. Interpetted != jitted

Interpreting means you read the bytecode, figure out what it does, execute those commands on behalf of the bytecode and throw it away to be interpreted next time it executes. JIT compilation means you read the byte code, compile it into machine code and then execute the machine code as well as storing it in memory for the next time the code executes.

Where did I say that being interpretted means it's only compiled Just-in-Time? Generally speaking, interpretting is a basic part of translating languages into their lower-order and that was the point I was trying to convey. I was by no means referring to these languages as being part of the Interpretted Language paradigm as I fixed that gross error when I edited my previous post. Hence my use of the word (made-up or not :p) "interpretted-ness."

Also, not all interpretted languages use bytecode :p. Being precompiled into bytecode isn't a requirement of an interpretted language and the only purpose of doing so is to try to speed up processing.

Originally posted by: Templeton
You may well have been speaking in generalities, but in a number of cases those generalities were flat out wrong.

Show me a single thing I said that was wrong. The reason I even said "interpretted-ness" was to convey that they aren't true interpretted languages. Especially when I mentioned the fact that the "interpretation" is done at different points of execution.

 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: slugg
christ... talk about tearing us apart. Aikouka and I were answering the original poster's question in a simple form... I especially mentioned a few times that i was speaking in generalities and that YES there are exceptions to the rule... calling me and Aikouka straight up wrong because we left out minor details just because we were trying to explain the jist of the whole concept to someone in a way they'd understand it was not only counterproductive, but a bit childish. I mean think about it, you just shoved what we said in our faces without offering anything useful to the thread. I guess if "showing us up" was that important to you, then go ahead and take your 15 minutes.
Relax man, you said a bunch of stuff that was wrong and I pointed it out, along with supplying more useful answers. If that's not offering anything useful, I don't know what is. If you've got rebuttals to any of the above, I'd love to hear it.

Also, some of the stuff was more conversational than statement of fact, like the portability, jsp and 'future is OO' stuff. I don't have all the answers, but I love discussing this stuff :)
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: Aikouka
Originally posted by: kamper
C was a high-level language when they created it ;) Heck, when I took my first C class they introduced it as a high level language (and I'm still in school).

I was referring to low-level as the scope to which the language is used. C is high order in the scope of all languages as it exists in a higher plane than Machine Code and Assembly; however, when it comes to scope of where C is used, it has a lower order than you'd see Java programs at :p. That was the point I was trying to convey, although it seems I worded it poorly.
Yep, as you can tell, I was just in a really pedantic mood :p
Originally posted by: kamper
You're confusing things big time. Interpetted != jitted

Interpreting means you read the bytecode, figure out what it does, execute those commands on behalf of the bytecode and throw it away to be interpreted next time it executes. JIT compilation means you read the byte code, compile it into machine code and then execute the machine code as well as storing it in memory for the next time the code executes.

Where did I say that being interpretted means it's only compiled Just-in-Time? Generally speaking, interpretting is a basic part of translating languages into their lower-order and that was the point I was trying to convey. I was by no means referring to these languages as being part of the Interpretted Language paradigm as I fixed that gross error when I edited my previous post. Hence my use of the word (made-up or not :p) "interpretted-ness."
What I was getting at was that it seems like you were implying that interpretation and jitting were the same thing ("The proper term for their interpretted-ness is Dynamic Translation or JIT (Just-In-Time (Compilation)"). The term 'interpret' is mutually exclusive to the term 'jit'. If you do a jit compilation, you are not interpreting, or at least that's how someone who writes virtual machines would understand it. The reason is just that the two ways of doing it are very different and you need a term to refer specifically to the non-jit way. So yeah, you could describe the process of jitting as first interpreting the code and then producing machine code but it'd be an abuse of the technical term. Anyway, just getting pedantic again, I'm sure you already understood what I'm trying to say :)
Also, not all interpretted languages use bytecode :p. Being precompiled into bytecode isn't a requirement of an interpretted language and the only purpose of doing so is to try to speed up processing.
I think there are more purposes to going with bytecode. For instance, it's probably easier to sign and/or obfuscate bytecode. It's also smaller, so it's easier to transmit. You can also use other language syntaxes and compile them to the same bytecode. But those are all fringe benefits, of course speed is primary. :)