Download presentation
Presentation is loading. Please wait.
1
Introduction to Computer Programming
2
Overview What is programming?
What are computer languages and how have they evolved? What is the basic process of programming, including the tools involved?
3
A step-by-step set of instructions to accomplish a task.
Algorithm A step-by-step set of instructions to accomplish a task. Example: Make KoolAid - Fill jug with water - Add KoolAid mix - Stir - Pour from jug into cups
4
expressed in a Computer Language
Computer Program A step-by-step set of instructions to accomplish a task expressed in a Computer Language
5
Computer Languages Machine Language
- Consists of binary codes for very simplistic commands Ex: 1001 (move), 1100 (add) - Codes differ by CPU model - Is the only language a CPU can follow - Using ML Requires detailed knowledge of the CPU/hardware.
6
Computer Languages ENIAC being programmed Machine Language
Univ of Penn, 1940’s (photo: U.S. Army)
7
Computer Languages Assembly Language
- Consists of text codes for very simplistic commands Ex: ADD, SUB, MOVE - Codes differ by CPU model - 1-to-1 translation to Machine Language - Using Assembly requires detailed knowledge of the CPU/hardware
8
Computer Languages High Level Language
- Consists of text codes for more complex expressions - Codes standardized across CPU models - 1-to-Many translation to Machine Language - Does not require detailed knowledge of the CPU/hardware.
9
Computer Languages ML vs ASSM vs HLL Assembler: Machine Lang:
to CPU:R to CPU:R ADD MOV CPU:REG High Level Language: x = a + b
10
Early High Level Languages
Computer Languages Early High Level Languages Fortran (FORMula TRANSlation) - by IBM, 1950’s - Number cruncher for mathematicians, scientists and engineers. - Ex: A = * R * R; - Very poor at manipulating “pretty” output and large volumes of data.
11
Early High Level Languages
Computer Languages Early High Level Languages COBOL (COmmon Business Oriented Language) - by committee, funded by DoD, 1960 - For business/management apps: does “pretty” and handles large volumes of data easily. - Very English-Like. Ex: ADD SUBTOTAL TO TAX GIVING TOTAL.
12
Computer Languages High Level Languages C
- by Dennis Ritchie (AT&T), 1972 - Combines ease-of-use of a HLL with the “power” of Assembly - Used to write efficient systems software (Unix Operating System)
13
Accomplishing a task using the least amount of resources.
Computer Languages Efficiency Accomplishing a task using the least amount of resources. In Programming, “resources” are: - Time (number of instructions executed) - Space (amount of memory required)
14
Today: one of the most common languages.
Computer Languages High Level Languages C++ - By Bjarne Stroustrup (AT&T), 1983 - Enhancement of C: major items: - Object-Oriented Programming - Extensibility: programmers can add new features to the language itself. Today: one of the most common languages.
15
Programming Process Tools, Files and Errors
16
Programming Process Software Tools
Editor – used to write the program in a HLL. Compiler – translates program in a HLL into Machine (or other low level) Language Linker – combines Object Files into an Executable. Loader – copies an Executable into memory and starts program execution.
17
Programming Process Software Tools
Integrated Development Environment (IDE) Combines the editor, compiler, linker, loader and often other helpful tools into one programming tool. Example: Microsoft Visual Studio IDE
18
Programming Process Files
Source – a text file containing a program written in a HLL Object – part of a program translated in Machine Language Executable – a complete program in Machine Language
19
Programming Process Errors
Syntax (aka Compiler) – found in the Source, these are violations of the rules for writing programs in the HLL. Link – the linker is unable to link the object files into an executable. Typical errors indicate something is missing or the parts (objects) do not “fit” together as expected.
20
Programming Process Errors
Load – the loader is unable to copy the executable into memory and start execution. Typical errors include “not enough memory” or “not a trusted program” (virus protection). Run-Time – occurs during execution. Typical errors include “division by 0”, “file not found”, “memory access violation”. Execution halts when a RTE occurs; normally called a “program crash” and may not have an error message.
21
Programming Process Errors
Logic (Semantic) – when there is no error from the perspective of the computer, but rather the program does something unexpected by the user. Example: The program prints: The area of a square with a length of 3m is 6m2
22
Errors Bug informal name for a Logic (or Run-Time) Error
Programming Process Errors Bug informal name for a Logic (or Run-Time) Error
23
Conclusion - Programming is writing instructions for a computer to follow. - Various languages have been invented over the years to assist programmers. - While variations exist, there is a basic process for writing code in a HLL and translating it into ML, including use of a basic set of tools.
24
Vocabulary Term Definition Algorithm
A step-by-step set of instructions to accomplish a task Program A step-by-step set of instructions to accomplish a task expressed in a computer language. Machine Language Binary computer language that differs by CPU model…the only language a computer can follow. Assembly Language Language made up of simple text codes for simplistic instructions. It differs by CPU model and has a 1-to-1 translation of commands into Machine Language. High Level Language Language made up of more complex and human-language-like codes with a 1-to-many translation of commands into Machine Language. FORTRAN Early language used to solve mathematical/scientific/engineering problems. COBOL Early language used for business data processing. C Language combining the functionality of a HLL with that of Asssembly, used to write Systems Software.
25
Vocabulary Term Definition C++
An enhancement of the C language providing support for Object-Oriented Programming and language Extensibility. Extensibility The ability of a programmer to extend an existing language with new features. Editor Software tool that allows a programmer to write a program in a HLL. Compiler Software tool that translates a program in a HLL into Machine Language. Linker Software tool that combines Object Files into a single Executable. Loader Software tool that copies an Executable into memory and initiates program execution. Source File Text file that contains a program written in a HLL. Object File File that contains instructions in Machine Language, but is not a complete program. Executable File File that contains instructions in Machine Language that is a complete program.
26
Vocabulary Term Definition Syntax Error
Violation of a HLL rule in a Source File, discovered by the Compiler Compiler Error (same as Syntax Error) Link Error Error meaning the Linker is unable to combine Object Files into an Executable Load Error Error meaning the Loader is unable to copy an Executable into memory and initiate program execution. Run-Time Error Error that occurs while a program is executing, causing the program to halt. Logic Error Unexpected output/behavior of a program when there is no other type of error. Semantic Error (same as Logic Error) Bug Informal word meaning Logic (or Run-Time) Error
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.