Module 1 - COSC95 - Introduction To Programming Languages - VCB
Module 1 - COSC95 - Introduction To Programming Languages - VCB
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
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.
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.
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.
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.
Some languages are better suited than others for particular projects. You can reduce effort by
picking the one that works best.
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.
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:
The main languages that were developed were FORTRAN, ALGOL 60.
2. Business applications
Characteristics:
b) Have precise way of describing and sorting decimal numbers and character data.
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
Characteristics:
a) Use of symbolic rather than numeric computation i.e., it must contain symbols, names etc.
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:
b) It must have low level features that allow the interface to external devices to be written
Developed Languages:
• Unix OS was written almost in C but it is too dangerous to use C on large important systems.
5. Scripting Languages
Characteristics:
• 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.
They have evolved over the past 40 years and these are designed for a particular specific purpose.
Languages Develop:
These are not used that much because of their narrow applicability
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.
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.
There are a lot of reasons why one programming language could be viewed as preferable to
another.
• Language syntax determines ease of writing, reading, testing, and modifying code
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.
• Language syntax should allow the program structure to reflect the algorithm
• 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
• 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.
Programming environment
• A weak language with a good environment can be easier than a strong language
Cost of use
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.
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.
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.
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.
An interpreter generally uses one of the following strategies for program execution:
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.
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.
• Usually consists of support tools and command language for invoking them
Separate compilation
• This requires a language that can compile the parts and merge together later
• Separate compilation can be difficult because subprograms might need each other
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
• 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)
• Execution trace
• 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
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