cs101 introduction to computing lecture programming languages
TRANSCRIPT
![Page 1: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/1.jpg)
CS101 Introduction to Computing
LectureProgramming Languages
![Page 2: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/2.jpg)
Today’s Lecture
• To understand the role of programming languages in computing
• To understand the differences among low- & high-level, interpreted & compiled, and structured & object-oriented programming languages
![Page 3: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/3.jpg)
Programming?
![Page 4: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/4.jpg)
The process of telling the computer what to do
Also known as coding
![Page 5: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/5.jpg)
Types of Programs?
![Page 6: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/6.jpg)
Batch ProgramsThese are typically started from a shell (or automatically via a scheduler) and tend to follow a pattern of:
– Initialize internal data – Read input data – Process that data – Print or store results
Key feature: No user interaction with the computer while the program is running
Examples?
![Page 7: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/7.jpg)
Event-Driven ProgramsExamples? GUIs, microwave, camera
The system sends events to the program and the program responds to these as they arrive.
Events can include things a user does - like clicking the mouse - or things that the system itself does - like updating the clock.
These programs generally work as follows:
– Initialize the internal data – Wait for events to arrive– Identify an incoming event and react accordingly
![Page 8: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/8.jpg)
ProgrammingLanguage?
![Page 9: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/9.jpg)
A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks
![Page 10: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/10.jpg)
All programs consists of:
1. Sequence of instructions
2. Conditionals
3. Loops
These may contain:– Data– Input/output (print, etc)– Operations (add, divide, etc)
![Page 11: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/11.jpg)
Examples of ProgrammingLanguages?
![Page 12: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/12.jpg)
Machine LanguageAssembly Language (1956-63)LISP (1956)Fortran (1957)COBOL (1959)PL/1(1964)BASIC (1964)Pascal (1970)Smalltalk (1972)C (1972)
Ada(1983) C++ (1983-85) QBasic (1986)Perl (1987)VisualBasic (1991)PowerBuilderJava (1995)JavaScriptC# (2001)
![Page 13: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/13.jpg)
Is HTML a programming
language?
![Page 14: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/14.jpg)
Types ofProgramming Languages?
![Page 15: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/15.jpg)
High level Programming Languages
Low Level Programming Languages
![Page 16: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/16.jpg)
High-level programming languages, while simple compared to human languages, are more complex than the languages the uP actually understands, called machine languages
Each different type of uP has its own unique machine language
![Page 17: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/17.jpg)
Lying betweenmachine languages&high-level languagesare languages calledassembly languages
![Page 18: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/18.jpg)
Assembly languages are similar to machine languages, but are easier to program in as they allow a programmer to substitute names for numbers
Machine languages consist of numbers only
![Page 19: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/19.jpg)
4th-generation languages
High-level languages
Assembly languages
Machine languages
![Page 20: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/20.jpg)
walks!
![Page 21: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/21.jpg)
Regardless of what language you use, you eventually need to convert your program into a language that the computer can understand
Two ways for doing that:compile the program or
interpret the program
![Page 22: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/22.jpg)
Interpreter is a program that executes instructions written in a high-level language
An interpreter translates high-level instructions into an intermediate form, which it then executes
In contrast, a compiler translates high-level instructions directly into machine language
![Page 23: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/23.jpg)
Compiled programs generally run faster than interpreted programs
The advantage of an interpreter, however, is that it does not need to go through the compilation stage during which the whole of the high-level code is translated into machine instructions in one go. This process can be time-consuming if the program is long.
The interpreter can immediately execute high-level programs, without waiting for the completion of the translation process
![Page 24: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/24.jpg)
Interpreters:Immediate response,
butexecute code slowly
Compilers:Takes longer to compile,
butsuper-fast execution
![Page 25: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/25.jpg)
Both interpreters and compilers are available for most high-level languages
However, BASIC and LISP were especially designed to be executed by an interpreter
![Page 26: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/26.jpg)
Why are there so many different programming languages?
![Page 27: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/27.jpg)
What is the difference between
them?
![Page 28: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/28.jpg)
What are the advantages of
particular languages?
![Page 29: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/29.jpg)
The question of which language is best is one that consumes a lot of time and energy among computer professionals
Every language has its strengths and weaknesses
![Page 30: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/30.jpg)
FORTRAN is a particularly good language for processing numerical data, but it does not lend itself very well to large business programs
Pascal is very good for writing well-structured and readable programs, but it is not as flexible as the C programming language
C++ embodies powerful object-oriented features, but it is more complex and difficult to learn as compared with Java
![Page 31: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/31.jpg)
The choice of which language to use can also depend on the:
type of computer the program is to run on,
and the
expertise of the programmer
![Page 32: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/32.jpg)
Can a single language have all the good bits of
other languages?
![Page 33: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/33.jpg)
Do some good features force a language to also
have bad features?
![Page 34: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/34.jpg)
What makes a feature good
or bad?
![Page 35: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/35.jpg)
Is there a perfect
language?
![Page 36: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/36.jpg)
Is there a perfect
language for a particular task?
![Page 37: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/37.jpg)
What changes in the field of computer languages can we expect in the near
future?
![Page 38: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/38.jpg)
Which programming language should you
learn?
Should you learn more than one?
![Page 39: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/39.jpg)
?Programming
SWDevelopment
![Page 40: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/40.jpg)
SWDesignDesignMethodology?
![Page 41: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/41.jpg)
The set of (often flexible) rules and guidelines a team of developers follow to construct reasonably complex SW systems
![Page 42: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/42.jpg)
Object Oriented Design (1)
• OO SW is all about objects: a black box which receives messages & responds with those of its own
• An object has 2 aspects:– Properties, also termed as state, data
• Example: For the bicycle: color, speed, pressure
– Methods, also termed as behaviors, instructions• Example: For the same object: accelerate(), inflate()
• In traditional design, these 2 aspects have been kept apart
![Page 43: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/43.jpg)
Object Oriented Design (2)
• The designer starts with any component (object) of the system; designs it as an independent, self-contained system, and then moves to the design of some other component
• The over-all system is put together by fitting together a collection of these components
• Key feature: Details of the design of the component are kept independent of the over-all system– Benefit: It can be easily re-used in other systems:
design once; use multiple times
![Page 44: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/44.jpg)
Structured Design (1)
• Also called top-down design
• The designer starts by first conceiving a skeleton high-level design of the system, and then starts defining features of that over-all design in an ever-increasing detail
• Making small changes in the functionality of the systems sometimes leads to a major re-design exercise
![Page 45: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/45.jpg)
Structured Design (2)
• Structured design emphasizes separating a program's data from its functionality
• Separating data from functionality typically leads to SW that is difficult to maintain & understand - especially for large SW systems
![Page 46: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/46.jpg)
Object-Oriented Languages
• Programming languages specifically designed to make it easy to implement object-oriented designs
• Examples: Smalltalk, C++, Java
![Page 47: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/47.jpg)
Reading Material
Programming Languages
http://www.wikipedia.com/wiki/Programming_language
![Page 48: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/48.jpg)
Goals of Today’s Lecture were …
• To understand the role of programming languages in computing
• To understand the differences among low- & high-level, interpreted & compiled, and structured & object-oriented programming languages
![Page 49: CS101 Introduction to Computing Lecture Programming Languages](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649e995503460f94b9c6a8/html5/thumbnails/49.jpg)
Focus of the Next Lecture:The SW Development Process
• Development process of reasonably complex SW systems does not consist of “coding” only
• We will become familiar with the various phases of the process that developers follow to develop SW systems of reasonable complexity