Which one is better C or C++

dantruon

Regular
Im a second year student at UNSW in Australia , and im currently doing C but i have experience in C++ before and I personally prefer C++, but the lecturer say that C has a better foundation and thus is better than C++.

I know some of you guy here are elite programmers, so do you agreed with my lecturer since he is elite as well, if so tell me the reasons. Thanks :)
 
Which is better, stone age or nuclear age?
I've heard some weird things come out of some teacher's mouths.

Unless your career path is going to require the extensive use of C then go with C++.
 
If you're about to do some programming for embedded apps (microcontrollers, ECU's, machines of whatever kind) or Matlab/Simulink based stuff, you'll need C. For anything else, be it PC, PDA, OS's, you name it you'll be better off with C++.

Although, C++ kinda contains C, so I don't get the point of that teacher of yours. But if he really said like you cited - he's a dumbass.
 
Most likely you have misunderstood the lecturer's statement... maybe. At least, this bit is near
C has a better foundation
As in, the student needs to think a bit lower level than the higher level abstractions. Good for building programming foundation. And no nice C++ string manipulation libraries. Nice for exercising a student's thinking about pointers, addresses, buffers.
 
passerby said:
Most likely you have misunderstood the lecturer's statement... maybe. At least, this bit is near
C has a better foundation
As in, the student needs to think a bit lower level than the higher level abstractions. Good for building programming foundation. And no nice C++ string manipulation libraries. Nice for exercising a student's thinking about pointers, addresses, buffers.

But honestly which one would you prefer
Code:
printf , scanf
or
Code:
 cin , cout

But I think you are right about my lecturer main intention of teaching us C first rather than c++. Is like teaching me addition first before showing me how to multiply.
 
i prefer printf over cout for outputting to console...
printf is a function whereas cout is an object with member methods so it should be of no surprise that printf is the more efficient of the 2
 
I've never become friends with cin and cout. The >> and << operators confused the hell out of me when I started with C++. The syntax doesn't look like anything you'd have seen before, and then you see it from the very first tutorial in C++, but you don't get to understand this syntax until you learn about operator overloads. Honestly, this is serious operator abuse IMHO.

I can throw in some words about OOP in general. It's great and all and I use it all the time. But you can certainly over-objectify stuff. For instance if you bake ints into a Integer class, which some people support, even professors. A number is not an object. Or Math.sqrt() and other silly constructs in java.
 
Or Math.sqrt() and other silly constructs in java.

I beg to differ. I use static classes whenever I benefit from them.
If it can simplify my work then I'm all for it.

Second of all a number isn't an object, hence why there is a wrapper class called "Integer" which handles parsing among other advanced integer manipulating functions.
 
K.I.L.E.R said:
...
Second of all a number isn't an object, hence why there is a wrapper class called "Integer" which handles parsing among other advanced integer manipulating functions.

Yeah that's a problem, why isn't everything object in JAVA, like it should ?
Really it wouldn't cost much to remove the 'primitive' types and make them objects too, and that would remove that int/Integer nonsense IMO.

I like JAVA but sometimes I find some things really weird or bad, like that.
 
C, C++. . . I use both in the same programs. If the functionality of one is more appropriate in a given situation, it's what I use. I prefer either to most other languages. Automatic reference counting and the inability to manually deallocate memory can be a little annoying -- and in my experience it can often lead to as much work as C/C++ memory management. :? Maybe it's just Python. . . or what I know of it.
 
It's typical of a university professor, though, to be pretty dogmatic about what he's used to. I've met all too many guys at MS who were raised on functional languages and will preach the innate superiority of Haskell or Eiffel over all other languages that may ever come into existence. But academia is even more so. My compilers professor was a Fortran fanatic. My AI professor was a Prolog person. One of my algorithms professors was actually a fan of brainf*ck... probably just because it looks so much like a straight Turing machine language.

It's just a simple matter of fact that we tend to like what we're used to. For me, that's typically C++ and Assembler. My two most frequented languages by far. Similarly, I was raised on ASM, so I've gotten completely indoctrinated with imperative langauges. Functional languages like Scheme and Haskell all bug the hell out of me. I'm not about to say that everyone else ought to agree -- I'm just saying that the path you walk is going to influence you the same way.
 
Ingenu said:
Yeah that's a problem, why isn't everything object in JAVA, like it should ?

Why should it? I don't think I've ever heard any valid reason for making ints and floats objects, other than the dogmatic opinion that OOP is good and everything else sucks.
 
so... since we're on the topic of C and all... does anyone know how to increase the stack size of an app compiled with gcc under win32 without using editbin (because I don't have #*%!(*@#$ Visual Studio)? or is this just a case of my professor being a true asshole and trying to make everyone use a goddamn iMac?

the port is MiniGW--it's what he said to use ( http://www.mingw.org/download.shtml ), but I'm grabbing Cygwin now and going to see how that works.
 
If you need that much stack space, you're doing something wrong.

Move whatever large array out of the function and into global space. Or malloc/free it.

EDIT: try gcc -Wl,--heap,1024,--stack,4096 -o blah blah.c
 
Most of the best C++ programmers I've worked with have been C programmers first. And most of the best C programmers have been assembly language programmers first.

From a pure language design standpoint C++ is pretty ugly, it's basically C pretending to be an OOP language. Objective C is a lot better designed but has its issues.

As for which is better, it depends on the job, for a large application I'll take the extra tools C++ gives me. For a small performance sensitive app, I'll still write it in C++, but I'll stick to predominantly core C functionality. C++ still gets you niceities like stronger type checking and // comments, and if you understand how various language features are implemented then you don't have any overhead.
 
Back
Top