2009 Pearson Education, Inc. All rights reserved. 1 Part I: Compilers Part II: Pair Programming Most slides courtesy of Ms. Stephany Coffman-Wolph Many.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
2009 Pearson Education, Inc. All rights reserved.
1
Part I: Compilers
Part II: Pair Programming
Most slides courtesy of Ms. Stephany Coffman-Wolph
Many slides modified by Prof. L. Lilien (even many without explicit message).
• Plus many slides courtesy of Ms. Stephany Coffman-Wolph
• Plus slides modified and added by Dr. Lilien
2009 Pearson Education, Inc. All rights reserved.
3
• 1.1 Introduction
• 1.2 What Is a Computer?
• 1.3 Computer Organization
• 1.4 Personal Computing, Distributed Computing and Client/Server Computing
• 1.5 Hardware Trends
• 1.6 Microsoft’s Windows Operating System
• 1.7 Machine Languages, Assembly Languagesand High-Level Languages
• 1.8 Visual Basic
• 1.9 C, C++ and Java
• 1.10 Visual C#
2009 Pearson Education, Inc. All rights reserved.
4
• 1.11 Other High-Level Languages
• 1.12 Structured Programming
• 1.13 Key Software Trend: Object Technology
• 1.14 The Internet and the World Wide Web
• 1.15 Extensible Markup Language (XML)
• 1.16 Introduction to Microsoft .NET
• 1.17 The .NET Framework and the Common Language Runtime
• 1.18 Test-Driving a C# Advanced Painter Application
• 1.19 Software Engineering Case Study: Introduction to Object Technology and the UML
2009 Pearson Education, Inc. All rights reserved.
51.7 Machine Languages, Assembly Languages and High-Level Languages
• Programmers write instructions in various programming languages
• Three general types of computer languages :
– Machine languages
– Assembly languages
– High-level languages
2009 Pearson Education, Inc. All rights reserved.
6
Fig. 1.1 | Comparing machine, assembly and high-level languages.
1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)
2009 Pearson Education, Inc. All rights reserved.
7++READ LATER++ 1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)
• A computer can directly understand only its own machine language
– It consists of streams of numbers- Ultimately reduced to binary 1s and 0s
• Machine-language programs - nearly incomprehensible to humans
– Example machine-language program snippet:
+1300042774
+1400593419
+1200274027
2009 Pearson Education, Inc. All rights reserved.
8
• Machine-language programming is slow and error prone• English-like abbreviations form the basis of assembly languages
– Easier to program in them– Easier to understand them
• A computer does not understand assembly languages– Until they are translated into computer’s machine language– Translation done by assemblers
• Assemblers convert assembly-language programs to machine-language programs
– Example assembly-language program snippet:LOAD BASEPAY or: LD BASEPAYADD OVERPAYSTORE GROSSPAY or
++READ LATER++ 1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)
2009 Pearson Education, Inc. All rights reserved.
9
• Example: Assembly code and its machine code [ http://en.wikipedia.org/wiki/Assembly_language#Assembler ]
++READ LATER++1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)
NOTE: The “object code” of the assembler is the machine code
Slide added by L.Lilien
2009 Pearson Education, Inc. All rights reserved.
10
• To facilitate programming, high-level languages were developed
• Keywords in English form the basis of high-level languages– Much easier to program in them– Much easier to understand them– Look almost like everyday English with math expressions:
grossPay = basePay + overTimePay
• A computer does not understand high-level languages– Until they are translated into computer’s machine languages– Translation done by compilers
• Compilers convert high-level-language programs to machine-language programs
++READ LATER++ 1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)
– CIL code is machine-independent code– CIL code is stored in an executable file
2) CLR compiler (CLR = Common Language Runtime)– Input: CIL code– Output: Machine-language code
- Machine-dependent code - I.e. not machine-independent code- Specific to the platform running CLR Fig. from: http://en.wikipedia.org/wiki/.NET_Framework
Slide added by L.Lilien
C#
2009 Pearson Education, Inc. All rights reserved.
15
• Purpose of the Common Language Infrastructure (CLI)
– Provide a language-neutral platform for application development and execution,
- Includes functions for exception handling, garbage collection, security, interoperability
– The core aspects of the .NET Framework implemented within the scope of the CLI
- So, .NET Framework is not tied to a single language
- Instead, it is available for many languages supported by the framework
• Microsoft's implementation of the CLI is called the Common Language Runtime (CLR)
++READ LATER++ 1.17 The .NET Framework and the Common Language Runtime (Cont.)
Slide modified by L.Lilien
2009 Pearson Education, Inc. All rights reserved.
16
++READ LATER++ 1.10 Visual C#
• C# was designed specifically for the .NET platform– As a language that would enable programmers to migrate easily to .NET
• C# is object oriented– With access to a powerful class library of prebuilt components
– It has roots in C, C++ and Java- Adapting the best features of each
2009 Pearson Education, Inc. All rights reserved.
17
• Visual C# is an event-driven, visual programming language
• C# allows to write programs that respond to events such as mouse clicks and keystrokes
• Visual Studio’s graphical user interface allows to design GUIs by dragging and dropping predefined objects (like buttons and textboxes) into place
++READ LATER++ 1.10 Visual C#
2009 Pearson Education, Inc. All rights reserved.
18
• Microsoft introduced C# along with its .NET strategy in 2000
• The .NET platform allows applications to be distributed to a variety of devices
• The original C# programming language was standardized by ECMA International in December 2002
• Since then, Microsoft proposed several language extensions– Adopted as part of the revised ECMA C# standard
++READ LATER++ 1.10 Visual C# (Cont.)
2009 Pearson Education, Inc. All rights reserved.
The Complete Compilation Process
• Complete compilation process I/O: – Input: high-level language (HLL) code – source code– Output: machine-code – object code
19
Slide added by L.Lilien
2009 Pearson Education, Inc. All rights reserved.
The Complete Compilation Process (Cont.)
• Four basic steps performed by a typical compiler:
1) Preprocessing (a part of the compiler!)
- To expand macros (details later)
2) Compilation (in the narrow sense)- Translates from high-level source code to assembly code
- Not to CIL/MSIL code
3) Assembly (a part of the compiler!)
- Translates from assembly code to machine code- When there are calls to external functions in the assembly
source file, the assembler leaves the addresses of the external functions undefined, to be filled in later by the linker
4) Linking (a part of the compiler!)
- Takes one or more objects and combines them into a single executable- An executable requires many external functions from system
and run-time libraries- Creates the final executable (<name>.exe in Windows)
20
Slide modifieds by L.LilienThis and next 9 slides courtesy of S. Coffman-Wolph, a few modified (slightly) by L. Lilien
2009 Pearson Education, Inc. All rights reserved.
1) Preprocessing
• First stage of the overall compilation process
• Preprocessor processes compiler directives– ++OPTIONAL++ Technically, C# does not have a separate
Preprocessing process (it is actually done at the same time as the lexical analysis).
• Directives– Allow for conditional compilations
- To conditionally skip sections of source files,
- To report errors and warning conditions
- To have distinct regions of source code
– Always placed on their own line and begin with #