Comprog

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

INTRODUCTION TO COMPUTER PROGRAMS Computer program - set of instructions that the

computer can execute, and it is our job, as


Computer - machine that can be instructed to carry out
programmers, to write these programs using one or
sequences of arithmetic or logical operations
more programming languages.
automatically via computer programming.
Operating system – Layer that facilitates
- is a programmable machine that performs
communication between Application like (web
arithmetic or logical operations.
browser, word processor, or mail client) and
computer hardware.
A BRIEF HISTORY OF COMPUTING
Device drivers - special programs that are designed to
enable communication between operating system
Year Description Inventor
and a particular hardware device.
Ancient ABACUS – none China,
Times programmable devices that Russia,
helps on getting results of SYSTEM ARCHITECTURE
Eastern
arithmetic computation. Europe
1770s Automata - Dolls that could Pierre
read instructions but cannot Jaquet-
perform arithmetic or logical Droz
operations. It could play
music, make drawings, and
write letters
19th Jacquard machine - automated Jacquard
Century looms that could be
programmed using punch
cards. They produced woven
silk.
19th Difference Engine/Analytical Charles
Century Engine. The Analytical Babbage
Engine was particularly
groundbreaking as it could be
programmable, which meant
it could be used to solve
different problems. HOW DOES A COMPUTER PROGRAM WORK?
1943 Electronic Numerical Integrator J. - We can provide input to the computer in many
and and Computer (ENIAC) - the Presper ways, such as with a keyboard, a mouse, voice
1946 first digital computer because Eckert commands, and touch screens.
it was the first one that was and John - The input data is sent to the computer's storage: the
both completed and fully Mauchly internal memory.
functional - The result of these operations is then sent back to
1833 The inventor of programming, Ada be stored in memory again before it is sent out as
she wrote an algorithm for Lovelace output.
how Bernoulli numbers, a CPU (which is the central processing unit) retrieves the
sequence of rational numbers
data from storage and performs operations on it.
often used in number theory,
could be calculated by the
FOUR TASK OF A COMPUTER
Analytical Engine.
1949 Short Code - can be John
considered to be one of the Mauchly
first higher-level
programming languages.
1954 FORTRAN - considered to be John
the first widely used high- Backus -
level, generalpurpose IBM
programming language
1950s Lisp and COBOL – other John
famous general-purpose McCarthy
programming language.
UNDERSTANDING THE BINARY SYSTEM
Binary code - represents text, computer processor
instructions, or any other data using a two-symbol
system.
- two-symbol system used is often "0" and "1" from
the binarynumber system.
- assigns a pattern of binary digits, also known as
bits, to each character, instruction, etc.
-
UNDERSTANDING ASCII AND UNICODE
ASCII (American Standard Code for Information
Interchange) - Computers can only understand
numbers, so an ASCII code is the numerical PROGRAMMING LANGUAGES
representation of a character such as 'a' or '@' or an Date Programming Inventor
action of some sort. Languages
1943 - Plankalkül Konrad Zuse
1945
April Fortran John Backus
1957
1958 Lisp John McCarty
1958 ALGOL American and
European computer
scientists
1959 COBOL - Common University of
Business-Oriented Pennsylvania
Language
1960- C, C++, Java, Go, Various Computer
present JavaScript, Perl, Scientist
Boolean algebra - branch of mathematics that deals with PHP, Python, C#
operations on logical values with binary variables. and many others.
Boolean variables - represented as binary numbers to
represent truths: 1 = true and 0 = false. TRANSLATING CODE INTO SOMETHING THAT THE
*Elementary algebra deals with numerical operations COMPUTER UNDERSTANDS
whereas Boolean algebra deals with logistical
operations. Interpreting - An interpreter will look at a single line of
source code, translate it into machine code, let the
computer execute this line, and then move on to the
next line of code.
Compiling - When we compile source code into machine
code, we first translate every line of code, and it is
not until the translation of all the lines of code has
Machine code – the native language of the computer been done that the program is executed.

COMPARING INTERPRETATION AND


COMPILATION

INTRODUCTION TO PROGRAMMING LANGUAGES

FAMILY TREE OF PROGRAMMING LANGUAGES


LANGUAGES THAT BOTH COMPILE AND CLIENT-SERVER APPLICATIONS
INTERPRET - a model we can use to create distributed
*The benefit of doing this is that we get some of the applications, which are applications that run on
advantages of both techniques. more than one machine.
*Some examples of mixed technique languages are Email server - handle incoming and outgoing emails,
Python, Java, C#, and Perl. and the client only connects to receive and
transmit messages
SYNTAX AND THE BUILDING BLOCKS OF A IP - an abbreviation for Internet Protocol and is part
PROGRAMMING LANGUAGE of a larger protocol stack, called TCP/IP, that
Syntax - the rules for how we write a program using a describes how computers communicate over the
language. internet
- set of rules defining how the source code will be IP address - can also be in the form of a domain
written and structured. name
*There is one big difference between grammar and - identifies all computers and other devices
syntax and that is about forgiveness for errors. connected to the internet.
Keywords - sometimes also referred to as reserved Domain name - a one-to-one mapping between an IP
words. address and a name.
- language will typically have between 30 and 50 - tied to one single IP address and is used
keywords. because it is easier to remember a domain
*Most programming languages are case sensitive, so name than an IP address that is just four
the use of uppercase and lowercase letters numbers in the form 123.123.123.123.
matters—for example, if is not the same thing as If Web application process
or IF. 1. The information you entered is sent to the
server
OPERATORS 2. The server requests the information stored in
- programming language will also have several a database about this user:
operators, and these are what we use to
3. The database returns the information it has for
accomplish things such as addition and
this user.
multiplication, as well as to compare items.
4. Server produces a web page for this user and
transmits it to the client's computer

WEB APPLICATIONS
- a special form of client-server application where
we have a client that interacts with a user in the
form of a web page
- server is responsible for producing the results the
Code blocks - sometimes referred to as a compound user will see and to accept and process the input
statement. from the user.
- a lexical structure of source code which is - are unique because, the logic of our application is
grouped together done on the server side, and it's the server that will
- Blocks consist of one or more declarations and produce the pages the user sees.
statements.
Braces or curly brackets {} - common technique that MOBILE APPLICATIONS
many languages employ is using parentheses. - programs that are designed to run on a mobile
device, such as a smartphone and tablets.
TYPES OF APPLICATIONS - might also use other features of the device, such
as the GPS, sending text messages, or sensing
STANDALONE APPLICATIONS the movement of the device using its
- is a program that can work offline and does not accelerometer.
necessarily require a network connection. - can be connected, same as client-server setup
- These applications do not need to interact with DISTRIBUTED APPLICATION
other programs. - an application that does not run on one single
Examples - Text editors such as Notepad on machine, but instead lets different parts of the
Windows or TextEdit on Mac, simple games such program run on multiple computers that
as solitaire, and paint programs. communicate with each other over a network.
CLOUD-BASED APPLICATIONS 3. WORKING WITH PACKAGES TO SHARE CODE
Cloud computing - first mentioned in 1996, but it was not Open source - denoting software for which the
until Amazon released its Elastic Compute Cloud in original source code is made freely available and
2006 that it became widely popular. may be redistributed and modified.
Package manager - is a piece of software that will
Advantages of adopting cloud-based applications
help us find, download, and install code.
Reduced costs - we will not need to buy a server
computer, and we will not need to maintain this
computer.
Scalability - is how we can adapt when the amount of
work our application is doing changes.
Python installation instruction
CLOUD SERVICE MODELS
Infrastructure as a Service (IaaS) - handles hardware 4. AVOIDING CONFLICTS USING NAMESPACE
resources such as servers, storage, firewalls, and so Namespace is a declarative region that provides a
on. scope to the identifiers (the names of types,
Platform as a Service (PaaS) - builds upon the IaaS. functions, variables, etc) inside it.
This contains readily configured environments that - used to organize code into logical groups and to
are targeted to a specific purpose. prevent name collisions that can occur especially
Software as a Service (SaaS) - This will provide you with when your code base includes multiple libraries.
everything—the hardware, the server software, as
well as applications—and the only thing you need to SEQUENCE – THE BASIC BUILDING BLOCK OF A
do is to configure it to work the way you want it to. COMPUTER PROGRAM

Sequences - the main logical structure of algorithms or


OTHER TYPES OF APPLICATIONS
programs.
Systems Software - The software in this category helps
- contain any number of instructions but each
the user, applications, and computer hardware to
instruction must be run in the order they are
interact and function together.
presented.
Programming Software - Applications used by
- No instruction can be skipped.
programmers when they write and test software.
*Sequential thinking can help us structure our ideas
Integrated Development Environments (IDE) -
so that we can break them down into smaller
specialized text editors that will assist programmers
pieces.
when writing code.
Statement - a command that the programmer gives to
the computer.
SOFTWARE PROJECTS AND HOW WE ORGANIZE
- expresses some action to be carried out and is
OUR CODE
made up of several internal components.
1. CODE MODULES - sequence of codes that we write is made up of.
Modular programming is a software design technique *print("Hello World") [a statement]
that emphasizes separating the functionality of a *This command has a verb (“print”) and other details
program into independent, interchangeable (what to print).
modules, such that each contains everything Expressions - Statements are made up of expressions,
necessary to execute only one aspect of the and expressions are made up of even smaller parts.
desired functionality. Compound statements - statement that spans several
Benefits: lines.
- able to reuse the module in other applications. - made up of one or more normal one-line
- easier to change or replace a module. statements.
2. WORKING WITH SOFTWARE PROJECTS Separating statements
PROJECT can be used in two different ways when - programming language will separate statements
talking about software development: by defining where a statement ends.
- collaborative enterprise used to develop the - Another popular way to terminate statements is
actual program – in other words, as a group of by using a semicolon, ;
people working together. Python - type of language that use new line to terminate
- container for all the files that make up the statements
program we develop. IDE is used to organize
codes MAKING THE CODE READABLE BY INDENTING AND
USING EMPTY LINES
Indentation - is a technique that we use to show that - You cannot use names that are used as
certain code lines belong together in a block. keywords in the language—that is, words that
Blank lines - are inserted for human readers. are reserved by the language, such as for, if,
and else.
- Spaces or other special characters, such as +,
MAKING THE CODE UNDERSTANDABLE USING -, and *, are not allowed to be part of the name
COMMENTS
Comment - line of normal text, inserted in the code,
which is only for humans.
- we use them to explain lines of code that are not
obviously understood at first glance. Camel case - is where the words that make up a name
*Compiler or interpreter ignores comments, it is not are separated by an uppercase letter that starts each
being executed. word.

Snake case - Separating words with an underscore is


called snake case.
- when using this convention, we only use
lowercase letters and separate words with an
underscore character.
- first_name, email_address, zip_code

PRIMITIVE DATA TYPES


Boolean type - A variable that uses this type can only
Uses of comments have one of two values— true or false
Planning and reviewing - Comments can be used to
plan the structure of the code before it is written. Numeric type
- when writing an intricate part of an application, Integer data types - The integer data type basically
some people prefer to map out the logic with represents whole numbers (no fractional parts).
comments before focusing on the real code. - represents some range of mathematical
Code description - one everyday use of comments is to integers.
summarize what a section of code is doing and - may be of different sizes and may or may not be
explain the programmer's intent. allowed to contain negative values.
Algorithmic description - sometimes, we implement
complex algorithms that need an explanation with
maybe both text and diagrams.

WORKING WITH DATA – VARIABLES

UNDERSTANDING VARIABLES Floating-point data type - family of data types that act
- When writing programs, we continuously work alike and differ only in the size of their domains (the
with data. allowable values).
- As we are using this data, we need a way to keep - represents number values with fractional parts.
track of it. - technically stored as two integer values: a
NAMING VARIABLES mantissa and an exponent.
- The name we give a variable should reflect
what data it represents
Some standard rules for naming variables are as
follows:
- It must begin with a letter of the alphabet or an
underscore (_).
- After the first character, the name can contain Composite type - data type that is made up of more than
letters, underscores, and numbers. one value
Fixed array - When we have a fixed size array, we say OPERATORS – THINGS WE CAN DO WITH
how many slots we want it to have when we create VARIABLES
it.
Arithmetic operators
- This size will not change. numbers[10] = 100
Dynamic array - A dynamic array (or list, vector, or
sequence) is an array that can grow and shrink as
we use it.
- numbers.add(11), numbers[11] = 100
Record type - Records are sometimes called
structures or structs. To use them, we first need to
define what they look like.

Relational operators

Dictionary - also known as a map, hash map, or


associative array
- a collection type that uses key-value pairs. The
key needs to be a unique value that we can use
to retrieve the value that is associated with it.
Logical operators

Set - a composite type that will store unique values


without any order
- this type is unordered, we cannot retrieve items
from it with an index WORKING WITH NUMBERS
- usually not a problem as this type is often used to • We can do basic arithmetic, such as addition,
test for membership subtraction, multiplication, and division,
• We can use them to keep track of how many
times we have done something.
MANIPULATING STRINGS
String - a sequence of characters, and a character does
Enumeration - often called just enum not have to be a letter, it can be punctuation marks,
- is an enumerated type with distinct values. a space, a hyphen, or any other character we can
- we can use this to create our types and dictate produce using a computer.
what values can be assigned to a variable that - can also contain digits
has this type. - 9 is different from "9"
String concatenation -When we take two strings and
add them together to form a new string.
- word = "day" + "break"
Splitting strings -We can split a string into multiple
strings.
String - a composite type as it is stored as an array of Substrings - Are used when we take part of a string to
characters. form a new string.
- Most languages will use double quotes to - Substring (AIRSPACES, 0, 3)
designate that something is a string and will use Case conversion - Conversion from uppercase to
single quotes for single characters. lowercase and viceversa

You might also like