Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [C++ - Untold Stories] The Beginners Guide to the World
Index -> Programming, C++ -> C++ Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
haskell




PostPosted: Wed Dec 27, 2006 1:53 pm   Post subject: [C++ - Untold Stories] The Beginners Guide to the World

C++ is a pecular language. It has countless styles, is multi-paradigm, and has so many religions and ferocious debates surrounding it, that it seems more like a cult than a programming language.

code:
So then what the hell is this?


This is a nice little guide for beginners interested in learning C++. However, some of the stuff may just be helpful to more experienced programmers as well, not just the C++ users.

code:
Sweet! Lets get bis-eh(busy)!


Sure thing.

Important Stuff before you begin

Basic programming concept knowledge is expected!

I recommend the following articles for you to read before you even go at it:

- Teach Yourself Programming in Ten Years by Peter Norvig
- An Introduction to Object-Oriented Programming
- Object Oriented Thinking
- Becoming a Real Programmer(Thinking About Thinking)

code:
Holy crap! Thats a lot of articles!


Yes, but they are crucial into getting a quick idea into what you are getting yourself into.

How-to Learn Object-Oriented Programming

In my opinion, if you are going to learn to be an object-oriented programmer, then you should start by programming in an object-oriented way. C++ is a great object-oriented language, but I must say that many many resources seems to place the most basic object-oriented concepts at the more advanced chapters, when in reality it should be there with the basics.

Which leads me to my first point. Use object-oriented concepts, such as classes, objects, and polymorphism as early as possible! C++, How to Program is a good book for this in particular.

code:
Should I learn C first? C and C++ are similar


Nope, and no they are not. An actual C application and an actual C++ application are completely different at the source code level. Sure, they share a few cosmetic similarities, but deep inside, they are two completely different beasts. They have two completely different ways of thinking, and are structured accordingly. If you want to be a C++ programmer, learn to program C++ as it was concieved, for object-oriented programming and generic programming. Sure it can be a procedural language, but if you are going to program C programs with C++, then you are better off with C.

code:
No wai!


Yes wai.

code:

#include <iostream>
    using std::cout;
    using std::endl;

class HelloWorld{
    public:
        HelloWorld()
        {
            cout << "Hello, world!" << endl;
        }
};

int main(){}

HelloWorld myHelloWorld;


code:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Hello, world!\n");
    return 0;
}


As you can see, I deliberately made these two identicle programs in two very different ways.

Now for the independant study, if you are still interested

Here comes the articles and free books that you can use on your quest to C++ programmer prowess:

- Thinking in C++
- C++ in Action: Industrial Strength Programming
- Google

Remember, use Google, it is a programmer's best friend.

code:
What compiler should I use?


I always recommend GNU(gah-new) tools, like GNU C++, which can be gotten from the official GNU site or MinGW. If you don't know which packages to download, you need the following:

Quote:

gcc-core
gcc-g++
binutils
mingw-runtime
mingw-utils
win32api


code:
Wow! Will you eva update dis here?


With time, yep.

Thank you for reading! Any comments, questions or errors, feel free to post, pm or contact me in any other means
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Thu Dec 28, 2006 8:03 pm   Post subject: (No subject)

Actually C and C++ are similar. That is, C++ is more or less a superset of C.
haskell




PostPosted: Fri Dec 29, 2006 3:29 pm   Post subject: (No subject)

Cosmetically, yes. The syntax is basically the same(except for templates, and the new keywords).

But beyond that, they are not the same. The base language is almost identicle, but due to the OOP and STL, they are two completely different beasts. Two different ways of thinking, and two completely different ways of program structure.
[Gandalf]




PostPosted: Fri Dec 29, 2006 4:50 pm   Post subject: (No subject)

"identicle" -> "identical" Smile

While they are two completely different languages, all the "superset" part means is that C++ builds off or adds on to C. The "more or less" part comes from the numerous instances where C++ changes things that are in C.
haskell




PostPosted: Sat Dec 30, 2006 11:20 pm   Post subject: (No subject)

Its more like "their" and "there".

It doesn't build or add on to C, it replaces it. It builds off and adds to the C base language(keywords), but it completely and utterly replaces the stdlib with the STL. The entire "language" is the libraries.

C is purely a procedural language. Leading to a modular state of mind(most of the time on actual applications).

C++ is a generic/OO/procedural language. It shares keywords and syntax with C, and the basis of modular coding(though classes and headers make it object-oriented design).

Which changes the thinking from "how do I make logical modules that I can easily implement and possibly re-use later" to "how do I make this class easy enough to implement now, yet abstract enough to be used later". Which are, when you are actually doing the design up(often UML for OOP), it is drastically different.

Basically, forget that fact that C++ is based off of C. It doesn't mean that they will be similar in any way besides cosmetically. If you look at it without that notion that "C++ is based off of C, therefore they are similar". A language is based off a paradigm. Programming paradigms are often very contrasted. C was based off one paradigm, C++ was based off another. Making C++ and C very different.
wtd




PostPosted: Sun Dec 31, 2006 12:46 am   Post subject: (No subject)

haskell wrote:
Which changes the thinking from "how do I make logical modules that I can easily implement and possibly re-use later" to "how do I make this class easy enough to implement now, yet abstract enough to be used later".


If you study C++ and its support of OOP in detail, you can see that the choice of default behaviors indicates that the designers intended for re-use in the subclassing sense to be relatively rare.
haskell




PostPosted: Wed Jan 03, 2007 4:31 pm   Post subject: (No subject)

That was a while ago. OOP has changed. So has programming.

Developer time is worth more than processor time now. Back when C++ was created, it wasn't like that. So crafting the most efficient code for the problem at hand was more important than saving time by code re-using.

Now, it is kind of like, re-use all you can, you can make optimizations
IF the application isn't up to par. Which is where OOP is pretty much now... Since C++ is mainly used as an OOP language, it is also used often in this sense. And it is, IMO, one of the best languages that allow re-usability on a scale the programmer is used to(headers ^^).

For those who don't know, this type of re-usability is often done in two parts. The class definition(has all the vars, classes, types, etc...), and the class code. The definition is done in the header, and the code in another CPP file. You can change the code of the CPP file completely, but as long as you keep everything named the same, and don't add any new public/global vars that the implementer needs, you can keep the implementation seperate. Which allows for very robust modular programming with an OOP language. And the code is re-usable, sometimes.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: