Geek Out!

live.pirillo.com

More Information

Hi!
I started up recently learning the C programming language and thought of learning C++ next. However I've been seeing around the web that learning C first gives bad programming habits and that it was not recommended.

Should I learn C or C++ first? And what's the best way to learn? Not just copying code and not knowing what it's for.
My primary computer is a MacBook Pro running 10.5, what are some good software?

Thank you!

Marcel Diallo

Tags: C, C++, Mac, programming

Views: 1

Reply to This

Replies to This Discussion

my understanding is that both languages are the same well... C++ is just an extension of C. so if you learn either you could write for either



thats how i see it but i know next to nothing about C lol
C and C++ are very similar, actually you can code C stuff with C++ because C++ is backward compatible. The main difference between C and C++ is that C++ has object oriented programming features with it. This means that you can make objects from classes, similar to how you would do with java. However the difference to java is that C++ does not force you to start with OOP, but you can if you wish.

About good software to use, well since you use a mac you can use XCode, which is available for Macs only, however I think you have to install it additionally to your OS X stuff, but you can install it from your install CD from the folder "Additional Software" or similar.

So it depends what you want to do, if you want to code in object oriented programming then use C++, otherwise use C only.

I hope this helps,
Cheers!
Oliver,
What would be the advantage of coding in Object oriented ?
Don't hesitate to explain it to me as if I was an idiot (I'm still really new, the most complicated program I've written was a calculator that didn't start again at the end of each operations)

Thank you
The advantage of OOP is that you have both methods/functions and attributes/variables stored in one places - in the class. With classical procedural programming, like in C, those functions and variables are seperate. Now if you want to change something you would have to change it everywhere the function is defined or the variable is defined. In small programs this may not be an issue, but with a big project where you have many source files this can be a pain to just change a little thing.
In OOP however you can define one header file with the Class, within the class you have your variables and methods/functions defined, however you use the object with its methods and attributes somewhere else. BUT the attributes and methods are only defined within the class. This means that if you want to change something, you just need to change it in one place and use it where ever you want.

The other thing is data-hiding. If there is a variable or a method that is only used for internal workings, you can set those to private, and those variables or methods will not be viewable outside of the class. This gives you a big deal of security.

The basic idea of OOP however is to treat a program as a real thing. Every "thing" has attributes such as color, size, weight, tastes, and so on. Every thing also has behavours (in c++ named methods) like moving somewhere, stopping, growing, or whatever else. so this makes it more easy to imagine to program some real thing. with OOP you can put those behavours and attributes in one spot and use it as an instance of the class.

I hope this gives you an idea of what OOP is and what its advantages are.

Cheers.
Thanks a lot, it was really useful.

Marcel

RSS

© 2013   Created by Chris Pirillo.

Badges  |  Report an Issue  |  Terms of Service