Top Banner
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights
25
Welcome message from author
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
Page 1: 13 A Programing Languages (IT) Lecture Slide

Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved.

McGraw-Hill Technology EducationMcGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies, Inc. All

rights reserved.

Page 2: 13 A Programing Languages (IT) Lecture Slide

Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved.

McGraw-Hill Technology Education

Chapter 13A

Creating Computer Programs

Creating Computer Programs

Page 3: 13 A Programing Languages (IT) Lecture Slide

13A-3

What Is a Computer Program?

• Computer programs– Also called software– Computer programs are the list of

instructions. Instructions are called code– CPU execute the instructions – Three types of computer programs

• Operating system• Utility• Application

Page 4: 13 A Programing Languages (IT) Lecture Slide

13A-4

Software Is Stored In Many Files

• Executable files– Contain the instructions for the CPU– Have extensions of .exe

• Many other extensions are commonly found

.dll extension

.ini extension

.hlp extension

Page 5: 13 A Programing Languages (IT) Lecture Slide

13A-5

Hardware/Software Interaction

• Program execution– Software executes at the CPU level– Code to play a sound

• Code generates an interrupt• CPU tells the sound card to play• Sound card plays the file

– Programmer creates the code

Page 6: 13 A Programing Languages (IT) Lecture Slide

13A-6

Hardware/Software Interaction

• Code– Statements written in a programming

language– Writing code can be tedious

• Code must be perfect• Order of steps must be exact

– Writing code is quite exciting• Problems are solved• New ideas are formed

Page 7: 13 A Programing Languages (IT) Lecture Slide

13A-7

Writing Code

Page 8: 13 A Programing Languages (IT) Lecture Slide

13A-8

Hardware/Software Interaction

• Machine code– Recall that computers think in binary– Code is translated into machine code

• CPU executes the machine code

– CPUs have a unique machine code

Page 9: 13 A Programing Languages (IT) Lecture Slide

13A-9

Hardware/Software Interaction

• Compilers and interpreters– Converts source code into binary

• Allows code to execute

– Checks source code for correctness

Page 10: 13 A Programing Languages (IT) Lecture Slide

13A-10

Hardware/Software Interaction

• Compiler– Creates an executable file

• Contents are called object code

– Executable can run on its own– Each language has its own compiler– C++ and Java are compiled languages

Page 11: 13 A Programing Languages (IT) Lecture Slide

13A-11

Hardware/Software Interaction

• Interpreter– Runs program one line at a time– More flexible than compilers– Slower than compilers– Always needed to execute program– Visual Basic and Perl are interpreted

Page 12: 13 A Programing Languages (IT) Lecture Slide

13A-12

Planning a Computer Program

• Plans– The steps to solve a problem– Describe the expected results– Programming without a plan is difficult

Page 13: 13 A Programing Languages (IT) Lecture Slide

13A-13

Planning Tools

• Pseudo code– Natural language statements that

resemble code– Describes what must be done– Can be written by non programmers– Programmers develop unique versions

Page 14: 13 A Programing Languages (IT) Lecture Slide

13A-14

How Programs Solve Problems

• Program control flow– Order program statements are executed– Typically executed in order– Constructs can change the flow

• Decision statements• Loops

Page 15: 13 A Programing Languages (IT) Lecture Slide

13A-15

How Programs Solve Problems

• Algorithm– Set of steps– Always leads to a solution– Steps are always the same– Flowcharts can describe algorithms

• Structured tool for drawing algorithms

– Algorithms appear in all programs

Page 16: 13 A Programing Languages (IT) Lecture Slide

13A-16

Hardware/Software Interaction

• Programming languages– Simplifies the writing of code

• English is used to describe the binary

– Original code is called source code– Several hundred languages exist

Page 17: 13 A Programing Languages (IT) Lecture Slide

PROGRAMING LANGUAGES

13A-17

Page 18: 13 A Programing Languages (IT) Lecture Slide

13A-18

Page 19: 13 A Programing Languages (IT) Lecture Slide

Low Level Language

• A low-level language is a programming language is very close to writing actual machine instructions.

• Low-level languages are considered more difficult to use, however, because they require a deeper knowledge of the computer's inner workings.

• Two good examples of low-level languages are assembly and machine code.

13A-19

Page 20: 13 A Programing Languages (IT) Lecture Slide

1. Machine language

• Programming language that can be directly understood and obeyed by a machine (computer) without conversion.

• It is different for each type of CPU• it is the native binary language (comprised

of only characters: 0 and 1) of the computer and is difficult to be read and understood by humans

• Hardware dependent: Could be performed by only one type of computer with a particular CPU.

13A-20

Page 21: 13 A Programing Languages (IT) Lecture Slide

2. Assembly Language

• An assembly language is a low-level programming language for microprocessors and other programmable devices.

• Assembly language implements a symbolic representation of the machine code needed to program a given CPU architecture.

• It is not just a single language, but rather a group of languages.

• Examples: x86

13A-21

Page 22: 13 A Programing Languages (IT) Lecture Slide

Higher level Language• High-level language is any programming language

that enables development of a program in much simpler programming context and is generally independent of the computer's hardware architecture.

• High-level language has a higher level of abstraction from the computer, and focuses more on the programming logic rather than the underlying hardware components such as memory addressing and register utilization.

• C/C++ and Java are popular examples of high-level languages.

13A-22

Page 23: 13 A Programing Languages (IT) Lecture Slide

Procedural Languages

• Procedural programming language is a list or set of instructions telling a computer what to do step by step and how to perform from the first code to the second code.

• Procedural programming languages include C, Go, Fortran, Pascal, and BASIC.

13A-23

Page 24: 13 A Programing Languages (IT) Lecture Slide

Non-Procedural Languages

– A computer language that does not require writing traditional programming logic.

– Also known as a "declarative language," users concentrate on defining the input and output rather than the program steps required in a procedural programming language

– Many are associated with specific application packages.

• Query Languages: • Report Writers: • Application Generators: 13A-24

Page 25: 13 A Programing Languages (IT) Lecture Slide

Object-oriented programming (OOP)

• It is a programming language model organized around objects rather than "actions" and data.

• Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.

• Examples: C++/JAVA, Smalltalk

13A-25