Download presentation
Presentation is loading. Please wait.
Published byMelissa Williams Modified over 9 years ago
1
Programming Language Prelim Period
2
Programming Language A programming language is a standardized communication technique for describing instructions for a computer. A programming language is a standardized communication technique for describing instructions for a computer.communicationcomputercommunicationcomputer Each programming language has a set of syntactic and semantic rules used to define computer programs. Each programming language has a set of syntactic and semantic rules used to define computer programs.syntacticsemanticcomputer programssyntacticsemanticcomputer programs
3
A language enables a programmer to precisely specify (but see Genetic Programming) what data a computer is to act upon, how these data are to be stored/transmitted, and what actions are to be taken under various circumstances. A language enables a programmer to precisely specify (but see Genetic Programming) what data a computer is to act upon, how these data are to be stored/transmitted, and what actions are to be taken under various circumstances.Genetic Programming actionsGenetic Programming actions Programming languages are a type of computer languages, excluding pseudocode which is exclusively for human communication. Programming languages are a type of computer languages, excluding pseudocode which is exclusively for human communication. computer languages pseudocode computer languages pseudocode
4
Reasons Why Study Programming Languages 1. Increased capacity to express programming concepts 2. Improved background for choosing appropriate languages 3. Increased ability to learn new languages
5
4. Understanding the significance of implementation 5. Increased ability to design new languages 6. Overall advancement of computing
6
Language of a Computer 1.) Machine language: the most basic language of a computer A sequence of 0s and 1s A sequence of 0s and 1s Every computer directly understands its own machine language Every computer directly understands its own machine language A bit is a binary digit, 0 or 1 A bit is a binary digit, 0 or 1 A byte is a sequence of eight bits A byte is a sequence of eight bits Early computers programmed in machine language Early computers programmed in machine language
7
2.) Low level Language - a programming language that is close to a machine language Example: Assembly languages Assembly languages In assembly language, an instruction is an easy-to-remember form called a mnemonic, where syntax and semantics is closer to the hardware In assembly language, an instruction is an easy-to-remember form called a mnemonic, where syntax and semantics is closer to the hardware
8
Assembler: translates assembly language instructions into machine language
9
3.) High-level languages make programming easier Closer to spoken languages Closer to spoken languages Examples: Examples: – Basic – FORTRAN – COBOL – C/C++ – Java
10
Programming Domains 1. Scientific applications performs arithmetic computation with large numbers of floating points. performs arithmetic computation with large numbers of floating points. efficiency is the primary concern efficiency is the primary concern first language for scientific applications are FORTRAN ( Formula Translator/Translation ) and ALGOL (ALGOrithmic Language) first language for scientific applications are FORTRAN ( Formula Translator/Translation ) and ALGOL (ALGOrithmic Language)
11
2. Business applications characterized according to the needs of the application, by elaborate input and output facilities and decimal data types. characterized according to the needs of the application, by elaborate input and output facilities and decimal data types. The first successful high level language for business was COBOL The first successful high level language for business was COBOL ( Common Business Oriented Language)
12
3. Artificial intelligence characterized by the absence of exact algorithm and the use of symbolic computation rather than numeric computation characterized by the absence of exact algorithm and the use of symbolic computation rather than numeric computation
13
requires more flexibility rather than more algorithmic programming. requires more flexibility rather than more algorithmic programming. The first functional Language for AI is LISP The first functional Language for AI is LISP ( LISt Processing)
14
4. Systems programming these are the operating systems and all of the programming support tools of a computer system these are the operating systems and all of the programming support tools of a computer system used almost continuously and therefore must have execution efficiency used almost continuously and therefore must have execution efficiency must have low-level features that allows software interface to external must have low-level features that allows software interface to external
15
5. Scripting languages/ Very High Level Languages (VHLLs) A scripting language is one that is used by putting a list of commands, called script, in a file to be executed. A scripting language is one that is used by putting a list of commands, called script, in a file to be executed. Fourth Generation languages that were developed in 1970’s are sometimes considered to be VHLLs Fourth Generation languages that were developed in 1970’s are sometimes considered to be VHLLs
16
6. Special purpose languages Used to produce business reports, for instructing programmable machine tools and simulations. Used to produce business reports, for instructing programmable machine tools and simulations.
17
Language Evaluation Criteria Readability Readability Writability Writability Reliability Reliability Cost Cost
18
Readability The most important criterium The most important criterium 1.1 Overall Simplicity A language with a large number of components is more difficult to learn than one with fewer components A language with a large number of components is more difficult to learn than one with fewer components Feature multiplicity Feature multiplicity
19
Incrementation in C: x++; ++x; x=x+1; x+=1; Incrementation in C: x++; ++x; x=x+1; x+=1; Operator overloading can reduce readability if users don’t do it sensibly Operator overloading can reduce readability if users don’t do it sensibly Simplicity can be carried too far, as is the case with assembly language Simplicity can be carried too far, as is the case with assembly language
20
1.2 Orthogonality A relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language A relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language Every possible combination of primitives is legal and meaningful Every possible combination of primitives is legal and meaningful
21
Example: Suppose a language has 4 data types: int, float, double, char 4 data types: int, float, double, char 2 type operators: array and pointer 2 type operators: array and pointer If the 2 type operators can be applied to themselves and the 4 data types, a large number of data structures is possible If the 2 type operators can be applied to themselves and the 4 data types, a large number of data structures is possible
22
The more orthogonal the design, the fewer exceptions the language rules require The more orthogonal the design, the fewer exceptions the language rules require Example of lack of orthogonality in C Example of lack of orthogonality in C There are 2 kinds of structured data types, arrays and structs;structs can be returned from functions, but arrays cannot There are 2 kinds of structured data types, arrays and structs;structs can be returned from functions, but arrays cannot
23
Parameters are passed by value, except for arrays, which are passed by reference Parameters are passed by value, except for arrays, which are passed by reference An array element can be any data type except void or a function An array element can be any data type except void or a function
24
1.3 Control Statement The relatively recent introduction of control constructs was a reaction to the indiscriminate use of the goto statement The relatively recent introduction of control constructs was a reaction to the indiscriminate use of the goto statement FORTRAN 77 had no while loop FORTRAN 77 had no while loop To implement a while construct, an IF statement and a restricted GOTO were used: To implement a while construct, an IF statement and a restricted GOTO were used:
25
20 IF (X.LT. 10) GOTO 30 --statements inside “loop” GOTO 20 GOTO 20 30 --first statement after loop
26
1.4 Data Types and Structures 1.4 Data Types and Structures Features for user-defined data types enhance readability Features for user-defined data types enhance readability Record types for storing employee info vs. a collection of related arrays (a la FORTRAN 77) Record types for storing employee info vs. a collection of related arrays (a la FORTRAN 77) CHARACTER (LEN=30) NAME(100) CHARACTER (LEN=30) NAME(100) INTEGER AGE(100) INTEGER AGE(100) INTEGER EMPLOYEE_NUMBER(100) INTEGER EMPLOYEE_NUMBER(100) REAL SALARY(100) REAL SALARY(100)
27
1.5 Syntax considerations Identifier forms Identifier forms FORTRAN 77 (at most 6 chars, blanks ignored) FORTRAN 77 (at most 6 chars, blanks ignored) Original ANSI Basic (a single letter possibly followed by a single digit) Original ANSI Basic (a single letter possibly followed by a single digit) Special words Special words Method for forming compound statements Method for forming compound statements Pascal:begin..end Pascal:begin..end
28
C:{.. } C:{.. } Ada:if.. end ifloop.. end loop Ada:if.. end ifloop.. end loop Form and meaning Form and meaning –Semantics should follow from syntax
29
Writability Simplicity and orthogonality Simplicity and orthogonality Support for abstraction Support for abstraction Process abstraction Process abstraction Data abstraction Data abstraction
30
Expressivity Expressivity APL has powerful operators which make it easy to accomplish a lot of computation in a small program APL has powerful operators which make it easy to accomplish a lot of computation in a small program forstatements for counting loops (instead of while) and then Boolean operator in Ada forstatements for counting loops (instead of while) and then Boolean operator in Ada
31
Reliability Type Checking Type Checking Subscript ranges in Adavs. C Subscript ranges in Adavs. C Static vs. dynamic type checking Static vs. dynamic type checking
32
Reliability Exception Handling Exception Handling intercept run-time errors, take corrective measures, and continue processing PL/I, C++, Ada, Java
33
Alisiang Alisiang 2 or more ways to reference the same memory cell 2 or more ways to reference the same memory cell Examples: pointers and unions Examples: pointers and unions Readability and writability Readability and writability
34
Cost Cost of training programmers Cost of training programmers Cost of writing programs Cost of writing programs Cost of compiling programs Cost of compiling programs Cost of execution programs Cost of execution programs Cost of the language implementation system Cost of the language implementation system Cost of poor reliability Cost of poor reliability Cost of maintaining programs Cost of maintaining programs
35
Influences on Language Design Computer architecture Computer architecture Imperative languages model the von Neumann architecture Imperative languages model the von Neumann architecture Functional programming languages (FPLs) will unlikely displace imperative languages until a non-von Neumann architecture is developed which implements them efficiently Functional programming languages (FPLs) will unlikely displace imperative languages until a non-von Neumann architecture is developed which implements them efficiently
36
Programming methodologies Programming methodologies Top-down design and stepwise refinement Top-down design and stepwise refinement Data-oriented design vs. process- oriented design Data-oriented design vs. process- oriented design Object-oriented design Object-oriented design Concurrency (process-oriented) Concurrency (process-oriented)
37
Language Categories Imperative Imperative Functional Functional Logic Logic Object-oriented Object-oriented
42
Logic Language logic programming contributes non-determinism, inversion and partial data structures logic programming contributes non-determinism, inversion and partial data structures
43
OBJECT ORIENTED PROG’G Object-Oriented Programming (OOP) is an approach to program organization and development that attempts to eliminate some of the pitfalls of the conventional programming methods by incorporation the best of structured programming features with several powerful new concepts. It is a new way of organizing and developing programs and has nothing to do with any particular language. However, not all languages are suitable to implement the OOP concepts easily. Object-Oriented Programming (OOP) is an approach to program organization and development that attempts to eliminate some of the pitfalls of the conventional programming methods by incorporation the best of structured programming features with several powerful new concepts. It is a new way of organizing and developing programs and has nothing to do with any particular language. However, not all languages are suitable to implement the OOP concepts easily.
44
Language Design Trade Offs Reliability vs. cost of execution Reliability vs. cost of execution Ada’s runtime type checking contributes to the cost of execution Ada’s runtime type checking contributes to the cost of execution Readability vs. writability Readability vs. writability C APL APL
45
Flexibility vs. safety Flexibility vs. safety Pascal variant record is a flexible way to view a data object in different ways, but no type checking is done Pascal variant record is a flexible way to view a data object in different ways, but no type checking is done
46
Implementation Methods Compilation – programs are translated to machine language
47
The Compilation Process: Source Program optimization Lexical units Input Data Lexical Analyzer Syntax Analyzer Intermediate Code generator Symbol Table Code Generator Computer Parse Trees Intermediate Code Machine Language Results
48
Pure Interpretation- programs are interpreted by another program called an interpreter with no translation. Pure Interpretation- programs are interpreted by another program called an interpreter with no translation. Source Program Source Program interpreter Results Input data
49
Hybrid implementation systems – source language are decoded once Hybrid implementation systems – source language are decoded once Example: Java applets Example: Java applets Intermediate form is called byte code Intermediate form is called byte code Applets are downloaded in byte code form, then interpreted by byte code interpreter Applets are downloaded in byte code form, then interpreted by byte code interpreter
50
Source Program Lexical Analyzer Syntax Analyzer Intermediate Code generator interpreter Results Intermediate Code Lexical units Parse tree
51
Programming Environments collection of tools used in software development collection of tools used in software development UNIX UNIX Borland C++ Borland C++ Smalltalk Smalltalk Microsoft Visual C++ and Visual Basic Microsoft Visual C++ and Visual Basic
52
Evolution of Major Programming Language Zuse’s Plankalkul - 1945 Zuse’s Plankalkul - 1945 By Konrad Zuse By Konrad Zuse Means Program Calculus Means Program Calculus It has integer, floating points, arrays It has integer, floating points, arrays Allows selection but no else Allows selection but no else Includes mathematical expressions showing relationships between program variables Includes mathematical expressions showing relationships between program variables Example Assignment Statement : Statement : A(5) = A(4) + 1 | A+ 1 => 1 V | 4 5 V | 4 5 S| 1.n 1.n S| 1.n 1.n The row labeled V is for subscript and the row labeled S is for data type, 1.n means an integer of n bits. The row labeled V is for subscript and the row labeled S is for data type, 1.n means an integer of n bits.
53
FORTRAN is a statically typed, compiled imperative computer programming language originally developed in the 1950s and still heavily used for scientific computing and numerical computation half a century later. is a statically typed, compiled imperative computer programming language originally developed in the 1950s and still heavily used for scientific computing and numerical computation half a century later. stands for Formula Translator/Translation. stands for Formula Translator/Translation. Although originally a procedural language, recent versions of Fortran have included some features to support object-oriented programming Although originally a procedural language, recent versions of Fortran have included some features to support object-oriented programming
54
Sample programs Sample programs A simple Hello World program to be compiled and run with any Fortran 90 or 95 compiler. A simple Hello World program to be compiled and run with any Fortran 90 or 95 compiler. program hello print*,"Hello World!" end program hello
55
LISP Lisp is a reflective, functional programming language Lisp is a reflective, functional programming language Originally developed as a practical computation model (in comparison to Alan Turing's), it later became the favored artificial intelligence. Originally developed as a practical computation model (in comparison to Alan Turing's), it later became the favored artificial intelligence. The language pioneered the use of tree structures (S-expressions), automatic storage management, interpreters, and functional programming. The language pioneered the use of tree structures (S-expressions), automatic storage management, interpreters, and functional programming. Today, Lisp languages are used in many fields, from web development to finance [1], and are also common in computer science education. Today, Lisp languages are used in many fields, from web development to finance [1], and are also common in computer science education.
56
Lisp derives from "List Processing". Lisp derives from "List Processing". Linked lists are one of Lisp languages' major data structures, and identical basic list operations work in all Lisp dialects. Linked lists are one of Lisp languages' major data structures, and identical basic list operations work in all Lisp dialects. Other common features in Lisp dialects include dynamic typing, functional programming support, and the ability to manipulate source code as data. Other common features in Lisp dialects include dynamic typing, functional programming support, and the ability to manipulate source code as data. ALLOWS metaprogramming – creating programs which write other programs. ALLOWS metaprogramming – creating programs which write other programs. Today, the most widely-known general- purpose Lisp dialects for programming are Common Lisp and Scheme. Today, the most widely-known general- purpose Lisp dialects for programming are Common Lisp and Scheme.
57
Sample PROGRAM: Sample PROGRAM: Evaluate a number's factorial: Evaluate a number's factorial: (defun factorial (n) (if (<= n 1) (if (<= n 1) 1 (* n (factorial (- n 1))))) (* n (factorial (- n 1)))))
58
ALGOL short for ALGOrithmic Language short for ALGOrithmic Language is a family of imperative computer programming languages originally developed in the mid 1950s is a family of imperative computer programming languages originally developed in the mid 1950s It was designed to avoid some of the perceived problems with FORTRAN and eventually gave rise to many other programming languages (including Pascal). It was designed to avoid some of the perceived problems with FORTRAN and eventually gave rise to many other programming languages (including Pascal). ALGOL uses bracketed statement blocks and was the first language to use begin end pairs for delimiting them. Fragments of ALGOL-like syntax are sometimes still used as a notation for algorithms, so-called Pidgin Algol. ALGOL uses bracketed statement blocks and was the first language to use begin end pairs for delimiting them. Fragments of ALGOL-like syntax are sometimes still used as a notation for algorithms, so-called Pidgin Algol.
59
Sample Program from ElliottAlgol Sample Program from ElliottAlgol program HiFolks; begin begin print "Hello world"; print "Hello world"; end; end;
60
COBOL is a third-generation programming language. Its name is an acronym, for COmmon Business Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments. is a third-generation programming language. Its name is an acronym, for COmmon Business Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments. The COBOL 2002 standard includes support for object-oriented programming and other modern language features. However, most of this article is based on COBOL 85. The COBOL 2002 standard includes support for object-oriented programming and other modern language features. However, most of this article is based on COBOL 85.
61
Hello world Hello world * IDENTIFICATION DIVISION. Program-Id. Hello-World. * ENVIRONMENT DIVISION. * DATA DIVISION. * PROCEDURE DIVISION. Para1. DISPLAY "Hello, world.". Para1. DISPLAY "Hello, world.". * Stop Run.
62
BASIC is a family of high-level programming languages. Originally devised as an easy- to-use programming language, i is a family of high-level programming languages. Originally devised as an easy- to-use programming language, i BASIC's name, coined in classic, computer science tradition to produce a nice acronym, stands for Beginner's All-purpose Symbolic Instruction Code, tied to the name of an unpublished paper by the language's co-inventor, Thomas Kurtz (the name thus having no relation to C.K. Ogden's series "Basic English"). BASIC's name, coined in classic, computer science tradition to produce a nice acronym, stands for Beginner's All-purpose Symbolic Instruction Code, tied to the name of an unpublished paper by the language's co-inventor, Thomas Kurtz (the name thus having no relation to C.K. Ogden's series "Basic English").
63
The eight design principles of BASIC were: The eight design principles of BASIC were: Be easy for beginners to use Be easy for beginners to use Be a general-purpose programming language Be a general-purpose programming languagegeneral-purpose programming languagegeneral-purpose programming language Allow advanced features to be added for experts (while keeping the language simple for beginners) Allow advanced features to be added for experts (while keeping the language simple for beginners) Be interactive Be interactive Provide clear and friendly error messages Provide clear and friendly error messages Respond fast for small programs Respond fast for small programs Not require an understanding of computer hardware Not require an understanding of computer hardware Shield the user from the operating system Shield the user from the operating system
64
The Basic Family: The Basic Family: MS-DOS/PC-DOS : BASICA, GW-BASIC Quick BASIC. Turbo BASIC MS-DOS/PC-DOS : BASICA, GW-BASIC Quick BASIC. Turbo BASICMS-DOSBASICAGW-BASICQuick BASICTurbo BASICMS-DOSBASICAGW-BASICQuick BASICTurbo BASIC Window Based: Visual Basic, Visual Basic for Applications (VBA), VBScript VB.NET. Window Based: Visual Basic, Visual Basic for Applications (VBA), VBScript VB.NET.Visual BasicVisual Basic for Applications (VBA)VBScriptVB.NETVisual BasicVisual Basic for Applications (VBA)VBScriptVB.NET Sample Program: Sample Program: 10 PRINT "Hello, world!“ 20 END 10 INPUT "What is your name: "; U$ 20 PRINT "Hello "; U$ 25 REM 30 INPUT "How many stars do you want: "; N 35 S$ = "" 40 FOR I = 1 TO N 50 S$ = S$ + "*" 55 NEXT I 60 PRINT S$ 65 REM 70 INPUT "Do you want more stars? "; A$ 80 IF LEN(A$) = 0 THEN GOTO 70 90 A$ = LEFT$(A$, 1) 100 IF (A$ = "Y") OR (A$ = "y") THEN GOTO 30 110 PRINT "Goodbye "; 120 FOR I = 1 TO 200 130 PRINT U$; " "; 140 NEXT I 150 PRINT
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.