![Page 1: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/1.jpg)
CMPE13 Cyrus Bazeghi1
Programming Languages
Telling computers what to do
![Page 2: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/2.jpg)
CMPE13 2
Objectives
• Describe what programmers do and do not do
• Explain how programmers define a problem, plan the solution and then code, test, and document the program
• List and describe the levels of programming languages – machine, assembly, high level, very high level, and natural
• Describe the major programming languages in use today
• Explain the concepts of object-oriented programming
![Page 3: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/3.jpg)
CMPE13
Program
Set of instructions written in a programming language that tells the computer what to do
3
![Page 4: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/4.jpg)
CMPE13
Programmers• Prepare instructions that make up the
program• Run the instructions to see if they
produce the correct results• Make corrections• Document the program• Interact with
– Users– Managers– Systems analysts
• Coordinate with other programmers to build a complete system
4
![Page 5: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/5.jpg)
CMPE13
The Programming Process
• Defining the problem• Planning the solution• Coding the program• Testing the program• Documenting the program
5
![Page 6: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/6.jpg)
CMPE13
The Programming Process: Defining the Problem
• What is the input• What output do you expect• How do you get from the input to
the output
6
![Page 7: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/7.jpg)
CMPE13
The Programming Process: Planning the Solution• Algorithms
– Detailed solutions to a given problem• Sorting records, adding sums of numbers,
etc..
• Design tools– Flowchart– Pseudocode
• Has logic structure, but no command syntax
• Desk-checking– Personal code design walk through
• Peer Reviews– “Code walk through”/structured walk
through
7
![Page 8: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/8.jpg)
CMPE13
The Programming Process: Planning the Solution
Accept series of numbers and display the average
8
![Page 9: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/9.jpg)
CMPE13
The Programming Process: Coding the Program
• Translate algorithm into a formal programming language
• Within syntax of the language• How to key in the statements?
– Text editor– Programming environment
• Interactive Development Environment (IDE)
9
![Page 10: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/10.jpg)
CMPE13
VI
• Mode editor, comes with pretty much all UNIX/LINUX distros
• Insert or command modes• Cheat Sheet
http://www.lagmonster.org/docs/vi.html
10
![Page 11: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/11.jpg)
CMPE13
Emacs
• A very “rich” editor• More than just an editor• Cheat Sheet
http://ccrma.stanford.edu/guides/package/emacs/emacs.html
11
![Page 12: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/12.jpg)
CMPE13
The Programming Process: Testing the Program
• Translation – compiler– Translates from source module into object
module– Detects syntax errors
• Link – linkage editor (linker)– Combines object module with libraries to
create load module– Finds undefined external references
• Debugging– Run using data that tests all statements– Logic errors
12
![Page 13: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/13.jpg)
CMPE13
The Programming Process: Documenting the Program
• Performed throughout the development• Material generated during each step
– Problem definitions– Program plan– Comments within source code– Testing procedures– Narrative– Layouts of input and output– Program listing
13
![Page 14: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/14.jpg)
CMPE13
Choosing a Language
• Choice made for you– What is available?– Required interface
• What do you know best?• Which language lends itself to the
problem to be solved?
14
![Page 15: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/15.jpg)
CMPE13
Language Generations
• Low levels closer to binary• High levels closer to human
code• Five Generations:
– Procedural Languages• Machine language• Assembly language• High-level language – 3GL
– Nonprocedural Languages• Very high-level language – 4GL• Natural language – 5GL
15
![Page 16: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/16.jpg)
CMPE13
Machine Language
• Written in strings of 0 and 1– Displayed as hexadecimal
• Only language the computer understands
• All other programming languages are translated to machine language
• Computer dependent
16
![Page 17: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/17.jpg)
CMPE13
Assembly Language
• Mnemonic codes– Add, sub, tst, jmp…
• Names for memory locations• Computer dependent• “Assembler” translates from
Assembly to machine language
17
![Page 18: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/18.jpg)
CMPE13
3GL: High-Level Languages
• 1960s• Languages designed for specific
types of problems and used syntax familiar to the people in that field– FORTRAN: (FORmula TRANslator)
• Math
– COBOL: (COmmon Business Oriented Language)• Business
• Compile translates from high-level language to machine language
18
![Page 19: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/19.jpg)
CMPE13
4GL: Very High-Level Languages
• Programmer specifies the desired results; the language develops the solution
• Ten times more productive with a 4GL than a procedural language
• Query Languages– Retrieve information from databases– Easy to learn and use
19
![Page 20: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/20.jpg)
CMPE13
5GL: Natural Languages
• Resemble natural or spoken English
• Translates human instructions into code the computer can execute
• Commonly used by non-programmers to access databases
20
![Page 21: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/21.jpg)
CMPE13
Third Generation Languages: Traditional
Programming
• Describe data• Describe procedures or
operations on that data• Data and procedures are separate
21
![Page 22: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/22.jpg)
CMPE13
Third Generation Languages
• FORTRAN– 1954– Represent complex mathematical
formulas– C/C++ has replaced FORTRAN
• COBOL– 1959– Business– Large complex data files– Formatted business reports
22
![Page 23: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/23.jpg)
CMPE13
Average a list of numbers
Accept series of numbers and display the average
23
![Page 24: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/24.jpg)
CMPE13
Third Generation Languages
FORTRAN
24
![Page 25: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/25.jpg)
CMPE13
Third Generation Languages
COBOL
25
![Page 26: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/26.jpg)
CMPE13
Third Generation Languages
• BASIC (Beginners All-purpose Symbolic Instruction Code)– 1965– Popularity grew with PC popularity
(1970s)– Easy to learn– Used little memory– Bill Gates beginnings.. MS Basic
• RPG– 1965– Report generation – quickly creates
complex reports
26
![Page 27: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/27.jpg)
CMPE13
Third Generation Languages
BASIC
27
![Page 28: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/28.jpg)
CMPE13
Third Generation Languages
• MS Visual Basic– 1987– Create complex user interfaces– Uses standard Windows features– Event-driven – user controls the
program
• C– 1972– Efficient code – the language of UNIX– Portability
• C++– Enhancement of C (Object Oriented)
28
![Page 29: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/29.jpg)
CMPE13
Third Generation Languages
C++
29
![Page 30: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/30.jpg)
CMPE13
OOP: Object-Oriented Programming
• Object– Self-contained unit of data and instructions– Includes
• Related facts (data)• Related functions (instructions to act on that data)
• Example– Object: cat– Data: feet, nose, fur, tail– Functions: eat, purr, scratch, walk– Cat: Kitty, Tabby
30
![Page 31: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/31.jpg)
CMPE13
OOP: Object-Oriented Programming
• Encapsulation – describes the objects self- containment
• Attributes – the facts that describe the object
• Methods / operations – the instructions that tell the object what to do
• Instance – one occurrence of an object• Messages – activate methods
– Polymorphism
Example: A ‘walk’ message causes Kitty to move (in a cat-like way)
31
![Page 32: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/32.jpg)
CMPE13
OOP: Object-Oriented Programming
• Class – defines characteristics unique to all objects of that class
• Inheritance – Objects of a class automatically posses all of the characteristics of the class from which it was derived
• Subclass – inherits characteristics from class and defines additional characteristics that are unique
• Instance – actual occurrence of an object
32
![Page 33: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/33.jpg)
CMPE13
ExampleClass: BoatSubclass: CanoeSubclass: PowerboatSubclass: SailboatInstance: Chardonnay II
OOP: Object-Oriented Programming
33
![Page 34: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/34.jpg)
CMPE13
OOP: Object-Oriented Programming
Using Objects in BusinessClass: CustomerSubclass: Retail or WholesaleInstance: John Smith
Retail and Wholesale customers automatically inherit customer address since it is part of the Customer class
34
![Page 35: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/35.jpg)
CMPE13
OOP: Object-Oriented Programming
Languages• C++
Can write both structured and object-oriented code
• Visual BasicRudimentary features of object-oriented language
35
![Page 36: CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do](https://reader030.vdocument.in/reader030/viewer/2022032612/56649eb25503460f94bb885d/html5/thumbnails/36.jpg)
CMPE13
Third Generation Languages
Java• Cross-platform• Java Virtual Machine (JVM)
– Sits on top of computer’s regular platform– Translates compiled Java code into
instructions for the specific platform
• Applets
36