programming -1 · electronic devices. • 1991 • recognizing this, sun microsystems funded an...
TRANSCRIPT
Programming -1
Introduction to programming languages
Latifah Altraiki
Objective
In this chapter you’ll:
• Understand What is computer programming .
• Learn about programming language.
• Describe types of programming languages.
• Understand the importance of programming career.
• Learn How to program?
Programming
• The way of communication between human and computer.
• Since a computer cannot understand what a person is saying, Programming languages was raised up.
Programming
• Defined as the process of writing instructions and directing commands to a computer or other device.
• Computers process data under the control of sequences of instructions called computer programs.
Programming
Problem Solve the idea instructions
Who is programmer ?
• A programmer is a someone who is able to write
commands to a computer to make it able to perform a specific task.
• Software programs guide the computer through ordered actions specified by people called computer programmers.
• The computer user must be distinguished from the programmer, where the user depends and benefits from what is produced by the programmer from applied programs, entertainment or educational programs.
Computer and Programming
• The main advantages of the computer that benefits programmer to solve problems:
• Speed : Computers can perform calculations and make logical decisions phenomenally faster than human beings can.
• Repetition: The computer is characterized by the ability to execute operations or commands several times determined by the programmer.
• Precision : A computer can perform complex calculations in very accurate precision.
• Storage: The computer's ability to store the data to be retrieved later, it features a large data size capable of storing, speed and accuracy in retrieval.
Hardware and Software- What is a Computer?• A computer consists of a CPU, memory, hard disk, monitor,
printer, and communication devices.
• To write instructions commanding computers to perform tasks.
Software (i.e., the instructions you write) controls hardware (i.e.,
computers).
• Today’s personal computers can perform billions of calculations
in one second—more than a human can perform in a lifetime.
• Supercomputers are already performing thousands of trillions
(quadrillions) of instructions per second!
Computers: Hardware and Software- (Cont.)
• A computer consists of various
devices referred to as hardware(e.g.,
the keyboard, screen, mouse, hard
disks, memory, DVD drives and
processing units).
• Computing costs are dropping
dramatically, owing to rapid
developments in hardware and
software technologies.
Hardware and Software- Computer Organization.
• Computers can be envisioned as divided into various logical units or sections.
• Input unit.
• Output unit.
• Memory unit.
• Arithmetic and logic unit (ALU).
• Central Processing unit (CPU).
• Secondary storage unit.
Computer Organization- Input and Output unit• Input unit “receiving section”:
• Obtains information ( data and computer programs) from input devices and places it at disposal of the other units for processing.
• Output unit “shipping section”:
• Takes information the computer has processed and places it on various output devices to make it available for use outside the computer .
Computer Organization- Memory unit and ALU
• Memory unit “Wearhouse section”:
• Retains information that has been entered through the input unit, making it immediately available for processing when needed.
• Arithmetic and logic unit (ALU) “manufacturing section” :
• Performs calculations such as addition, subtraction, multiplication and division. It is also containing the decision mechanism.
Computer Organization-CPU and Secondary storage unit
• Central Processing unit (CPU) “administrative section”:
• Coordinates and supervises the operation of the other section.
• Secondary storage unit “warehousing section”:
• Programs or data not actively being used by the other units normally are placed on secondary storage devices (e.g hard drive) until they’re again needed.
Data Hierarchy
• Data items processed by computers form a data hierarchy that becomes larger and more complex in structure as we progress from the simplest data items (called “bits”) to richer ones, such as characters and fields.
Data Hierarchy (Cont.)• Bits
• The smallest data item in a computer can assume the value 0 or the value 1.
• Remarkably, the impressive functions performed by computers involve only the simplest manipulations of 0s and 1s—examining a bit’s value, setting a bit’s value and reversing a bit’s value (from 1 to 0 or from 0 to 1).
• Characters
• We prefer to work with decimal digits (0–9), uppercase letters (A–Z), lowercase letters (a–z), and special symbols (e.g., $, @, %, &, *, (, ), –, +, ", :, ? and / ).
• Digits, letters and special symbols are known as characters. The computer’s character set is the set of all the characters used to write programs and represent data items on that device.
• Computers process only 1s and 0s, so every character is represented as a pattern of 1s and 0s.
Data Hierarchy (Cont.)
• Fields
• Just as characters are composed of bits, fields are composed of characters or bytes.
• A field is a group of characters or bytes that conveys meaning.
• For example, a field consisting of uppercase and lowercase letters could be used to represent a person’s name, and a field consisting of decimal digits could represent a person’s age.
Data Hierarchy (Cont.)
• Records
• Several related fields can be used to compose a record (implemented as a class in Java).
• In a payroll system, for example, the record for an employee might consist of the following fields :
• Employee identification number (a whole number)
• Name (a string of characters)
• Address (a string of characters)
• Hourly pay rate (a number with a decimal point)
• Year-to-date earnings (a number with a decimal point)
• Amount of taxes withheld (a number with a decimal point)
• Thus, a record is a group of related fields.
• In the preceding example, all the fields belong to the same employee.
Data Hierarchy (Cont.)
• Files
• A file is a group of related records.
• Database
• A database is a collection of data that’s organized for easy access and manipulation.
• The most popular database model is the relational database in which data is stored in simple tables.
Types of software
• Software allows users to use physical components (hardware) efficiently and comfortably.
• The software can be divided into three main types:
1. Operating System.
2. Application Programs.
3. Programming Languages.
Programming languages
• Programmers write instructions in various programming languages, some directly understandable by computers and others requiring intermediate translation steps.
• These may be divided into three general types:
Types of programming languages:
Machine Languages Assembly languagesHigh
level languages
Machine languages
• Machine Languages
• Any computer can directly understand only its own machine language, defined by its hardware design.
• Generally consist of strings of numbers (ultimately reduced to 1s and 0s) that instruct computers to perform their most elementary operations one at a time.
• Machine dependent—a particular ma-chine language can be used on only one type of computer.
Assembly Languages and Assemblers
• English-like abbreviations that represent elementary operations formed the basis of assembly languages.
• Translator programs called assemblers convert early assembly-language programs to machine language
High-Level Languages
• High-level languages
• Single statements accomplish substantial tasks.
• A payroll program written in a high-level language might contain a single statement such as
• grossPay= basePay+ overTimePay
High-Level Languages (cont.)
• There are many high-level programming languages used to write programs, and the difference between these languages is only in the way of expressing each type of previous commands and instructions.
• Examples of different programming languages include:
• visual basic.
• Java.
• C++
• C#
• Python ….
High-Level Languages (Cont.)
• Structural programming:
• Depend on building a data structure without paying attention to the processes that can be applied to the data, programmers then began to reveal a new programming method that combines data and processes into a single structure for the close relationship between data and processes this was the object-oriented programming.
• OPP- Object-oriented programming:
• Object-oriented programming (OOP)allows you to implement an object-oriented design as a working system.
• It is an advanced programming pattern, which divides the program into units called objects.
• We can say is a new method used in programming enables us to analyze and design applications in the form of objects that contain data and processes together
The importance of basic concepts of programming language
• In all programming languages there are basic concepts related to the simplest components through which you can write a program even if simple.
• These concepts are common, but the way they are written and defined by the translator may vary.
•
Software Compiler /
Interpreter Machine
language Hardware
Compiler (translator)
• Compilers convert high-level language programs into machine language.
• Allow you to write instructions that look almost like everyday English and contain commonly used mathematical notations.
• It is part of a programming language that converts commands from the language expression method into the language of the operating system and compiles them into a single file called the EXE program file.
Source
ProgramCompiler EXE Program
Processing
unit
Interpreter
• Compiling a high-level language program into machine language can take considerable computer time.
• Interpreter programs, developer to execute high-level language programs directly, avoid the delay or compilation, although they run slower than compiled programs.
• Converts the program to the machine language line by line, unlike the compiler (translator) who converts the entire program once after you finish writing it.
• In some high-level programming languages, both the compiler and the interpreter are used, such as Java.
Interpreter Compiler
Translates program one statement at a
time(line by line).
Scans the entire program and
translates it as a whole into machine
code.
It takes less amount of time to analyze
the source code but the overall
execution time is slower.
It takes large amount of time to
analyze the source code but the overall
execution time is comparatively faster.
Continues translating the program
until the first error is met, in which
case it stops. Hence debugging is easy.
It generates the error message only
after scanning the whole program.
Hence debugging is comparatively
hard.
Programming language like Python,
Ruby use interpreters.
Programming language like C, C++ use
compilers.
Programming language like Java use both the compiler and the interpreter.
Computer and Programming
• To reach the goal of writing the program we must go through the following stages:
1. Identify the problem to be solved.
2. Find a solution.
3. Write the program.
Thinking PlanningWrite the program
Java Language
• Java is one of the world’s most widely used computer programming languages.
• Java is an object-oriented programming -OPP .
• 2015 marks the 20th anniversary of the first release of Java for public use
Java language (Cont.)
• For many organizations, the preferred language for meeting their enterprise programming needs is Java.
• Java is also widely used for implementing Internet-based applications and software for devices that communicate over a network.
• According to Oracle, enterprise desktops, PC desktops, large number of mobile devices and 100% all Blu-ray Disc™ (medical devices) players run Java.
The status of Java in the world
10 million Java
developers.
15 billion devices.
Java is now in the cloud
Java story
• Microprocessors have had a profound impact in intelligent consumer-electronic devices.
• 1991
• Recognizing this, Sun Microsystems funded an internal corporate research project led by James Gosling, which resulted in a C++-based object-oriented programming language that Sun called Java.
• Key goal of Java is to be able to write programs that will run on a great variety of computer systems and computer-controlled devices.
• This is sometimes called “write once, run anywhere.”
Java story (Cont.)
• 1993
• The web exploded in popularity
• Sun saw the potential of using Java to add dynamic content to web pages.
• Java drew the attention of the business community because of the phenomenal interest in the web.
• Java is used to develop large-scale enterprise applications, to enhance the functionality of web servers, to provide applications for consumer devices and for many other purposes.
Duke is a lucky amulet for java
The original Duke was
created by Joe Barling,
graphic designer in green
team
Java Release Date
Java versionYear
2017
Java Technical Products
There are four sets of Java technology products and
the types of devices that target:
1. Java Standard Edition (Java SE ), Java platform.
2. Java Enterprise Edition (Java EE) , Java platform.
3. Micro Edition (Java ME), Java platform.
4. Java card.
Java SE
• Java Standard Edition contains the capabilities needed to develop desktop and server applications.
Java EE
• The Java Enterprise Edition (Java EE) is geared toward developing large-scale, distributed networking applications and web-based applications.
Java ME
Java Micro Edition (Java ME)
• a subset of Java SE.
• geared toward developing applications for
resource-constrained embedded devices,
such as
• Smartwatches
• MP3 players
• television set-top boxes
• smart meters (for monitoring electric energy usage)
• and more.
Java card
• There are five billion Java cards in use.
• They are used to create applications that can work safely on smart cards and similar devices with small units.
• Java cards are commonly used in the following areas:
• Identity cards.
• Security purposes.
• Business transactions
• SIM cards in mobiles phone.
Setup requirements for Java
• To write any program in Java we need to install the following:
• IDK
• JDK
• JRE
Java (JRE) Runtime environment
• Includes:
• Java Virtual Machine (JVM).
• Java class libraries.
• The purpose :
• Read the instructions, consisting of bytes (.class).
• Run the same byte instruction anywhere using Java Virtual Machine (JVM).
Java Development Kit ( JDK)
• Includes:
• JRE
• Java compiler (translator ).
• Additional tools.
• The purpose :
• Translate the instructions, consisting of bytes ( . java .class)
Integrated development environment IDE
• The purpose :
• Provide an advanced text editor.
• Help in correcting code errors.
• Projects management.
• Write the source code (.java).
• Examples:
• Eclipes.
• NetBeans.
• BlueJ and Greenfoot.
• Alice.
Compile the Java program and run it
Writing translate Execute
You have an
idea to create
a program
(.java)
The result is to
create a file
.class (Byte
instructions)
The code is
included in the
file(.java)
Your code is
working!The code is
included in the
file(.java)
writing translate Execute
Compile the Java program and run it
• The program is written in a high-level language; however, it must be translated into machine language instruction.
• Most programming languages compile an independent executable file for each platform.
• Java is a programming language independent of the platform.
✓ Using IDE such as Eclipse in writing source code (.java).
✓ JDK translate the instructions, consisting of bytes ( . java .class) .
✓ Run the instructions, consisting of bytes (.class) in Java Virtual Machine (JVM) ,
which is a part JRE
Summary
• What is computer programming .
• Learn about programming language.
• Describe types of programming languages.
• The importance of programming career.
• How to program?