Computer Science Canada

From C++ to C

Author:  Mazer [ Wed Sep 08, 2004 3:58 pm ]
Post subject:  From C++ to C

I'm starting computer science in University tomorrow, and for some reason we're going to be doing C. Stupid prof. He/she wrote the textbook that we're using, so it seems to me that there's a bit of an ego problem here. I've never actually used C before but some of the things I've heard is that there are no classes, and the structs only let you have member variables (no functions). What are the advantages of C? What else do I need to know?

Author:  Catalyst [ Wed Sep 08, 2004 4:05 pm ]
Post subject: 

well c++ is a superset of c, so you lose a bunch of nice features (such as classes, templates, new and delete, among others). But you supposedly gain a small speed increase. The reason they probably start with c is to avoid diving into oop right away

Author:  Mazer [ Wed Sep 08, 2004 4:18 pm ]
Post subject: 

I figured as much. Which is just dumb. OOP is easier. So I no longer get to use new or delete... what is it now malloc() and free() or something? Bleh. At least it's not turing?

Author:  rizzix [ Wed Sep 08, 2004 5:51 pm ]
Post subject: 

yea well look at it this way.. it has been tested that c++ is much slower than C. thats why c++ is never used for creating realtime OS's or programs.. u know stuff used in robots/spacecrafts// etc... wherever performance is crucial. it is important u know C.. some stuff is a little different for the normal C++ way of doing things.

PS: after learning C, objective-c is a piece of cake.. u should take a look at it.

PSS: i dont really see a diff in performance in C++ and C.. but statistically there supposed to be Confused

Author:  wtd [ Wed Sep 08, 2004 7:03 pm ]
Post subject: 

C as a language is actually much better suited to teaching than C++. C++ features a byzantine syntax with a lot of rules, and even more exceptions to those rules. C is much simpler.

This doesn't mean that C is necessarily a better language, but it makes it easier to learn.

A quick translation:

code:
// C++

#include <iostream>

int main()
{
   std::cout << "Hello, C++" << std::endl;
}


code:
/* C */

#include <stdio.h>

int main()
{
   puts("Hello, C");
}

Author:  Acid [ Thu Sep 09, 2004 1:38 pm ]
Post subject: 

I remember hearing a quote that went something like, "Programming with C makes it easy to shoot yourself in the foot. In C++ it's harder, but when you do you take the whole leg."

Author:  Andy [ Thu Sep 09, 2004 3:15 pm ]
Post subject: 

and that is relevant to his question how?

Author:  rizzix [ Thu Sep 09, 2004 4:48 pm ]
Post subject: 

well you dont want to C a shot foot.. even worse is Cing plus plus the rest of your body damaged.

Author:  Andy [ Thu Sep 09, 2004 6:04 pm ]
Post subject: 

LOL nice... very nice rizzix

Author:  Acid [ Fri Sep 10, 2004 1:05 pm ]
Post subject: 

dodge_tomahawk wrote:
and that is relevant to his question how?


I was just saying. It wasn't supposed to be relevant to the question.

Author:  bugzpodder [ Fri Sep 10, 2004 3:22 pm ]
Post subject: 

personally i am having a lot of trouble with that also (dont ask me why i want to write my programs in C)

some of this are compiler dependant

first of all, this wont work: int f(int &a, int &b)
secondly this also wont work

.....//some code
int a;

as intializations must be placed on the top

and one more problems, it doesnt like // comments. i think /* works */

as well as a lot of other things i dont know

Author:  Andy [ Fri Sep 10, 2004 4:30 pm ]
Post subject: 

so what are you supposed to do in the case of int f(int &a, int &b)?

Author:  Catalyst [ Fri Sep 10, 2004 4:31 pm ]
Post subject: 

use pointers probably

Author:  Andy [ Fri Sep 10, 2004 4:35 pm ]
Post subject: 

argg..... not that i dun like pointers, im just lazy

Author:  bugzpodder [ Fri Sep 10, 2004 4:47 pm ]
Post subject: 

Catalyst wrote:
use pointers probably


yes, something like int f(int *a, int *b){ *a^=*b^=*a^=*b;} //doesnt work if a=b

Author:  Mazer [ Fri Sep 10, 2004 5:15 pm ]
Post subject: 

It gets worse than my preference of C++ over C. First day of class the professor seems to think we're impressed by her use of... Bonzi Buddy. Yeah. There had to be about a hundred people in there, not laughing with her, but at her. And I'm told that she does this "all the time". Talk about injustice. Actually, terrorism is more like it.

Author:  Andy [ Fri Sep 10, 2004 5:24 pm ]
Post subject: 

ROFL... poor mazer... tats what u get for going to windsor

Author:  Dan [ Fri Sep 10, 2004 6:23 pm ]
Post subject: 

wow, what kind of insturcter do u have? Do they even have a phd in compsci?

Author:  Mazer [ Fri Sep 10, 2004 6:44 pm ]
Post subject: 

Unfortunately.

PS: please give me powers in the C/C++ section so I can edit dodge's post, and proceed to shoot him in the face later. Thanks.

Author:  Andy [ Sat Sep 11, 2004 6:50 am ]
Post subject: 

rofl u noe im just playin around wit ya


: