locked
Diff b/w Compile time and run time RRS feed

  • Question

  • Can anybody explain....what will happen when we do compile and runs our program.

    And which keyboard keys we will use for doing both.

     

    kavitha

    Saturday, March 3, 2012 5:46 PM

Answers

  • Hello Kavitha,

    When you compile a program:

    A program called a compiler reads your source files

    • In a first phase called scanning or lexing: It splits your source code into tokens usually based on keywords and literals of the languages
    • In a second phase called parsing: It checks the syntax of the language (order of the tokens), and builds an internal structure to manipulate your code called Abstract Syntax Tree (AST), it can do type checking during this phase or on a third phase.
    • In a third phase it applies some transformations, mainly to optimize your code.
    • Then in the case of .NET languages like C# it generates an intermediate language (IL) called MSIL (MicroSoft Intermediate Language).
    • It checks and link some of the dependencies of your code.
    • It generates your binary called an assembly. 

    When you run a .NET program (assembly) some others program coming from what we call the .NET Runtime or CLR for Common Language Runtime read the binary informations from your program and translate them on the fly (Just In Time compilation) to operations understandable by your processor, allowing your application to run.

    I hope my answer is clear, and not too detailed.

    When you use Visual Studio you can compile/build and run your programs from the menu bar, from the solution explorer or pressing F6 to build only and F5 to build if not done and run.

    Dorian


    • Proposed as answer by DorianCorompt Saturday, March 3, 2012 6:56 PM
    • Edited by DorianCorompt Saturday, March 3, 2012 6:57 PM
    • Marked as answer by Lie You Friday, March 9, 2012 2:31 AM
    Saturday, March 3, 2012 6:56 PM