0.2 — Introduction to programming languages

Modern computers are incredibly fast, and getting faster all the time. Yet with this speed comes some significant constraints. Computers only natively understand a very limited set of instructions, and must be told exactly what to do. A program (also commonly called an application or software) is a set of instructions that tells the computer what to do. The physical computer machinery that executes the instructions is the hardware.

Machine Language

A computer’s CPU is incapable of speaking C++. The very limited set of instructions that a CPU natively understands is called machine code (or machine language or an instruction set). How these instructions are organized is beyond the scope of this introduction, but it is interesting to note two things. First, each instruction is composed of a number of binary digits, each of which can only be a 0 or a 1. These binary numbers are often called bits (short for binary digit). For example, the MIPS architecture instruction set always has instructions that are 32 bits long. Other architectures (such as the x86, which you are likely using) have instructions that can be a variable length.

Here is an example x86 machine language instruction: 10110000 01100001

Second, each set of binary digits is translated by the CPU into an instruction that tells it to do a very specific job, such as compare these two numbers, or put this number in that memory location. Different types of CPUs will typically have different instruction sets, so instructions that would run on a Pentium 4 would not run on a Macintosh PowerPC based computer. Back when computers were first invented, programmers had to write programs directly in machine language, which was a very difficult and time consuming thing to do.

Assembly Language

Because machine language is so hard to program with, assembly language was invented. In an assembly language, each instruction is identified by a short name (rather than a set of bits), and variables can be identified by names rather than numbers. This makes them much easier to read and write. However, the CPU can not understand assembly language directly. Instead, it must be translated into machine language by using an assembler. Assembly languages tend to be very fast, and assembly is still used today when speed is critical. However, the reason assembly language is so fast is because assembly language is tailored to a particular CPU. Assembly programs written for one CPU will not run on another CPU. Furthermore, assembly languages still require a lot of instructions to do even simple tasks, and are not very human readable.

Here is the same instruction as above in assembly language: mov al, 061h

High-level Languages

To address these concerns, high-level programming languages were developed. C, C++, Pascal, Java, Javascript, and Perl, are all high level languages. High level languages allow the programmer to write programs without having to be as concerned about what kind of computer the program is being run on. Programs written in high level languages must be translated into a form that the CPU can understand before they can be executed. There are two primary ways this is done: compiling and interpreting.

A compiler is a program that reads code and produces a stand-alone executable program that the CPU can understand directly. Once your code has been turned into an executable, you do not need the compiler to run the program. Although it may intuitively seem like high-level languages would be significantly less efficient than assembly languages, modern compilers do an excellent job of converting high-level languages into fast executables. Sometimes, they even do a better job than human coders can do in assembly language!

Here is a simplified representation of the compiling process:
Example of compiling

An interpreter is a program that directly executes your code without compiling it into machine code first. Interpreters tend to be more flexible, but are less efficient when running programs because the interpreting process needs to be done every time the program is run. This means the interpreter is needed every time the program is run.

Here is a simplified representation of the interpretation process:
Example of interpreting

Any language can be compiled or interpreted, however, traditionally languages like C, C++, and Pascal are typically compiled, whereas “scripting” languages like Perl and Javascript are interpreted. Some languages, like Java, use a mix of the two.

High level languages have several desirable properties.

First, high level languages are much easier to read and write.

Here is the same instruction as above in C/C++: a = 97;

Second, they require less instructions to perform the same task as lower level languages. In C++ you can do something like a = b * 2 + 5; in one line. In assembly language, this would take 5 or 6 different instructions.

Third, you don’t have to concern yourself with details such as loading variables into CPU registers. The compiler or interpreter takes care of all those details for you.

And fourth, they are portable to different architectures, with one major exception, which we will discuss in a moment.

Example of portability

The exception to portability is that many platforms, such as Microsoft Windows, contain platform-specific functions that you can use in your code. These can make it much easier to write a program for a specific platform, but at the expense of portability. In these tutorials, we will explicitly point out whenever we show you anything that is platform specific.

0.3 -- Introduction to C/C++
0.1 -- Introduction to these tutorials

145 comments to 0.2 — Introduction to programming languages

  • Hi Alex,

    Your tutorials are really very helpful to learn C++ easily. I’ve already started to learn and have determined to finish it. Why I would be failed to cover the whole ready made amazing lessons while the master of C++ (Alex) have already been covered up all the lessons with good explanation for learning?

    Thanks a lot sir.

  • Ganesh Bhadane

    Hi Alex,
    I have simple question. What is compile time and runtime??

  • nida

    I have no knowledge about any basics to programming. Can i complete this course?

  • Abhishek Raina

    Hello teacher,
    First of all thank you for posting this and helping all of us!
    So I have been learning java (on blueJ) for a few years and it will continue for a few more years. My problem is will learning C++ make it difficult for me to understand java? I was scrolling down the index of learncpp and most of the topics looked familiar. Is C++ similar to java or is it very different? I really wanted to learn C++ but I could not let it hinder my progress in java.
    What do you suggest?

  • Xrem

    The material in this site is so clear and straight-forward. I will try to click every add on the pages. Thank you sooooooooo much.

  • Therese McLeod

    #include <iostream>
    using namespace std;
    void doPrint()
        cout << "In doPrint()" << endl;

    int main()
        cout << "Starting Main()" << endl;
        cout << "Ending Main()" << endl;
        return 0;
    Yay, it was broken, now it’s fixed, the solution was strange, languages betwixt.

  • disha

    Hi Alex,

    Thanx aloooooott for such a beautiful website.. no words to explain how useful it is..

    I’ve a que that:

    I’ve done my bachelors degree in computers..

    if I’m learning c++ from here in a best way then of course there is no need for a classes but I wanna get certified in c++ then how will i get a certification for the same???

    I need a certification which is acceptable for all the well known companies..

    Is there any way that we can directly apply for a certification and get it.. if yes then where and how can we apply and how much expenses will it take??

    do rply plzz.. it’s really very important for me…

    and thanks in advance..

    • Alex

      There are a few companies that offer certifications in C++. Microsoft is probably the best known of the bunch. However, certifications don’t tend to be very highly regarded in programming, so I’m not sure that’s a worthwhile course of action.

  • Ben

    In what way can I support this noble effort, Alex? I am studying Cloud Computing and knowledge of C++ is required.

  • Lizzy

    Does learncpp have any connection to codecademy? Because this comment is using my codecademy profile pic.

    • Alex

      This site has no association with codeacademy. However, if you comment and use an email address that has an associated gravatar, we’ll pull it in the gravatar and display it. Look up gravatar for more information on what it is.

  • GEScott71

    This sounds great so far - thanks for the great intro.  I am going to work through this entire tutorial, and will comment after each section as to how I am doing (and likely with many questions!).

    I found many of the comments above motivating, so I’ll add a few details about myself and motivation here.

    I am a 45yo product manager of embedded systems for railroad locomotives, working for General Electric.  I am a mechanical engineer by education.  I haven’t done any programming since BASIC in junior high and 1 semester of FORTRAN in college.  I want to learn to code for 2 reasons:  1)GE is working to become a software company and I want to better understand how software is created and implemented to do my job better, and 2)There are some small personal projects I want to develop my own programs for, as I haven’t found pre-built solutions.

    Thanks Alex!

  • Clark

    Great site, I’m so happy that I found it, keep up the good work, cheers mate !

  • dontletmegetme

    I love this website

  • UKImperium

    Easy to read & learn. It’s great, not like most sites you visit where they bored you on the first sentence.

  • Suraj

    Here is an example x86 machine language instruction: 10110000 01100001 and Here is the same instruction as above in assembly language: mov al, 061h
    Can you please explain me how they are same.

    • Alex

      An assembler “compiles” the assembly instruction “mov, al, 061h” into the machine language instruction 10110000 01100001, which can be executed directly by the CPU.

  • this tutorial is the best…. like always:)
    by the way I want to learn c++ because my wish it became a game development.
    Sorry if my writing less can be understood:)

  • Dakota Cookenmaster

    This tutorial site is almost an answer to prayers. I am a Web Developer by trade (knowing HTML5 and CSS3) but I never had the chance to get into C++ or C# or JavaScript. I just got a job offer to design a program and I freaked because I had no idea how to program a program. This is a glimmer of light. I hope that it will help me with what I need to do.

  • Marko

    I do not see adds but I would like to, because I wish you earn for your effort! Why is that?

  • Saulo

    I loved this. Thanks!

  • Apollo Justice

    So simple!
    Even a child could learn from this. [One actually is] Me. I’m a sixth-grade student.

  • sho_k

    hey alex,
             pizza or mac&cheese ?

    • Alex

      A true programmer would never choose mac & cheese over pizza.

      But now I’m wondering what mac and cheese pizza would taste like.

  • RandomGuy

    i am still on elememtary, and i am already here, lol

  • Joe Lai Lim

    i am currently preparing for my university diploma in information technology course, i have completely no background or knowledge regarding programming languages and its roots, development and this websites are giving such an easy and detailed information!!! i want a textbooks which can be in this kind of format hahahah, and most importantly, it drives my thirst for knowledge in, thank you!!

  • Raza

    Can anybody explain me what this statement means in the second line of first paragraph "Computers only natively understand". I want to know what exactly author when he/she is using the word ‘natively’. I try google it, but did not found any solid answer.

  • Vidya Moger


    Compiler reads entire source code at once and loads the object code (binary data) in memory for execution.
    If my understandng is correct, then the interpreter will read each line of the code and loads the translated machine code into memory one by one.

    I am not completely understanding how compilers and interpreters loads the machine code into memory for execution. I hope you understand my queries. I am beginner.


    • Alex

      Both compilers and interpreters work through the source code one line at a time. The difference is that compilers convert all of the code into an executable ahead of time. Interpreters do it “just in time”.

  • Vidya Moger

    Wow…simple and easy to understand. First few paragraphs hooked me up to this tutorial. Hope I become a good and effiecient C++ programmer ๐Ÿ™‚ ๐Ÿ™‚
    Thanks Alex for your efforts.

  • Cirius

    Thank you for your help! I appreciate it!

  • Thanks .. nice tutorial for beginners.

  • Paul

    Thanks Alex for your hard work.
    For an old feller like me this is ideal, I have had jobs on the periphery of all this for years but never got around to getting my hands dirty.

  • hello Alex,great site and keep it up .i have a question that i want to become an expert in c++ and want to develop a game within 4 month ,can i do this . you tell me that what shall i do for this ??????please give me suggestion.

  • Alex please make the ads open in a new page…lol..Just messin

  • Hafiz Furqan


    I HOPE you are fine it is very informative but i want to ask you i am little bit knowledge of computer my education is Master of education. is it possible to learn the c plus plus ?

  • Christopher Schrock

    This is awesome! I am new to all this and preparing for a college course in the next year or so. I’m hoping to make it through all of this to fully understand! ๐Ÿ™‚

    I really appreciate all the hard WORK!

  • Nathan Choi

    Hey Alex,

    As I’m new to programming C++, I found this website quite helpful. I really appreciate all your work and effort. Thank you!

  • Ran

    What I’ve learned from this page.

            * machine language: A code that can be understand by CPU

        1. Instructions are composed of a number of binary digits.
        2. Each set of digits is translated by CPU into a specific instruction to do some task.
        3. Example: 10110000 01100001

        * Assemble language:

        1. The instructions given to CPU is a set of name (rather than a set of bits)
        2. Easy to understand by construct with machine language, but it is still hard for human to understand
        3. Fast but only to a specific CPU.
        4. Example: mov al, 061h

        * High level language

        1. Easy for human to write code.
        2. Must be translated into machine language before execute.
        3. Two ways to translate high level language into machine code: compiling or interpreting.

        * The difference between compiler and interpreter

        1. Compiler translates high-level language into executable programs that CPU can directly understand.
        2. Interpreter do not translate high-level language. It directly execute your program.

  • atul

    I read more to c++

  • toby

    Amazing tutorial….Would recommend this site to everyone

  • Amaan

    Thanks a million , in fact splendid tutorials. Great job

    please familiarise me about how to retain screen.

    i used
    before return 0;
    it doesn’t work, but when i use it twice ,like
        return 0;

    then screen retains and waits for enter key to press.

    i am usind Bloodshed dev-C++ compiler

  • Cosry

    C++ works for Roblox right? I heard it does along side LUA

    • Alex

      I’m not familiar with Roblox, but it looks like the scripting is done in LUA. However, I do see some people doing C++ stuff, so maybe there’s a way to do it.

  • adoga

    this site is the juice…very well Exemplified..better than most textbooks, and it’s free..

  • Cool into, thanks ๐Ÿ™‚

  • heidi

    amazing how simple and practical can be,thx so much guys for this lesson.

    • Alex

      Wikipedia has a good article on MIPS. The short answer is that it’s an alternative to the 80×86 architecture that many embedded and console products have used. If you’ve ever played on a Nintendo 64 or Playstation 1 or 2, you’ve used a machine that uses a MIPS architecture.

  • saira

    its amazing to learn Cpp freeeeee

  • Vex

    We’ve known more about machine language/Assemble/High level language/… ?
    A good tutorial for newbies like me. Thanks so much for sharing.

  • dss

    Hi alex,
    First of all thank you so much for providing such a good tutorial for c++.
    I have few doubts regarding above concepts and thanks in advance.
    1).How does compiler know that it is supposed to generate object file belongs to a particular CPU??  
    2).Does compiler contains knowledge of all ISAs(instruction set architectures) of all the CPUs which are availble in the market before it compiles source code??

    • Alex

      By default, compilers typically generate object files for the architecture the compiler itself runs on. Object files and executables aren’t CPU-specific, they’re architecture specific.

      A compiler generally contains knowledge of how to build executables for the specific architecture it runs on. However, some compilers are capable of cross-compiling (making programs for other architectures). For example, you could have a compiler that runs on Windows but generates iOS apps.

  • i’m a bigginer and it’s very useful for me; thanks

  • Josh Crowson

    When it says "assembly language is tailored to a particular CPU" does that mean the code only works for that single CPU or every CPU of that kind? If that makes sense.

  • Denis Piskor

    as a guy said from above. ill comment each section to show some graditude to people who made this, so….thank you ๐Ÿ™‚

  • Francisco Mendez

    Started today, lets see how quick i can learn everting im from Mexico
    i do undestand a bit off programing thx so much i will let you now how im doing gracias.

  • I have to learn this for the summer.

  • Its very useful for me, Thanks

  • Fahad Mulla

    started today lets see how quick i can grasp everything…

  • I’m a beginner so this is pretty damn awesome

  • Bernard Collins

    It’s almost like the hitchhiker coming back from the far reaches of the galaxy. It seems I’ve been everywhere and tried everything. Now I’m coming back to programming. This time I "gotta" make it.

  • jay

    nice content ,helpful for beginners

  • ansy

    very well explained

  • Ryan P W N

    Brilliant, thanks for the offering


    Thanks for a commendable job. I am saluting you for your hardwork and user friendly presentation, makes people to gain knowledge and learn programming language easy.

    Thanks & Regards

  • Dawie

  • Batuhan

    very deep tutorial and understandable thank you

  • Manvi

    Its 2015 and the tutorials on this website still rock! Well Done and thank you so much!

  • Very in-depth tutorial. I feel this site may be the answer to me learning programming. Thanks Thanks!


  • Great, and easy to understand tutorials….
    Keep the good works coming.


  • Ed

    There is a typo in first sentence.

  • Hassan ch

    How Can I Install C Turbo C or C++ on my Laptop?
    I am Running Win 8 on mah laptop.

  • Aquib Razack

    I have a doubt. It says here that assembly languages are really fast and still used today when speed is required. It is also mentioned that one line of a high level language code, will most probably take up 5 or 6 lines of assembly code. So how can assembly languages be faster?

    • Alex

      If you hand-coded assembly (and were good at it), you might be able to structure things better than the compiler, leading to better/faster results in assembly. Modern compilers are pretty good though.

  • RedScorpion

    These tutorials sound great, i cant wait to move on to the next one. Its just that i am kind of finding it hard to find key points, like what i would need to know in order to move on. Is there any part of this tutorial that i would need to know before moving on?, or is it just for informational purposes. Thanks.

  • M Spicka

    Good Morning!
    Excellent tutorials… I am looking for any articles about why someone would choose to learn to program in C++ vs Obj-C. Basically Mac vs Windows. I have a few split convictions that a purely personal and was looking for an overall understanding why one would prefer one over the other. I personally use a Windows based at work and have macs in my home. I had picked C++ purely to the face that my father-in-law is a C++ programmers and I have access to a lot of help and a potential job. Thank you.

  • JokerFrown

    I’m assuming that x64 works the same as x86?

    • x64 is an extension of x86, that allows use of more memory, and some other things. all about the developing on x64 platform can be found here -

  • ck_dragonmaster

    This is cool… Thanks

  • justin

    hi,just read the introduction,I bet it’s a great tutorial,I am new to c++,the content is easy yet informative

  • MrAlshahawy

    Hi Alex,

    Many thanks for all your efforts to help us learning C++ , It’s really appreciated.

    keep Up.

  • Hi, this post helps me so much. I wish there is a PDF version so i can read it every night before go to bed.

    Love this.

  • Ivan

    Uhh.. i just graduated highschool and want to learn into computer programming. i do not understand any of this yet.. but hopefully I can. Lol..

  • Awesome!!!!!!!!! thank you!!!!!

  • yogini

    very good explanation

  • aman

  • Jonty

    It is very easy and well detailed tutorial. I will keep following till the end.

  • Kevin

    How awesome this is. Thanks for the work done.

  • rin

    Very useful and simple to understand ๐Ÿ™‚ Thanks!

  • Angus

    I am trying to learn how to program MUD and this is helping so much with the C++ part ๐Ÿ™‚

  • melina

    you are absolutely amazing!!! before finding this i was on the verge of crying!!! this is the best tutorial ever!!! keep up the good work!!!
    and may i ask if it would be possible for you to provide us with more tutorials on other programming languages???

  • Dicennian

    Very informative, I like this tutorial. Will post everytime I’ve read a part. This one covered a lot, thanks for giving this for free.

  • this is good for biginers…..

  • jz

    THis is an amazing website..So easy for the first timers like me to understand..
    Can anybody tell me if there is any website like this for Microsoft SQL server ..

  • Its really good ,very easy understandable tutorial , thanks to the site admin .

  • Phil Martel

    A minor error:
    In the text there’s an example of machine language

    and assembler

    but the C/C++ example

    should be a = 97;

    [ Fixed. Thanks for noticing. - Alex ]

  • Pieter

    I am now porting to section 0.3 to compile some extra knowledge for my brain to interpret

  • Megha

  • Hi,

    IS there a similar site for learning JAVA also ?

    • I’m sure there is, but as I am not a java programmer, I am not personally aware of one. Perhaps another reader might be of assistance here.

    • csvan

      Raja, to the best of my knowledge, I do not think so (except for maybe the official Java tutorial from sun).

      However, if you are not afraid of digging in, check out Bruce Eckels book “Thinking in Java”. As of current, the third edition can be freely downloaded from his webpage ( This is a fantastic book that I personally value at top-level. Eckel also has two books on C++ (Thinking in C++, vol I and II), which you also may download from his site. Beware that they go deep though! How you use them is up to you. This tutorial is much more concise I think, whereas Eckels book deals with much more smaller details and technicalities (forgive me if I misspelled that!).

      Having said that, this website is by far the best tutorial I have seen online on C++, and using it in conjunction with Eckels book and an education can be a killer combination.

    • eat potatoes everyday

      As the commenter is unlikely to find this to be of any use now, I’ll leave this here for others who might find this. Oracle’s Java Tutorial ( is a pretty good one. There’s also a nice learn-by-doing style tutorial at

  • Niels

    Very nice en good information. Thanks.
    Are there any CPUs who understand each others instructions written in high-level language code? Or in other words, are build
    execuatbles compatable for certain CPUs and platforms?


    • To my knowledge, no CPU understands instructions written in a high-level language. Because of the fact that each CPU only understands specific instructions that are native to it, high-level language programs must be compiled into CPU-specific machine-code. This means executables are not natively cross-CPU.

      • Jonathan

        ahhh.i understand now. U mean CPU needs compiler in order to understand the high level language right? while enterpreter directly execute the file without compiling.

        I want to dig deeper on this. on how the cpu really connects with each other. anyway its to theoritical but interesting tho.

        Would also click the adds for the next page of this tutorial. This website is interesting.hehe

  • This tutorial continues to amaze me. Just more ways for me to refine my skills.

  • Hey There,

    I’ve been doing programming for years and have never bothered to learn more than the academics of what the real “guts” where. This tutorial was very easy to understand and makes we wanna get back down into lower level programming.

    Very well laid out and informative. Keep up the good work ๐Ÿ™‚

    , Mike

  • I’m gonna start remembering C++ programming by reading this tutorial and, according to the comments, I have to say that looks pretty good! Good job and most of all it’s really updated

  • OMAR!

    ill probably comment on every single one too. Without this, I probably wouldn’t learn computer languages until 12th grade! Screw that!!

  • Timon

    I’m probably gonna comment every single thing as I learn this. Just to show my gratitude to this website.

    Even this first chapter is amazing.

  • So Detailed, and easy, and informational, and helpful, and FREEEEEEE!!!!!!!!

Leave a Comment

Put C++ code inside [code][/code] tags to use the syntax highlighter