0% found this document useful (0 votes)
91 views

Module 1 - COSC95 - Introduction To Programming Languages - VCB

This document provides an overview of programming languages and their domains. It discusses the definition of a programming language and reasons for studying them. It also describes different programming domains including scientific applications, business applications, artificial intelligence, systems programming, scripting languages, and special purpose languages. For each domain, it outlines characteristics and examples of languages developed for that domain. The document concludes by listing some criteria for programming languages, such as readability, writability, reliability, orthogonality, uniformity, maintainability, and generality.

Uploaded by

April Vasquez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views

Module 1 - COSC95 - Introduction To Programming Languages - VCB

This document provides an overview of programming languages and their domains. It discusses the definition of a programming language and reasons for studying them. It also describes different programming domains including scientific applications, business applications, artificial intelligence, systems programming, scripting languages, and special purpose languages. For each domain, it outlines characteristics and examples of languages developed for that domain. The document concludes by listing some criteria for programming languages, such as readability, writability, reliability, orthogonality, uniformity, maintainability, and generality.

Uploaded by

April Vasquez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Republic of the Philippines

CAVITE STATE UNIVERSITY


Silang Campus
Biga I, Silang, Cavite
 046 513-5706  046 513-3965
[email protected]

DEPARTMENT OF INFORMATION TECHNOLGY

COSC 95 - Programming Languages

Module 1 – Week 2-3


Introduction to Programming Languages

Overview
Are you aiming to become a software engineer one day? Do you also want to develop a mobile
application that people all over the world would love to use? Are you passionate enough to take the
big step to enter the world of programming? Then you are in the right place because through this
article you will get a brief introduction to programming. Now before we understand what
programming is, you must know what is a computer. A computer is a device that can accept human
instruction, processes it, and responds to it or a computer is a computational device that is used to
process the data under the control of a computer program. Program is a sequence of instruction
along with data.

Objectives

After working on this module, you will be able to:


1. Understand the definition and terms needed for programming languages.
2. Determine the broad and specific functions of O.S
3. Know the language categories.

Programming Language
▪ A programming language is a set of rules that provides a way of telling a computer
what operations to perform. It is a notational system for describing computation in a
machine-readable and human-readable form.

A programming language is an artificial language that can be used to control the behavior of a
machine, particularly a computer. Programming languages, like human languages, are defined
through the use of syntactic rules, to determine structure and meaning respectively.

Programming languages are used to facilitate communication about the task of organizing and
manipulating information, and to express algorithms precisely. Its natural language is English. It has
words, symbols and grammatical rules. A programming language has words, symbols and rules of
grammar.

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


The grammatical rules are called syntax. Each programming language has a different set of syntax
rules.

A construct is simply a concept implementation mechanism used by a given programming language


– the language’s syntax.

Reasons for studying the concepts of Programming Languages

1. To improve your ability to develop effective algorithms

Many languages provide features that can be extremely useful when used properly but waste a
large amount of time when used improperly. Algorithms behave similarly, so the habit of making
correct decisions with a programming language can carry over to making correct decisions with an
algorithm.

2. To improve your use of your existing programming language

By understanding exactly how the features in a programming language are implemented, you learn
how to effectively use them. When you know how the language components such as
lists/arrays/strings work, you can use them more efficiently.

3. To increase your vocab of useful programming constructs

When thinking about a set of data/program structures to solve a problem, it’s typical to only think
about the structures that are immediately available within the programming language you’re working
with. By knowing the constructs of other programming languages, you can find one that fits your
scenario better and possibly implement it yourself.

4. To allow a better choice of programming language

Some languages are better suited than others for particular projects. You can reduce effort by
picking the one that works best.

5. To make it easier to learn new language

A thorough knowledge of programming language constructs and implementation techniques allows


programmers to learn new languages more easily.

6. To make it easier to design a new language

Though you may not be making the next C or Java programming language, it’s actually fairly
common to create a form of programming language on a small scale within a project.

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


Programming Domains

Programming domains deals with the areas of computer applications and their associated
languages. It refers to domain-specific programming languages. Some of them are:

1. Scientific applications

The first digital computers, which appeared in the 1940’s, are invented for scientific applications. In
the II world war, the US defense department wanted a computer that could easily calculate the
values in their applications like trajectory of missiles.

Characteristics:

a) Consists of simple data structures


b) Can do large number of floating-point arithmetic

The main languages that were developed were FORTRAN, ALGOL 60.

2. Business applications

The use of computers for business applications began in 1950’s

Characteristics:

The business people wanted a programming language that can:

a) Produce elaborate reports

b) Have precise way of describing and sorting decimal numbers and character data.

c) The ability to specify decimal arithmetic operations.

COBOL (Common Business Oriented Language) was the first high level language for business.
With the advent of minicomputers small business people are used computers and some of its tools
like spreadsheet systems and database system.

3. Artificial intelligence

In the year of1960, artificial intelligence played a very important role.

Characteristics:

AI is abroad area of computer applications characterized by:

a) Use of symbolic rather than numeric computation i.e., it must contain symbols, names etc.

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


b) More flexible language for symbolic computation.

c) The ability to create and execute some code segments during execution.

The main languages that were developed during this time were the LISP and PROLOG. These
were mainly used logic programming like designing moves of chess.

4. Systems Programming

In the 1960’s and 1970’s system software was used. The OS and all of the programming support
tools of a computer system are collectively known as its system software. System software is almost
used continuously.

Characteristics:

The system software must have the following:

a) As it is continuously used it must be efficient.

b) It must have low level features that allow the interface to external devices to be written

c) It must provide security

Developed Languages:

• IBM for mainframes developed PL/s, a dialect of PL/I

• For digital systems BLISS was developed

• For Burroughs extended ALGOL

• Unix OS was written almost in C but it is too dangerous to use C on large important systems.

5. Scripting Languages

These languages have evolved over the 25 years.

Characteristics:

a) A scripting language is used by putting a list of commands, called a SCRIPT in a title to be


executed

b) For simple applications like file management and file filtering

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


Languages Developed:

• SH is the first scripting language with simple commands later control, flow statements, variables,
functions and other capabilities were added resulting in a complete programming language.

• Korn Shell (Ksh), developed by David Korn

• AWK, developed by Alfred Aho, Peter Weinberger, and Brian Kernighan

• TCL, developed by John Ousterhout

6. Special Purpose Languages

They have evolved over the past 40 years and these are designed for a particular specific purpose.

Languages Develop:

• PPG to produce business reports

• API– for instructing programmable machine tools

• GPSS for system stimulation

These are not used that much because of their narrow applicability

Programming Language Criteria

Readability - Understand and comprehend a computation easily and accurately.

Writability - Express a computation clearly, correctly, concisely, and quickly.

Reliability - Assures a program will not behave in unexpected or disastrous ways.

Orthogonality - A relatively small set of primitive constructs can be combined in a relatively small
number of ways. Every possible combination is legal. Lack of orthogonality leads
to exceptions to rules.

Uniformity - Similar features should look similar and behave similar.

Maintainability - Errors can be found and corrected and new features added easily.

Generality - Avoid special cases in the availability or use of constructs and by combining closely
related constructs into a single more general one.

Extensibility - Provide some general mechanism for the user to add new constructs to a language.

Standard ability - Allow programs to be transported from one computer to another without
significant change in language structure.

Implement ability - Ensure a translator or interpreter can be written.

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


Attributes of a good language

There are a lot of reasons why one programming language could be viewed as preferable to
another.

Clarity, simplicity, unity

• The language must provide a framework for thinking about algorithms

• The language must provide a way to express ideas of algorithm implementations

• Its concepts should be simple so they can be used in developing algorithms

• The language should have a minimum number of concepts (conceptual integrity)

• Language syntax determines ease of writing, reading, testing, and modifying code

Cryptic syntax maybe easy to write but is usually hard to read.

Constructs that mean different things should look different.

Orthogonality

The attribute of being able to combine various features with all combinations of features being
meaningful.

Ex: Language can evaluate expression to get Boolean T/F. Language also has conditionals based
on T/F. If any expressions can be used/evaluated within a conditional statement, these features are
orthogonal.

• Orthogonal features make a language easier to learn

• A negative aspect is that it may hide errors

Naturalness for the application

• Language syntax should allow the program structure to reflect the algorithm

• Examples of algorithms differing in structure are:


✓ Sequential
✓ Concurrent
✓ Logic

• The language should provide the following tools for solving a problem:
✓ Appropriate data structures
✓ Appropriate operations
✓ Appropriate control structures
✓ A natural syntax for the problem

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


Support for abstraction

• There is always a gap between abstract data structures and primitive data structures.

• The language should allow data structures, data types, and operations to be defined and
maintained as self-contained abstractions.

• Ada developed for lack of abstraction in Pascal, C++ for lack of abstraction in C.

Ease of program verification

• Reliability of programs is a huge concern

• Methods of testing program correctness:


✓ Formal verification
✓ Desk checking
✓ Testing via input data

• A combination of the above methods is used for large projects

• Hard program verification may outweigh language features

• Simple syntax/semantics makes program verification simpler

Programming environment

• A weak language with a good environment can be easier than a strong language

• Factors that influence the programming environment include:


✓ Reliable, efficient, well-documented implementation
✓ Special editors
✓ Special testing packages
✓ Version control

• ADA, FORTRAN, C have standardized definitions for portable application development

Cost of use

• Cost of program execution


✓ Main focus of earl programming years
✓ Speed not a high concern anymore
✓ 10% or20% execution time tolerated for other benefits

• Cost of program translation


✓ Student programs are compiled frequently but executed few times
✓ A fast compiler is important for programming education

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


• Cost of program creation, testing, use
✓ Smalltalk and Perl can help solve problems with minimum investment in programmer time
and energy.
✓ Programming time minimized, but execution time may be larger in comparison to other
languages.

• Cost of program maintenance


✓ Studies show largest cost is over the life of the program, not initial
✓ Maintenance includes repair of errors and enhancements
✓ A language that makes it easy to adjust programs may be cheaper in the long run

Language Design Trades-Offs

Reliability vs. Cost of execution

Conflicting criteria. Ex. Java demands all references to array elements be checked for proper
indexing but that leads to increased execution cost. C does not require index range checking. C
program executes faster than equivalent Java program, although Java programs are more reliable.
Java designer traded execution efficiency for reliability.

Readability vs. Writability

Another conflicting criterion, ex. APL provides many powerful operators for array operands (and a
large number of new symbols), allowing complex computations to be written in a compact program
but at the cost of poor readability. Many ALP operators can be used in a single long complex
expression. APL is very writable but poor readability.

Writability (flexibility) vs. Reliability

Another conflicting criterion. Ex. C++ pointers are powerful and very flexible but not reliably used,
because of the potential reliability problems with pointers, they are not included in Java.

Implementation Methods
Programming languages can be implemented by any of the three general methods:

Compilation

It is the process the computer takes to convert a high-level programming language into a machine
language that the computer understands. The software which performs this conversion is called a
compiler.

A compiler is a special program that processes statements written in a particular programming


language and turns them into machine language or “code” that computer’s processor uses.

When executing (running), the compiler first parses (or analyzes) all of the language statements
syntactically one after the other and then, in one or more successive stages or “passes”, builds the
output code, making sure that statements that refer to other statements are referred to correctly in
the final code. Traditionally, the output of the compilation has been called object code or sometimes
an object module. The object code is machine code that the processor can execute one instruction
a time.

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


Pure Interpretation

Programs are interpreted by another program known as an interpreter with no translation. An


interpreter is a computer program that directly executes, i.e., performs, instructions written in a
programming or scripting language, without requiring them previously to have been compiled into
a machine language program.

An interpreter generally uses one of the following strategies for program execution:

1. Parse the source code and perform its behavior directly;

2. Translate source code into some efficient intermediate representation and immediately execute
this;

3. Explicitly execute stored precompiled code made by a compiler which is part of the interpreter
system.

Early versions of Lisp programming language and Dartmouth BASIC would be examples of the first
type. Perl, Python, MATLAB, and Ruby are examples of the second, while UCSD Pascal is an
example of the third type.

Hybrid Implementation System

A compromise between compilers and pure interpreters. They translate high-level language
programs to an intermediate language designed to allow easy interpretation. This method is faster
than pure interpretation because the source language statements are decoded only once.

Compilation of a language implemented through a hybrid system is very similar to that of a compiled
language, except that the intermediate code is never translated to machine language
macroinstructions. Instead, a virtual machine is supplied that takes the intermediate language as
its machine language, so it can interpret the intermediate code much faster than it would be able to
interpret ahigh-level language.

Two common hybrid languages are Perl, which uses some early compilation to detect errors before
interpretation, and Java, which produces a machine-independent byte code that is executed on the
Java Virtual Machine.

Other languages provide a kind of hybrid system in which early development is done via
interpretation, and compilation is only done once the code is relatively bug-free.

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


Programming Environments

• Programming environment is where programs are created, tested.

• Usually consists of support tools and command language for invoking them

• Typical tools include:


✓ Editors
✓ Debuggers
✓ Verifiers
✓ Pretty printers
✓ Test data generators

Effects on Language Design


Programming environments have had two large effects on language design:
✓ Features aiding separate compilation/assembly from components
✓ Features aiding program testing and debugging

Separate compilation

• For large programs, different programmers will be working on separate parts

• This requires a language that can compile the parts and merge together later

• Separate compilation can be difficult because subprograms might need each other

• There are ways to provide information to subprograms during separate compilation:

1. Information may need to be redeclared (FORTRAN)

2. An order of compilation maybe required (Ada)

3. A library containing relevant specifications may be required (Java/C++)

Option 1 above uses independent compilation. The subprogram is entirely contained. The
disadvantage is inability to check inconsistency of data between external declaration and internal
redeclaration. You will have assembly errors even though the subprograms may have 0 errors.

Options 2 and 3 require the use of libraries. The body is usually omitted during the compilation of
subprograms.
✓ Separate compilation has the side effect of enabling name collisions issues
✓ Several subprograms or portions of programs may have the same name

This may not be determined until attempting to merge all subprograms

• There are three main ways languages avoid these name collisions
✓ Use of naming conventions (obligation of the programmer)
✓ Use of scoping rules (Used by Pascal, C, Ada)
✓ Add name definitions from external library (inheritance in Object-oriented)

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022


Testing and debugging

A few typical examples of testing and debugging features:

• Execution trace

✓ Prolog, LISP, may others have execution tracing tools.


✓ Allows for statements and variables to be tagged for tracing
✓ When a tagged statement is called, program stops, debug trace is printed.

• Breakpoints

✓ Specified by programmer
✓ When breakpoint is reached, execution is interrupted, control given to user
✓ User can inspect and modify variables and restart the program

• Assertions

✓ A special conditional expression


✓ If assertion fails, program is interrupted
✓ Exception handler may print or take other actions upon failed assertion
✓ After debugging, assertions may be disabled.

Activity 1

Create a written report for the different computer languages. Include at least 10 computer
languages. Please see below the instructions and format for the written report. You should at
least use your own words to write your report (should not be totally copy and paste from search
engine).

Note: If ever you have the exact/almost same output from your classmate, automatically zero
score.

Report structure:

✓ Title page
✓ Contents page
✓ Summary
✓ Introduction
✓ Main body
✓ Conclusion
✓ References

COSC 95 – PROGRAMMING LANGUAGES GIO BAUTISTA- SECOND SEMESTER AY 2021-2022

You might also like