Вы находитесь на странице: 1из 16

Introduction to Programming

Language
Lecture 1
CSC 425

Introduction
Programming is a core activity in the process of
performing tasks or solving problems with the aid of a
computer.
(http://www.doc.ic.ac.uk/~wjk/c++intro/#S1)
As the machine signals (language) is too large for
human to comprehend, a simplified version is needed.

Introduction
Problem Specification
We need to properly define what we need.
Various formal methods can be used. Specification can be in form of
text-based documentation or usage of diagrams such as UML.

Algorithm / Pseudocode
The specific steps to achieve the goal need to be written.
Can use ordinary language

Writing The Code


Translate the Algorithm / Pseudocode into programming language

Compilation/Interpretation Process
Process done by the computer

Output
Process done by the computer

Introduction
There are many different programming languages.
"high-level" programming : syntax close to natural language,
"low-level" languages includes many technical references to 0's and
1's, etc.

Programming language also have different paradigm (way of using


in)
Among the paradigm
Procedural : Programming language in form of functions/module
Object-Oriented: programming language that handle things as object

Some programming languages such as C++ can support more than one
Paradigm.

There are at least two ways of processing computer language:


Compiled
Interpreted

Compiled vs. Interpreted Language


Compiled Language
A compiled language is a programming
language whose implementations are
typically compilers (translators that generate machine
code from source code)
E.g. C++, Java

Interpreted Language
An interpreted language is a programming language for which
most of its implementations execute instructions directly,
without previously compiling a program into machinelanguage instructions. The interpreter executes the program
directly, translating each statement into a sequence of one or
more subroutines already compiled into machine code.
E.g. Php, JavaScript

Compiled Approach
Step 1 : Write Source Code
This can be done using an Integrated Development Environment (IDE)

Step 2 : Pre-processing
Pre-processing will handle '#' directives

Step 3 : Compilation
Compiler converts a high-level language into the specific instruction
set of the target CPU
Parse and translate to Assembly Language

Step 4 : Assembler
Assembler translates assembly to binary

Step 5 : Linker
puts binary together with startup
code and required libraries

Some of the Steps in


Compilation Process
Source Code (.cpp) to Assembly Language

Assembly to Binary

Interpreted Approach
Step 1 : Write Source Code
This can be done using an Integrated
Development Environment (IDE)

Step 2: Source Code Retrieval


Retrieve the prepared source code.

Step 3: Interpreter Program


convert the code to executions

Step 4: Code Execution


Computer will execute the code accordingly

Integrated Development Environment


(IDE)
An integrated development
environment (IDE)
or interactive development
environment is a software
application that provides
comprehensive facilities to
computer
programmers for software
development.
An IDE normally consists of
a source code editor, build
automation tools and a debugger.
Most modern IDEs offer Intelligent
code completion features.
Examples of IDE: Visual Studio,
Eclipse, Netbean, Dev C++,
CodeBlock etc.

Brief History of C++


A C++ program is a collection of commands,
which tell the computer to do "something".
This collection of commands is usually
called C++ source code, source code or
just code. C++ is a compiled programming
language
Code would undergo the compilation process to
produce machine (binary) code.

Brief History of C++


C++ was developed by Bjarne Stroustrup of
AT&T Bell Laboratories in the early 1980's, and
is based on the C language. The name is
intended as an incremental improvement of C.
C++ is somewhat of a high level language but
it nevertheless includes many low-level
facilities to directly manipulate the computer's
memory.

ANSI/ISO C++
The American National Standards Institution (ANSI) and
the International Standards Organisation (ISO) provide
"official" and generally accepted standard definitions
of many programming languages, including C and C++.
The standard guarantees that standard-compliant C++
programs are portable.
In practice most versions of C++ include ANSI/ISO C++
as a core language, but also include extra machinedependent features to allow smooth interaction with
different computers' operating systems.

C++ Source Code Section


Header & Library
Using namespace std;

Global variable declaration


Function Declaration

Main Function

Function Implementation

An Example C++ Program


Header & Library

Using namespace std;

Main Function

Exercise
Identify at least five programming language
available and specify whether it is compiled or
Interpreted.
JAVA is a special type of programming
language, explain what is the role of JVM in
the programming process.

Вам также может понравиться