0% found this document useful (0 votes)
5 views40 pages

Introduction to Programming Concepts

Uploaded by

farebaaminy08
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views40 pages

Introduction to Programming Concepts

Uploaded by

farebaaminy08
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

What is Program? What Is Programming? How to tell a computer what to do?

Computer Languages Computer Languages Type

Introduction to Programming
02-Introduction to Programming

Khadija Rahmany

Women Online University


Computer Science Faculty

March 28, 2024


What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Table of contents
What is Program?
What Is Programming?
How to tell a computer what to do?
Computer Languages
Computer Languages Type
Translator software
The way, Java does it...
Bytecode
Java Virtual Machine (JVM)
Let’s See Java in Practical !!!
Installing Java on your PC
Summery
Think ON...
Reffrences
Question
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

What is Program?

• A program consists of instructions that tell the computer what


to do, how to behave.
• A program has two distinct concepts
• Used by users repeatedly to perform a task after installing on
the computer.
• Text file of instructions to the computer written in some
languages that can be translated into executable files.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

What Is Programming?

• Programming is planning how to solve a problem. No matter


what method is used – pencil and paper, computer –problem
solving requires programming.
• A creative process done by programmers to instruct a
computer on how to do a task with the help of a language.
1. Requirements gathering
2. Analysis
3. Design
4. Implementation
5. Testing, Debugging
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

How to tell a computer what to do?

• Human beings communicate with each others in different


language such as Urdu, French, Punjabi and Arabic etc.
• A computer can not understand natural [Link] CPU
of a computer can only execute commands coded in 0’s and
1’s.
• To communicate with the computers we have to use specific
languages and for this purpose hundreds of languages have
been develop in which few of them has gained international
reputation. Java language is one of them.
• So we have to know computer languages
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Computer Languages

• A tool for humans and computers to communicate


• Programmers write instructions in various Computer
Languages, some directly understandable by computers and
others that require intermediate translation steps.
• Hundreds of computer languages are in use today. These may
be divided into three general types:
1. Machine languages
2. Assembly languages
3. High-level languages
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Computer Languages Type


What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Computer Languages Type


Machine languages

• Primitive computer languages that consisted entirely of 1’s


and 0’s.
• Machine languages consist of numbers only.
• Any computer can directly understand only its own
machine language.
• Machine language is the natural language of a particular
computer.
• It is also referred as machine code or object code.
• Good for computers, bad for programmers.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Computer Languages Type


assembly languages

• Machine-language programming was simply too tedious for


most programmers.
• Instead of using the strings of numbers that computers could
directly understand, programmers began using English-like
abbreviations to represent the elementary operations of
computers .
• The programs in Assembly language are written using these
mnemonic 1 codes as: ADD for addition, SUB for subtraction
• Programmers still use assembly language when speed is
essential.
• Assembly languages are also called as low level language.

1
A mnemonic is an abbreviation for an operation
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Computer Languages Type


High Level languages

• High level languages allow programmers to write instructions


that look almost like everyday English and contain commonly
vocabulary and set of grammatical rules.
• They are closer to human languages and further from
machine languages.
• The main advantage of high-level languages over low-level
languages is that they are easier to read, write
• The term programming language usually refers to high-level
languages.
• The first high-level programming languages were designed in
1950s. Now there are dozens of different languages, including
Ada, BASIC, COBOL, C, C++, LISP and Pascal.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software

• Programs written in a high-level language must be


translated into machine language.
• Translator software are software that translating any
languages into machine understandable language.
• There are list of translator software:
1. Assemblers
2. Compilers
3. Interpreters
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Assemblers

• Programs written in Assembly language are translated to


machine language by assemblers

     
Assembly Code Assembler
  Machine
 Code 
 
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Compilers

• High level Language must be translated into machine


language as well.
• A program that translates human readable source code into
computer executable machine code or Object code.
• Reads the sourcecode from a file
• Checks the sourcecode for mistakes
• Writes the machinecode to another file
• The program can be executed later
• Any changes to source code require complete recompilation.
• Example: Turbo Pascal, C,C++ , etc.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Compilers
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Compilers and different machines
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Interpereter

• Another type of translator used for translating a language


program into machine code.
• Takes one statement, translates, executes then fetches
another statement.
• Statements from the source program are fetched and executed
one by one.
• No copy of the translation exists, and if the program is to be
re-run, it has to be interpreted all over again.
• Example :Unix shell ,JavaScript and PHP.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Interpreter
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Interpreters on different machines
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Advantages and disadvantages of compiler

• Advantages:
• Once a program is compiled, it can be run very often
without recompiling it
• Pre-compiled programs run much faster than interpreted
ones
• Compilers can find mistakes better then interpreters
• Disadvantages
• Programs have to be recompiled every time they have
changed For bigger programs, this can take a long time.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Comparison of compiled and interpreted code
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Advantages and disadvantages of Interpreter

• Advantages:
• It is not necessary to recompile a program when it has
changed. The new change can be run directly.
• Disadvantages
• Because an interpreter does not save the source Code but runs
the program directly, the source code has to be translated
every time the program runs
• This makes the program running much slower then a
precompiled program.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Compiler and interpreter

• Programming languages can be divided into three Types:


• Complied languages like C, C++
• Interpreted languages like Bash, PHP
• Mixed form like Java, Python
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

The way, Java does it...


What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

The way, Java does it...

• Java is a High Level Programming Language that must


translate
• Because of the problems with interpreters and the problem
with compilers, java uses a mixture between compiling and
interpreting.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Translator software
Compiler and interpreter
• In this case the source code is translated by a compiler in a
sort of object code, also called byte code that is then executed
by an interpreter implementing a virtual machine using this
byte code
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Bytecode

• Programs are written in Java are complied by the Java


Compiler javac. The result is a program in Java Bytecode.

• Bytecodes are the machine language of the Java virtual


machine
• The Java compiler on a Macintosh will produce the exact
same bytecodes as the Java compiler on an Intel system.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Java Virtual Machine (JVM)

• This code can not be run by a real computer, but it can be


interpreted by a software called the Java Virtual Machine
(JVM).
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Java Virtual Machine (JVM)

• The JVM is a software, which can be easily programed for


nearly every computer and operating machine.
• It can interpret Java Bytecode faster than a normal interpreter
can interpret sourcecode.
• Java programs can be run on every machine a JVM exists for.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

JVM on different machines


What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Let’s See Java in Practical !!!


What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Installing Java on your PC


Windows

• It needs you to install the necessary Java components and


files. First up is the Java Virtual Machine.
• you need to head over to Sun’s website to get the Java Virtual
Machine, also known as the Java Runtime Environment (JRE).
Try this page first:
[Link]

• When you click the link, your computer will be scanned for the
JRE. you’ll be given the opportunity to download and install it.
• After downloading and installing, you may need to restart you
computer. When you do, you will have the Java Virtual
Machine.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Installing Java on your PC


Windows

• At this stage, you still can’t write any programmes. The


only thing you’ve done is to install software so that Java
programmes can be run on your computer.
• To write code and test it out, you need something called a
Software Development kit
• Java’s Software Development Kit can currently be downloaded
from here:
[Link]

• The one we’re going to be using is called Java SE. (The SE


stands for Standard Edition.). Click on that link, then on
”Java SE (JDK) 6 Download”.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Installing Java on your PC


PATH Variable

• Follow the instructions to download java and run the .exe to


install Java on your machine.
• Once you installed Java on your machine, you would need to
set environment variables to point to correct installation
directories
• Usually you create a subdirectory someplace convenient to
hold the various program files for a new [Link] would like
to run the compiler while working in that directory.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Installing Java on your PC


PATH Variable

• The Windows operating system uses an environment variable


called PATH that is a list of all the subdirectories where it
should look to find programs.
• To see what is in your PATH variable, type PATH in your
DOS window:
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Installing Java on your PC


PATH Variable

• Exactly what you see depends on your OS and what you have
done with it. If you don’t see C:\Program Files
\Java\jdk1.5.0-06 (or similar) in your PATH you will have to
edit your PATH variable
• Right-click on ’My Computer’ and select ’Properties ’.
• Click on the ’Environment variables’ button under
the’Advanced’tab.
• Now alter the ’Path’variable so that it also contains the path
to the Java executable. Example, if the path is currently set to
’C:\WINDOWS\SYSTEM32’, then change your path to read
’C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin’.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Installing Java on your PC


PATH Variable
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Summery

• A program consists of instructions that tell the computer


what to do, how to behave.
• Programming is planning how to solve a problem.
• Computer languages are tool for humans and computers to
communicate such as machine languages, assembly languages
and high-level languages.
• Programs written in a high-level language must be translated
into machine language by translator software such as
assemblers, compilers and interpreters.
• Java is a High Level Programming Language that uses a
mixture between compiling and interpreting.
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Think ON...

• Java Programming Language


What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Reffrences

1. [Link]
2. [Link].[Link]
3. [Link]
4. [Link]
wcs/
5.
[Link]
6. [Link] gpollice/cs544-
f05/CourseNotes/maps/Class1/[Link]
What is Program? What Is Programming? How to tell a computer what to do? Computer Languages Computer Languages Type

Question

You might also like