C vs. C++.

03/29/2012 12:43 Lateralus#1
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 injection illusion logic#2
umm i guess the only noticeable different between c and c++ is the ++ :P :P :P
03/29/2012 16:54 I don't have a username#3
You may read this:
[Only registered and activated users can see links. Click Here To Register...]
03/29/2012 17:12 KraHen#4
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 CptSky#5
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 IAmHawtness#6
D is fucking insane. I vote D.
03/29/2012 18:41 Kiyono#7
Quote:
Originally Posted by IAmHawtness View Post
D is fucking insane. I vote D.
It may sound good but any real reasons?
03/29/2012 20:16 IAmHawtness#8
Quote:
Originally Posted by Kiyono View Post
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 KraHen#9
@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 Lateralus#10
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 CptSky#11
Quote:
Originally Posted by KraHen View Post
@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 I don't have a username#12
Quote:
Originally Posted by IAmHawtness View Post
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 God. I came reading this reply.
04/03/2012 00:01 morsomgut2#13
both are good i think every system have his uses
04/03/2012 02:13 InfamousNoone#14
[Only registered and activated users can see links. Click Here To Register...] worth a read.