Top Banner
Programming Languages Part 2 CS 1 Rick Graziani Spring 2008
24

Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Dec 28, 2015

Download

Documents

Avis Horton
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Programming LanguagesPart 2

CS 1

Rick Graziani

Spring 2008

Page 2: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 2

Goal of third generation languages

• 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

Op-code Operand Description 1 LOAD reg. R from cell XY. 2 LOAD reg. R with XY. 3 STORE reg. R at XY. 4 MOVE R to S. 5 ADD S and T into R. (2’s comp.) 6 ADD S and T into R. (floating pt.) 7 OR S and T into R. 8 AND S and T into R. 9 XOR S and T into R. A ROTATE reg. R X times. B JUMP to XY if R = reg. 0. C HALT.

Page 3: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 3

Page 4: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 4

Page 5: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 5

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

Page 6: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 6

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

Page 7: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 7

Evolution of Programming Languages

• Lineage does not represent that one language evolved from another, although this is the case with some languages.

Page 8: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 8

Evolution of Programming Languages

Page 9: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 9

Evolution of Programming Languages

Page 10: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 10

Procedural Languages

• 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

Main Program

Procedure 1

Procedure 2

Procedure 3

Page 11: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 11

Object Oriented Programming

• 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

Left click

Right click

Page 12: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 12

Other types of languages

• Other types of languages include:– Functional languages: LISP, Scheme– Declarative languages: Prolog– Scripting languages: Perl, PHP, shell scripts, HTML

Page 13: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 13

Programming Concepts

• Program consists of:– Declarative statements

• Variables and data types– Imperative statements

• Procedures, instructions, and algorithms– Comments

• Enhance readability• Used throughout the program

Page 14: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 14

Variables and Data Types

• 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.

125

9.75

d

Integer

Float

Character

Page 15: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 15

Programming Concepts

Count 1

I will not throw paper airplanes in class.

2

I will not throw paper airplanes in class.

3

I will not throw paper airplanes in class.…

499

I will not throw paper airplanes in class.

500

I will not throw paper airplanes in class.

501

Page 16: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 16

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

Page 17: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 17

Variables

• Variables:– Can be given an initial value within the program– Value may change from:

• Program instructions• User input

Count 1

I will not throw paper airplanes in class.

2

I will not throw paper airplanes in class.

3

I will not throw paper airplanes in class.…

499

I will not throw paper airplanes in class.

500

I will not throw paper airplanes in class.

501

Page 18: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 18

Data structure

• 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]

1 2 3 4 5 … … 24 25

B o o l o o

char Last_Name[25]

Page 19: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 19

Data structure

• Two dimensional array– Row and column– Integer pins [bowler, frame]

1

2

3

4

3

12

0

7

6

9

1

7

Integer pins [bowler, frame]

Page 20: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 20

Assigning Value

• 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.

125

9.75

d

Integer

Float

Character

Fahrenheit = (9/5)Celcius + 32

Page 21: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 21

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

Page 22: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 22

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.

Page 23: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Rick Graziani [email protected] 23

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

• 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

Page 24: Programming Languages Part 2 CS 1 Rick Graziani Spring 2008.

Programming LanguagesPart 2

CS 1

Rick Graziani

Spring 2008