Curso de c++ (mit)
January 4, 2011 6.096
Lecture 1 Notes: Introduction 1
1.1
Compiled Languages and C++
Why Use a Language Like C++?
At its core,a computer is just a processor with some memory, capable of running tiny instructions like “store 5 in memory location 23459.” Why would we express a program as a text file in a programming language,instead of writing processor instructions? The advantages: 1. Conciseness: programming languages allow us to express common sequences of com mands more concisely. C++ provides some especially powerfulshorthands. 2. Maintainability: modifying code is easier when it entails just a few text edits, instead of rearranging hundreds of processor instructions. C++ is object oriented (more on that inLectures 7-8), which further improves maintainability. 3. Portability: different processors make different instructions available. Programs writ ten as text can be translated into instructions for manydifferent processors; one of C++’s strengths is that it can be used to write programs for nearly any processor. C++ is a high-level language: when you write a program in it, the shorthands are sufficientlyexpressive that you don’t need to worry about the details of processor instructions. C++ does give access to some lower-level functionality than other languages (e.g. memory addresses).
1.2
TheCompilation Process
A program goes from text files (or source files) to processor instructions as follows:
Source File Compiler Object File Linker Source File Compiler Object File Libraries ExecutableOS Program in Memory
Object files are intermediate files that represent an incomplete copy of the program: each
source file only expresses a piece of the program, so when it is compiled into anobject file,
the object file has some markers indicating which missing pieces it depends on. The linker
takes those object files and the compiled libraries of predefined code that they rely on,...
Regístrate para leer el documento completo.