Programming Languages
Part 2
CS 1
Rick Graziani
Spring 2008
Goal of third generation languages
Op-code
1
2
3
4
5
6
7
8
9
A
B
C
Operand
Description
LOAD reg. R from cell XY.
LOAD reg. R with XY.
STORE reg. R at XY.
MOVE R to S.
ADD S and T into R. (2’s comp.)
ADD S and T into R. (floating pt.)
OR S and T into R.
AND S and T into R.
XOR S and T into R.
ROTATE reg. R X times.
JUMP to XY if R = reg. 0.
HALT.
• Goal of third generation languages (C, C++, Java):
•
– Statements (language) do not refer to the attributes of
any particular machine
• Statements not part of the CPU’s machine language
Program written an a third generation language could
theoretically be compiled to run on any other computer.
– In reality this is not completely accurate
Rick Graziani [email protected]
2
Rick Graziani [email protected]
3
Rick Graziani [email protected]
4
Programming language standards
• Programming language (C, C++, Java):
•
– Standard commands
– Vendor’s options
Standard organizations:
– ANSI (American National Standards Institute)
– ISO (International Organization for Standardization)
• ISO is not a TLA but meaning “equal” in Greek
Rick Graziani [email protected]
5
Vendor Compiler Options
•
Vendor compiler options:
– Language extensions
– Features to make it easier to program
– Not compatible with other vendor’s compilers
– Makes it difficult to change to another vendor’s compiler
Rick Graziani [email protected]
6
Evolution of Programming Languages
•
Lineage does not represent that one language evolved
from another, although this is the case with some
languages.
Rick Graziani [email protected]
7
Evolution of Programming Languages
Rick Graziani [email protected]
8
Evolution of Programming Languages
Rick Graziani [email protected]
9
Procedural Languages
Main
Program
Procedure 1
Procedure 2
Procedure 3
•
•
Procedural Languages
– Traditional approach to programming.
– Procedure is a sequence of commands which can be
used multiple times by the main set of instructions.
Procedural Languages include:
– Fortran, COBOL, BASIC, ADA, Pascal, C
Rick Graziani [email protected]
10
Object Oriented Programming
Left
click
•
•
•
Right
click
Object Oriented Programming (OOP)
– Software system is viewed as a collection of units, called objects.
– Object – has the capability of performing certain actions and to call other
objects.
Example: Screen icons
– Each icon is an object
– Each object encompasses a collection of procedures known as methods
– Each method describes how that object will respond to events such as:
• Double left click (run the program)
• Right click (display a series of options)
Example OOP Languages: C++, Visual Basic, Java
Rick Graziani [email protected]
11
Other types of languages
•
Other types of languages include:
– Functional languages: LISP, Scheme
– Declarative languages: Prolog
– Scripting languages: Perl, PHP, shell scripts, HTML
Rick Graziani [email protected]
12
Programming Concepts
• Program consists of:
– Declarative statements
• Variables and data types
– Imperative statements
• Procedures, instructions, and algorithms
– Comments
• Enhance readability
• Used throughout the program
Rick Graziani [email protected]
13
Variables and Data Types
Integer
125
Float
9.75
Character
d
• Variable – A location in RAM (main memory), given a descriptive
•
•
name, which stores information.
Data type – Variables are a type of day which can be:
– Number
• Integer: 0, 1, 2, 3, 4, 5, 6, etc.
• Real (floating point): 9.75, 300.5412
– Character: a, b, c, A, B, C, etc.
– String of text: “123 Main Street”
Working area or scratch pad for the program.
Rick Graziani [email protected]
14
Programming Concepts
Count
499
500
501
1
2
3
I will not throw paper airplanes in class.
I will not throw paper airplanes in class.
I will not throw paper airplanes in class.
…
I will not throw paper airplanes in class.
I will not throw paper airplanes in class.
Rick Graziani [email protected]
15
Variables
• Variables are declared, defined in the declaration section of the
program.
– Usually at the beginning of the program
– Examples:
int height_in_inches
char first_initial
float price
Rick Graziani [email protected]
16
Variables
Count
499
500
501
1
2
3
I will not throw paper airplanes in class.
I will not throw paper airplanes in class.
I will not throw paper airplanes in class.
…
I will not throw paper airplanes in class.
I will not throw paper airplanes in class.
• Variables:
– Can be given an initial value within the program
– Value may change from:
• Program instructions
• User input
Rick Graziani [email protected]
17
Data structure
1 2 3 4 5 …
… 24 25
B o o l o o
char Last_Name[25]
• Variables are often associated with a data structure.
• Data structure – A conceptual shape of arrangement of data
• Homogeneous Array
•
– Block of values of the same type
– Such as a one dimensional list or a two dimensional array (row,
column)
Example: String or array of characters
– char Last_Name[25]
Rick Graziani [email protected]
18
Data structure
1
2
3
4
3
6
12
0
7
9
1
7
Integer pins [bowler, frame]
• Two dimensional array
– Row and column
– Integer pins [bowler, frame]
Rick Graziani [email protected]
19
Assigning Value
Integer
125
Float
9.75
Character
•
d
Assignment statement – Statement which assigns a
value to a variable.
– Value assigned from user input
– Value assigned from another variable
– Value assigned from a specific value
– Value assigned from a calculation that can include both
variables and assigned values.
Fahrenheit = (9/5)Celcius + 32
Rick Graziani [email protected]
20
Open Source Software
• Open source software is computer software for which the
•
•
•
human-readable source code is made available under a
copyright license (or arrangement such as the public
domain) that meets the Open Source Definition.
This permits users to:
– Use the software
– Change the software
– Improve the software
– Redistribute it in modified or unmodified form
It is often developed in a public, collaborative manner.
Wikipedia
Rick Graziani [email protected]
21
Open Source Definition
1. Free Redistribution: the software can be freely given away or sold.
2. Source Code: the source code must either be included or freely
obtainable. (Without source code, making changes or modifications
can be impossible.)
3. Derived Works: redistribution of modifications must be allowed.
4. Integrity of The Author's Source Code: licenses may require that
modifications are redistributed only as patches.
5. No Discrimination Against Persons or Groups: no one can be
locked out.
6. No Discrimination Against Fields of Endeavor: commercial users
cannot be excluded.
7. Distribution of License: The rights attached to the program must
apply to all to whom the program is redistributed without the need for
execution of an additional license by those parties.
8. License Must Not Be Specific to a Product: the program cannot be
licensed only as part of a larger distribution.
9. License Must Not Restrict Other Software: the license cannot insist
that any other software it is distributed with must also be open source.
10.License Must Be Technology-Neutral: no click-wrap licenses or
other medium-specific ways of accepting the license must be required.
Rick Graziani [email protected]
22
Projects
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Apache Software Foundation
Audacity
Blender -- 3d animation
CodePlex
Debian
Drupal -- Content Management System
Eclipse Foundation
Fedora Project
FreeBSD
Freedesktop.org
Free Software Foundation
FUSE ESB, FUSE Message Broker, FUSE
Services Framework and FUSE Mediation
Router - Supported versions of Apache
projects
GIMP -- Image Editing similar to photoshop
GNU
Inkscape -- Vector tool similar to illustrator
Java
JBoss
Joomla! -- Content Management System
KnowledgeTree -- Document Management for
Teams and Small to Medium-sized
Organizations
LibreSource
Linux
Macaulay2 -- algebraic geometry and
commutative algebra
Rick Graziani [email protected]
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Miranda IM -- multiprotocol IM
Mozilla Foundation
MySQL
NetBSD
OpenBSD
Open-Xchange
Open Market For Internet Content Accessibility
OpenOffice.org -- Word processor, spreadsheet,
presentation tool, database, equation editor
OpenSees -- open system for earthquake
engineering simulation
OpenSuse
Open Solutions Alliance
Open Source Development Labs
Open Source Initiative
Open Source Geospatial Foundation
PHP -- Hypertext preprocessor
Povray -- Ray Tracer
Python
Restore -- RESTORE is an open source project for
heterogeneous system backup and restore.
SAGE -- Magma computer algebra system
Scribus -- Desktop publishing similar to pagemaker
SourceForge -- Repository of open source software
Subversion (software) -- version control
Synfig -- 2d vector graphic and animation
TYPO3 -- Enterprise Level Content Management
System
ubuntu
Zenoss
Zimbra
23
Programming Languages
Part 2
CS 1
Rick Graziani
Spring 2008
Descargar

Document