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

Lecture 1 - Introduction To Programming

java

Uploaded by

jafarhossaini238
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 views37 pages

Lecture 1 - Introduction To Programming

java

Uploaded by

jafarhossaini238
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
You are on page 1/ 37

Islamic Emirate of Afghanistan

Ministry of Higher Education


Herat University
Computer Science Faculty

Introduction to Practical Computer Science 1 (Semester 1)


Introduction to Programming
Lecture 01

Lecturer: Mohammed Hamed Amiry


[email protected]

8/21/2025 1
Content…
What is a Program?
What Is Programming?
How to tell a computer what to do?
Computer Languages
Computer Languages Type
Translator software
Type of Java Editions
Java Virtual Machine (JVM)
Installing Java on your PC
Q & A Section
What is a 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 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.
• Requirements gathering
• Analysis
• Design
• Implementation
• Testing, Debugging
How to tell a computer what to do?
• Human beings communicate with each others in different language
such as Dari, French, Punjabi and Arabic etc.
• A computer can not understand natural language. The 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
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
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.
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 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.
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.
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
Translator software
Assemblers

• Programs written in Assembly language are translated to machine language by


assemblers
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 source code from a file
• Checks the source code for mistakes
• Writes the machine code to another file
• The program can be executed later

• Any changes to source code require complete recompilation.


• Example: Turbo Pascal, C,C++ , etc.
Translator software
Compilers
Translator software
Interpreter
• 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.
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.
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.
Translator software
Comparison of compiled and interpreted code
Translator software
Compiler and interpreter

• Programming languages can be divided into three Types:


• Complied languages like C, C++
• Interpreted languages like Bash, PHP, JavaScript
• Mixed form like Java, Python
The way, Java does it...
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.
• Write Once, Run Anywhere
Type of Java Editions
• Java Standard Edition
• to develop client-side applications.
• The applications can run on desktop.
• Java Enterprise Edition
• to develop server-side applications, such as Java servlets,
JavaServer Pages (JSP), and JavaServer Faces (JSF).
• Java Micro Edition
• to develop applications for mobile devices, such as cell phones.
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.
Translator software
Compiler and interpreter
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.
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).
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
source code.
• Java programs can be run on every machine a JVM exists for.
Let’s See Java in Practical !!!
Installing Java on your PC
• For installing java you need to install java development kit(jdk).
• For downloading latest jdk you must visit the Oracle website and
download the software
• https://www.oracle.com/java/technologies/javase-jdk15-downloads.html
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 project. You would like to run the compiler while
working in that directory.
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:
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\jdk-15.0.1 (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-15.0.1\bin’.
Installing Java on your PC
PATH Variable
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.
For more study
• Chapter 1
Next Lecture On
• Java Programming Language
Q &A SECTION

8/21/2025 37

You might also like