Introduction To C C

What is C++?

C++ is a programming language. Alright smart guy. What is a programming language?

What is a Programming Language?

Now thats a better question. First and foremost, there a hundreds of different programming languages. C++ / Java / C# / Visual basic / Java Script, PHP… So what do they all do? Every programming language is just a bunch of instructions.

Me:  "Hey Bob!  Grab me some Tim Hortons."
Bob:  "Sure thing man." and bob goes to grab me some Tim Hortons.

See how easy it is to program :) I just programmed Bob to get my some Tim Hortons. The language I used to program Bob is English.
It works out well because I know English and Bob knows English.

Now suppose I go to France where I try to program Jacque to grab me some coffee. Yet, Jacque only speaks French.

Me:  "Hey Jacque!  Grab me some Tim Hortons."
Jacque:  "Vous voulez dormir avec Tim Horton ? Et moi ?"

Jacque has no idea what to do, and I've just created a confusing situation. You see I was trying to program Jacque using the English programming language, but Jacque only understand the French programming language. C'est dommage n'est-ce que pas?

So now lets apply it to your computer. You computer will obey every single thing you tell it to do. You just have to tell it in a language it understands. That language is a programming language.

So a programing language is a language you use to tell your computer what to do. Fair enough.
You might ask why don't think just create an English programming language for computers.
If they could, they would. We keep getting better at it actually. Yet, we're not quite there yet.
It's sad to say, but I've gotten so used to programming languages like C++, I read them as well as English. To a large extent, the makers of programming languages have tried to make it as similar to English as possible. We'll see that later.

But I thought computers speak binary not C++? What about all the 0101010010010100101 stuff?

Oh, someone is advanced! Technically all a computer understands is binary. In the same way as all our brains understand are electric impulses and chemical reactions. But do I tell you what to do in the form of neurons? No, you understand English. So I can tell you what to do in English.

In a similar way. A computer understands C++, Java, C#… so that is what the instructions are given in. Yes, for the technically superior among us, there is actually a compiler, which compiles the programming language into a form usable internally by the computer full of 1's and 0s. But here's a similar analogy. As you read this text, your eyes pick it up and that data is sent somewhere in your brain. Your brain translates/'compiles' it into neurons impulses and chemical reactions and in doing so understands what is being written.

I present this way not to encourage ignorance but to generalize it a bit. Today with dynamic languages and scripting, there really isnt that traditional compile->link->binary sequence. By all means read up on bits and bytes and opcodes :)

Should I learn C++?

Well it depends. C++ was the first language I learned. I've learned many other since then. I think C++ is one of those languages that if you really know it, you can pretty much learn any other language with the exception of strange ones (like Prolog). C++ will teach you all the fundamentals. Also, because of its many 'flaws', it will teach you very good habits for other languages.

What's the difference between C and C++?

There's many differences, but also many similarities. First, they invented C. Then they wanted to introduce some new concepts (i.e Object Oriented programming), so they added some stuff to C and called it C++. Make no mistake about it though, it is a vast language and you will probably never know every single detail. Just like you will never know every single word in the dictionary.
As I go through this wikibook, don't be surprised if I mix and match C/C++. It's a gradual progression.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License