|
You last visited: Today at 10:21
Advertisement
C vs. C++.
Discussion on C vs. C++. within the CO2 Programming forum part of the Conquer Online 2 category.
03/29/2012, 12:43
|
#1
|
elite*gold: 0
Join Date: May 2005
Posts: 1,892
Received Thanks: 920
|
C vs. C++.
I read a lot about the differences, benefits, and disadvantages, but if you have programmed anything with the two, please explain the benefits and disadvantages of both.
Edit: vs. D, if you are knowledgeable about all 3 and want to extend that much.
Edit 2: More importantly, I'm wanting to know if there are any reasons to use C over C++, and C++ over D.
|
|
|
03/29/2012, 14:57
|
#2
|
elite*gold: 0
Join Date: Jan 2012
Posts: 164
Received Thanks: 22
|
umm i guess the only noticeable different between c and c++ is the ++ :P :P :P
|
|
|
03/29/2012, 16:54
|
#3
|
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
|
You may read this:
|
|
|
03/29/2012, 17:12
|
#4
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
|
In my opinion, instead of minimal speed differences, it all comes down to the question : do you want OOP? I know that you can some of it with C using structs, but meh. Also, you can always write your lower level code in C, then create an encapsulating C++ class for it, the beauty is that you can use both at the same time.
|
|
|
03/29/2012, 18:00
|
#5
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,444
Received Thanks: 1,176
|
C++ is OOP, so, it's an higher level language than C. More your language is higher, less you have control on things... And more you're program will not be "optimized". Actually, the difference will be seen in things like OS kernel... As C++ is an extension of C, you can use both in your project, so, I'll say, use C when you really need big control on resources and output and use C++ when you want OOP. (N.B. C++ program that do the same thing than a C program will probably give a more complex ASM output. Less optimized) For memory management, file I/O, string manipulation, I tend to use C over C++. For other things, I use OOP.
It's my opinion.
|
|
|
03/29/2012, 18:02
|
#6
|
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,199
|
D is ******* insane. I vote D.
|
|
|
03/29/2012, 18:41
|
#7
|
elite*gold: 20
Join Date: Jun 2006
Posts: 3,296
Received Thanks: 925
|
Quote:
Originally Posted by IAmHawtness
D is ******* insane. I vote D.
|
It may sound good but any real reasons?
|
|
|
03/29/2012, 20:16
|
#8
|
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,199
|
Quote:
Originally Posted by Kiyono
It may sound good but any real reasons?
|
It's like the big brother of C++. Same features of C++11 plus garbage collection, no need for header files, completely object-oriented, and many other features. Unfortunately, there aren't many good IDEs around, yet  .
|
|
|
03/29/2012, 20:44
|
#9
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
|
@CptSky : It will give a more complex ASM code only if you use C++ headers, but you can always use the C headers, also it`s a bit compiler dependent. Regarding file I/O, I did some tests with in the near past, turns out that fprintf() is waaaay faster than fstream& operator::<< in GCC (MinGW) 3.x.x, though in 4.x.x << wins hands down. So as compilers evolve, subjects of debate tend to change.
|
|
|
03/29/2012, 22:40
|
#10
|
elite*gold: 0
Join Date: May 2005
Posts: 1,892
Received Thanks: 920
|
I think I'm going to force myself through hell and try a large scale project in C over the summer when I want to take a "break" from the source Korvacs and I are developing. I'm talking about using Notepad++, the GCC compiler, and creating my own makefiles. I've been spoonfed by VS for a long time. But please continue the discussion - I'm still interested, and this is an interesting thread.
|
|
|
03/29/2012, 23:49
|
#11
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,444
Received Thanks: 1,176
|
Quote:
Originally Posted by KraHen
@CptSky : It will give a more complex ASM code only if you use C++ headers, but you can always use the C headers, also it`s a bit compiler dependent. Regarding file I/O, I did some tests with in the near past, turns out that fprintf() is waaaay faster than fstream& operator::<< in GCC (MinGW) 3.x.x, though in 4.x.x << wins hands down. So as compilers evolve, subjects of debate tend to change.
|
Not only when you use C++ headers. Just the fact of using classes and objects will produce more complex ASM code as the code has to be structured with the objects and not only a few methods in the application.
As you said, optimization is compiler dependent... So, sometimes the same C code will be slower than the same C++ code. But, it won't remove the fact that being an higher language, C++ will be less optimized and more complex. In term of speed, memory management, etc. C++/CLI is an extension of C++ that add support of a garbage collector. The result is less optimized than a C++ application... You have less control on memory because a part is managed by the GC... For the output, it way more complex because it contains ASM and CIL bytecode.
|
|
|
03/30/2012, 07:35
|
#12
|
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
|
Quote:
Originally Posted by IAmHawtness
It's like the big brother of C++. Same features of C++11 plus garbage collection, no need for header files, completely object-oriented, and many other features. Unfortunately, there aren't many good IDEs around, yet  .
|
Oh ***. I came reading this reply.
|
|
|
04/03/2012, 00:01
|
#13
|
elite*gold: 0
Join Date: Jun 2008
Posts: 146
Received Thanks: 40
|
both are good i think every system have his uses
|
|
|
04/03/2012, 02:13
|
#14
|
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
|
 worth a read.
|
|
|
All times are GMT +1. The time now is 10:22.
|
|