Module 2 Objectives:
a. To be able to understand and explain what is computer language and its purpose
b. To be able to understand and explain the generation of programming language
c. To be able to understand and explain the classification and paradigm of programming language
d. To be able to understand and explain the program development life cycle (PDLC)
e. To be able to understand and explain the program development tools
f. To be able to understand and explain the characteristics of a good program and its basic elements
MODULE 2: Introduction to Computer Programming
Concepts of Programming Language
Computer languages provide the means of communication with the computer machine. A computer
programming language is a set of rules, commands, instructions, symbols, and syntax that allows
programmers to write code and create software programs or applications like desktop applications, websites,
computer games, etc.
Purpose of Programming Language (PL)
The purpose or the functions of programming language is to write or create programs that devises specific
algorithms. It manages different input and output devises and manage transformation of data. Programming
language consists of a vocabulary and a set of rules which is called a syntax. Which a programmer must
learn.
Another function of a programming language is to create a bridge of communication between human and
computers. As computers only understands 0’s and 1’s (Binary) where on the other side humans understand
the common languages. which tends to create a huge misinterpretation.
So the main purpose (PL) is to use the programming languages to translate the human imputed requirements
into a computer understandable format.
Generation of Programming Language
• First Generation Language (1GL)
The very first programming languages was the Machine Languages (ML). Its generation spans from
1940 to 1956. These ML were the Low Level Languages. It is a language entirely made up of 0’s
and 1’s. Machine language programs had the advantage of faster execution speed and efficient use
of primary memory. Each type of processor required its own machine language. For this, machine
language is said to be Machine-Dependent which was also known Hardware-Dependent. There was
originally no compiler or assembler that specific time to process the instructions. The very first
computers used vacuum tubes for circuitry and magnetic drums for memory. It also used to respond
to the instruction set that was hardwired into the circuitry of a microprocessor.
• Second Generation Language (2GL)
The second generation programming languages were the Assembly Languages (AL). Its generation
spans from 1956 to 1963. These languages use mnemonic codes that consists of very short words
for commands. It also uses symbolic addresses in place of 1s and 0s to represent the operation
codes. A mnemonic is an alphabetical abbreviation which is used as a memory aid. Although its an
improvement over the 1st generation languages but it also had its complications like, before they can
be used by the general computer, assembly languages had to be translated into machine language
first. A language translator program called an Assembler was used for this conversion. Assembly
languages provide an easier and more efficient way to programming than machine languages, while
maintaining control over the internal functions of a computer at the same time.
• Third Generation Language (3GL)
The third generation programming languages were referred as the High-Level Languages. Its
generation spans from 1964 to 1971. The appearances of these type of languages were like the
everyday use words or mathematical formulas. They were portable or machine independent
programming. The Data Structure and Control Structure were introduced by 3rd generation
languages. Integrated circuits were used in them so that it could be used in different processors
unlike the first two generations. These programs not only helped in solving what to do but also how
to do it. A language translator was required to convert the high-level language programs into machine
language readable. Two types of language translators were used with this 3rd generation, and those
were compilers and interpreters.
• Fourth Generation Language (4GL)
The fourth generation languages are called the Declarative Languages which is also referred as Very
High-Level Languages. Its generation spans from 1971 to present days. These Languages are more
advanced than traditional High-Level programming languages because it uses English-like
Commands that do not require traditional Input-Process-Output. 4th generation languages allow
users or non-computer professionals, to develop software’s and so on. These generation uses
microprocessors where thousands and thousands of integrated circuits were built into a single silicon
chip. The sophistication of 4th generation languages differs hugely. These languages are usually
used in conjunction collaborated with a database and its data dictionary.
And based on these five (5) languages tools for 4th generation programming languages falls into its
category: Query languages, Report generators, Applications generators, Support systems and
financial planning languages, Micro-computer application software
• Fifth Generation Language (5GL)
The fifth generation languages are basically an out-growth of the Artificial Intelligence (AI). Its
generation spans from present days to beyond. It is a Programming language based on solving
problems using restrictions or limitations given to the program, rather than using an algorithm
imputed by a programmer. It also contains programming languages that has visual tools to assist in
developing a program.
First Programmer
Augusta Ada Byron has been called the world’s first computer programmer. In the 1840s, she wrote the
world’s first machine algorithm for an early computing machine that existed only on paper. Lovelace was a
brilliant mathematician, thanks in part to her privileged birth. Babbage was so impressed with Lovelace’s
contributions, he dubbed her "The Enchantress of Numbers."
First Programming Language
Somewhere between 1944-45, Konrad Zuse developed the first ‘real’ programming language called
Plankalkül (Plan Calculus). Zeus’s language (among other things) allowed for the creations of procedures,
which stored chunks of code that could be invoked over and over to perform routine operations.
Classification of Programming Languages
Programming languages are communication systems which allow programmers giving specific instructions
to machines and computers, so that they can perform the actions that are necessary to achieve certain goals.
Through programming languages, programmers can communicate with machines using their language
(programming), through which they can write instructions in the form of algorithms and tell computer systems
what they want them to do.
Since there are so many different programming languages, today we want to explain how to classify them
following different classification criteria: Level, Paradigm, Compilation and by Purpose.
Classification by level
One way to classify languages is considering their level of abstraction, that is, whether they are more or less
similar to the way machines communicate. We can divide them into three groups:
• Machine language: it is the language that machines can understand directly, as it uses only zeros
and ones (binary).
• Low-level languages: they are languages which are very close to the way machines communicate,
but do not reach binary. The disadvantage of these languages is that they are specific to each
machine. Within this group, the most characteristic language is the assembly language.
• High-level languages: they are languages that are closer to the way people communicate. They
are portable and make the process of writing, reading and modifying programs much easier. Python
and C++ are two examples of high-level languages.
Classification by paradigm
Another way to classify them is according to programming paradigms, which determine different ways of
structuring and ordering the actions that a program must perform. In this case, we can divide them into two
types:
• Imperative languages: in this type of language, programmers specify the sequence of operations
that the program must perform to solve the problem. PHP, Java or Python are some examples of
imperative languages.
• Declarative languages: in this case, programmer specify a desired result and the language is
responsible for getting what it takes to achieve it. Prolog, Lisp and Haskell are declarative languages.
Classification by compilation
Third, we can also classify them according to their compilation, which is the process of translating programs
so that machines can understand them. There are two types of languages according to these criteria:
• Interpreted languages: they act a bit like a human interpreter when doing simultaneous translation
of a speaker who is talking in another language. The program is translated at runtime, that is, at the
same time as it is used – the interpreter reads a line, translates it and executes it. JavaScript and
PHP are examples of interpreted languages.
• Compiled languages: they function as a human translator who takes a complete work and
translates it in its entirety. Instead of doing it line by line, the program is completely translated into a
language close to the machine language before running it, thus generating an object file. The object
program is used at run time. Java and C++ are two examples of compiled languages.
Classification by purpose
Finally, there is also a classification according to the purpose of each language. In this case, we divide them
into the following groups:
• General-purpose languages: they are languages that have been designed to solve multiple
problems. Java and Python are general-purpose languages.
• Domain-specific languages: they are languages which have been created for a specific thing and
it doesn’t make sense to use them outside their scope. SQL is a specific language.
Programming Paradigm
Paradigm is a school of thought or model that has distinct features, frameworks, patterns, and style which
help you solve a particular problem. Paradigms are used in all fields such as psychology, sociology,
etymology, computer science and so on. In the field of computer science, new programming languages
emerge from existing languages and add, remove and combine features in a new way. The languages may
follow a particular paradigm or can be a combination of many paradigms. Did you know that there are 256
programming languages? It is evident that each of them has evolved from the other with an amalgamation of
various programming paradigms.
Programming languages are tools and not all tools are good for all jobs. Some tasks are easier to solve
functionally. Some are clearly suited for Objected Oriented programming. Others get simpler when you use
constraint solving or pattern matching.
• Procedural Programming - Procedural programming can also be referred to as imperative
programming. It is a programming paradigm based upon the concept of procedure calls, in which
statements are structured into procedures (also known as subroutines or functions). They are a list
of instructions to tell the computer what to do step by step, Procedural programming languages are
known as top-down languages. Most of the early programming languages are all procedural.
Features of Procedural Code:
- Procedural Programming is excellent for general-purpose programming
- The coded simplicity along with ease of implementation of compilers and interpreters
- A large variety of books and online course material available on tested algorithms, making it
easier to learn.
- The source code is portable
- The code can be reused in different parts of the program, without the need to copy it
- The program flow can be tracked easily as it has a top-down approach.
• Logical Programming - Logical programming is a computer programming paradigm that has its
foundations in mathematical logic in which program statements express facts and rules about
problems within a system. Rules are written as logical clauses with a head and a body. They also
follow a declarative rather than an imperative approach. To understand how a problem can be solved
in logical programming, you need to know about the building blocks − Facts and Rules −
Let us understand the difference between Imperative and declarative programming. Imagine you
walk into your favorite coffee place and you would like to order some coffee.
The imperative approach will be:
- Enter the coffee shop
- Queue in the line and wait for the barista asking you for your order
- Order
- Yes, for takeaway, please
- Pay
- Present your loyalty card to collect points
- Take your order and walk away
The declarative approach:
- A large latte for takeaway, please
So rather than providing a step by step instruction (imperative), you tell the system what you need
and let it try to come up with a solution (declarative).
Features of Logical Programming:
- Logical programming can be used to express knowledge in a way that does not depend on the
implementation, making programs more flexible, compressed and understandable.
- It enables knowledge to be separated from use, i.e. the machine architecture can be changed
without changing programs or their underlying code.
- It can be altered and extended in natural ways to support special forms of knowledge, such as
meta-level of higher-order knowledge.
- It can be used in non-computational disciplines relying on reasoning and precise means of
expression.
• Functional Programming - Functional programming is a programming paradigm where you have a
style of building the structure and elements of computer programs. Here you treat computation as
an evaluation of mathematical functions and you avoid changing-state and mutable data. Functional
programming consists only of PURE functions. Pure functions are those which take an argument list
as an input and whose output is a return value.
• Object-Oriented Programming(OO) - In this paradigm, all real-world entities are represented by
Classes. Objects are instances of classes so each object encapsulates a state and behavior. State
implies the fields, attributes of the object and behavior is what you do with the state of the object and
they are the methods. Objects interact with each other by passing messages.
Features of OO:
- Encapsulation – This is a fundamental feature of Object-Oriented Programming. Here you hide
unnecessary details in classes and deliver a simple and clear interface for working. It describes
the idea of bundling data and methods that work on that data within one unit. This concept is
also often used to hide the internal representation, or state, of an object from the outside
- Inheritance - Inheritance is one of the core concepts of object-oriented programming (OOP)
languages. It is a mechanism where you can derive a class from another class for a hierarchy of
classes that share a set of attributes and methods. It explains how the class hierarchies develop
code readability and support to the reuse of functionality.
- Data Abstraction - to Data abstraction is the reduction of a particular body of data to a simplified
representation of the whole. Data abstraction is usually the first step in database design.
- Polymorphism - Polymorphism is an object-oriented programming concept that refers to the
ability of a variable, function or object to take on multiple forms.
Declarative or Imperative Paradigm
Declarative programming is a paradigm describing WHAT the program does, without explicitly specifying its
control flow.
Imperative programming is a paradigm describing HOW the program should do something by explicitly
specifying each instruction (or statement) step by step, which mutate the program's state.
Structured and Unstructured Program
A programming paradigm can categorize the programming language depending on language features.
Structured programming and Unstructured programming are two common programming paradigms. The key
difference between Structured and Unstructured programming is that Structured programming allows the
programmer to divide the whole program into modules or functions and in Unstructured programming, the
code is written as one block.
In Structured Programming, the code is divided into functions or modules. It is also known as modular
programming. Modules or functions are a set of statements which performs a sub task. As each task is a
separate module, it is easy for the programmer to test and debug. It is also easy to do modifications without
changing the whole program.
3 categories: Procedural, OOP, Model based (Database query),
In Unstructured Programming, the code is written as a single whole block. The whole program is taken as a
single unit. It is harder to do changes in the program. This paradigm was used in earlier versions of BASIC,
COBOL, and FORTRAN. Unstructured programming languages have a limited number of data types like
numbers, arrays, strings. It is particular with the use of unstructured control flow using goto statements or
equivalent. The distinction was particularly stressed by the publication of the influential "Go To Statement
Considered Harmful" open letter in 1968 by Dutch computer scientist Edsger W. Dijkstra, who coined the
term "structured programming".
Program Development Life Cycle (PDLC)
Program Development Life Cycle (PDLC) is a systematic way of developing quality software. The PDLC is
similar to the Software/System Development Life Cycle (SDLC), but is applied at a higher level, to manage
the development of multiple software programs or projects.
The PDLC is typically divided into several phases, including:
Planning: In this phase, the goals and objectives of the program are defined, and a plan is developed to
achieve them. This includes identifying the resources required and determining the budget and schedule for
the program.
Analysis: In this phase, the requirements for the program are defined and analyzed. This includes identifying
the stakeholders, their needs and expectations, and determining the functional and non-functional
requirements for the program.
Design: In this phase, the program’s architecture and design are developed. This includes creating a detailed
design of the program’s components and interfaces, as well as determining how the program will be tested
and deployed.
Implementation: In this phase, the program is developed and coded. This includes writing the program’s
source code and creating any necessary documentation.
Testing: In this phase, the program is tested to ensure that it meets the requirements and is free of defects.
Deployment: In this phase, the program is deployed and made available to users.
Maintenance: After the deployment, the program is maintained by fixing any bugs or errors that are found
and updating the program to meet changing requirements.
The PDLC is an iterative process that allows for feedback and adjustments to be made at each phase, to
ensure that the final product meets the needs of the stakeholders and is of high quality.
Program Development Life Cycle (PDLC) is a systematic way of developing quality software. It provides an
organized plan for breaking down the task of program development into manageable chunks, each of which
must be successfully completed before moving on to the next phase. The program development process is
divided into the steps discussed below:
1. Defining the Problem – The first step is to define the problem. In major software projects, this is a
job for system analyst, who provides the results of their work to programmers in the form of a program
specification. The program specification defines the data used in program, the processing that should
take place while finding a solution, the format of the output and the user interface.
2. Designing the Program – Program design starts by focusing on the main goal that the program is
trying to achieve and then breaking the program into manageable components, each of which
contributes to this goal. This approach of program design is called top-bottom program design or
modular programming. The first step involves identifying main routine, which is the one of program’s
major activity. From that point, programmers try to divide the various components of the main routine
into smaller parts called modules. For each module, programmer draws a conceptual plan using an
appropriate program design tool to visualize how the module will do its assign job. Program Design
Tools: The various program design tools are described below:
• Structure Charts – A structure chart, also called Hierarchy chart, show top-down design of
program. Each box in the structure chart indicates a task that program must accomplish.
The Top module, called the Main module or Control module. For example:
• Algorithms – An algorithm is a step-by-step description of how to arrive at a solution in the
most easiest way. Algorithms are not restricted to computer world only. In fact, we use them
in everyday life.
• Flowcharts – A flowchart is a diagram that shows the logic of the program.
• Decision tables – A Decision table is a special kind of table, which is divided into four parts
by a pair of horizontal and vertical lines.
• Pseudocode – A pseudocode is another tool to describe the way to arrive at a solution. They
are different from algorithm by the fact that they are expressed in program language like
constructs
3. Coding the Program – Coding the program means translating an algorithm into specific
programming language. The technique of programming using only well defined control structures is
known as Structured programming. Programmer must follow the language rules, violation of any rule
causes error known as syntax error. These errors must be eliminated before going to the next step.
4. Testing and Debugging the Program – After removal of syntax errors, the program will execute.
However, the output of the program may not be correct. This is because of logical error in the
program. A logical error is a mistake that the programmer made while designing the solution to a
problem. So the programmer must find and correct logical errors by carefully examining the program
output using Test data. Syntax error and Logical error are collectively known as Bugs. The process
of identifying errors and eliminating them is known as Debugging.
5. Documenting the Program – After testing, the software project is almost complete. The structure
charts, pseudocodes, flowcharts and decision tables developed during the design phase become
documentation for others who are associated with the software project. This phase ends by writing
a manual that provides an overview of the program’s functionality, tutorials for the beginner, in-depth
explanations of major program features, reference documentation of all program commands and a
thorough description of the error messages generated by the program. The document is to put
together all of the materials that have generated throughout the PDLC process. All of the flowcharts,
messages, algorithms, lines of code, and the user manuals are part of this documentation.
• Internal documentation is used by other programmers to help them know why you did
something certain way or tell them how you wrote a program.
• External documentation includes user manuals and anything that is not the actual code or is
part of the listing. This should also include materials that are placed on a website such as
FAQs (Frequently Asked Questions) and help areas.
6. Deploying and Maintaining the Program – In the final phase, the program is deployed (installed)
at the user’s site. Here also, the program is kept under watch till the user gives a green signal to it.
Even after the software is completed, it needs to be maintained and evaluated regularly. In software
maintenance, the programming team fixes program errors and updates the software.
Program Development Tools
A programming tool may be any software program or utility that aids software developers or programmers in
creating, editing, debugging, maintaining and/or performing any programming or development-specific task.
A programming tool is also known as a software development tool.
Commonly used software tools in the area of computer programming:
• Interpreter
• compiler and linker
• debugger
• project builder
• code management tools (GIT, etc.)
• integrated development environment (IDE)
• additional tools (profiler software, network analyzer, load tester, database explorer/analyzer, etc.)
Characteristics of Programs
A program is a set of instructions given to a computer to perform a specific task. A computer program is a list
of instructions that tell a computer what to do. Everything a computer does is done by using a computer
program.
1. Accuracy - a program must do what is supposed to do correctly and must meet the criteria laid down
in its specification.
2. Readability and Simplicity - overall simplicity of a programming language strongly affects the
readability of the programs written in that language and programs which are easier to read and
understand are also easier to maintain.
3. Efficiency - optimal utilization of resources is essential in any computer program. Programs written
in a good programming language are efficiently translated into machine code are efficiently executed
and acquire as little space in the memory as possible. The algorithm should be more effective. Every
program needs certain processing time and memory to process the instructions and data. The
program efficiency is also high if it has a high speed during runtime execution of the program.
4. Compactness - in a good programming language, programmers should be able to express intended
operations concisely. A verbose language is generally not liked by programmers, because they need
to write too much.
5. Structured - means that the language should have necessary features to allow its users to write
their programs based on the concepts of structured programming.
6. Usability - program must be easy enough to use and be well documented, both for end-users, novice
and computer experts.
7. Reliability - program must always do what is supposed to do and never crash at any point either
during usage or whenever.
8. Maintainability - It is the process of fixing program errors and improving the program. If a program
is easy to read and understand, then its maintenance will be easier. It should also prevent unwanted
work so that the maintenance cost in the future will be low. It should also have quality to easily meet
new requirements. A maintainable software allows us to fix bugs quickly and easily, improve usability
and performance, add new features, make changes to support multiple platforms, and so on.
9. Machine Independent - Program should be machine-independent. Program written on one system
should be able to execute on many different types of computers without any changes. It is not system
specific and provides more flexibility. An example of this would be Java.
10. Flexible - The program should be written in such a manner that it allows one to add new features
without changing the existing module. The majority of the projects are developed for a specific period,
and they require modifications from time to time. It should always be ready to meet new
requirements. Highly flexible software is always ready for a new world of possibilities.
11. Naturalness - good language should be natural for the application area for which it has been
designed. It should provide appropriate operators, data structures, control structures and a natural
syntax to facilitate the users to code their problem easily and efficiently.
12. Cost Effectiveness – It is the key to measure the program quality. Cost must be measured over the
life of the program and must include both cost and human cost of producing these programs.
Five Basic Programming Elements
1. Input – getting data and commands into the computer
2. Output – getting your results out of the computer
3. Arithmetic – performing mathematical calculations on your data
4. Conditionals and Looping – testing to see if a condition is true or false and cycling through a set of
instructions until some condition is met
5. Variables and data structures – storing information, which may change over time
- END OF MODULE 2 -
ACTIVITY
A. The TIOBE Programming index is an indicator of the popularity of programming languages. Check
their website on top 5 programming languages and give your thought why it gotten their rank.