Download Programming Languages

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Functional programming wikipedia , lookup

Structured programming wikipedia , lookup

Stream processing wikipedia , lookup

C syntax wikipedia , lookup

Name mangling wikipedia , lookup

Object-relational impedance mismatch wikipedia , lookup

Programming language wikipedia , lookup

Object-oriented programming wikipedia , lookup

Corecursion wikipedia , lookup

Interpreter (computing) wikipedia , lookup

Reactive programming wikipedia , lookup

Falcon (programming language) wikipedia , lookup

Compiler wikipedia , lookup

Abstraction (computer science) wikipedia , lookup

Go (programming language) wikipedia , lookup

History of compiler construction wikipedia , lookup

Assembly language wikipedia , lookup

ILLIAC IV wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Transcript
Programming Languages:
History & Traditional Concepts
CSC 2001
Solution development
Three main tasks (all very important):
 Understanding the problem
 unambiguous, complete description
 verification/testing
 Solution planning
 pseudocode
 algorithmic design
 verification/testing
 Implementation
 expressing solution in a manner that a computer can execute
 “programming,” but being a computer programmer is more than this!!
 verification/testing
Implementation
 Historical perspective
 Traditional programming concepts
 Procedural units
 Language implementation
 Programming language paradigms
 imperative programming
 object-oriented programming
 Others
 Alice
 Programming Lego Mindstorm Robots with Drizzle
History
Machines can execute instructions in
machine language.
4056
Problems?
machine dependent
hard to read, write, and fix (debug)
Assembly language
In 1940’s, programmers developed a
mnemonic notational system to help.
4056 became something like…
MOV R5, R6
had to build assemblers to translate to machine
language
Pros?
more readable, easier to write
Cons?
still very low level and machine dependent
Remaining challenges
Machine independent language
Ability to express instructions in larger
increments
Why are these good goals?
What additional tools need to be built to
make it work?
Can you foresee any major obstacles with
this?
Two early successes
FORTRAN
FORmula TRANslator
focused on scientific applications
COBOL
Common Business-Oriented Language
developed by US Navy for business
applications
Supporting tools
compilers
translated from higher level language
stores result of translation for later
execution
interpreters
execute while translating
Language “generations”
First generation
machine language
Second generation
assembly language
needs assemblers
Third generation
higher level languages
needs compilers or interpreters
High level language goals
revisited
Did the third generation languages
achieve their goals of machine
independence and larger instruction
increments?
Larger instruction increments?
Yes
Machine independent solutions?
In theory
What do I mean?
We traded machine dependence for
compiler dependence.
If all compilers define the language
exactly the same way, we have machine
independence.
This is often not the case!
Standards
Languages typically have a “standard” formal
definition.
Compiler developers can choose to extend
the language if they want to.
Using these non-standard extensions can lock
you into a particular machine and compiler
because no one else recognizes those
extensions.
Why might a compiler developer do that?
Case study
Java
Developed by SUN with specific goal of
machine independence.
Microsoft’s Java implementation violated
standard.
Microsoft was told they couldn’t call it Java.
Still, you can’t assume “Java is Java.”
Lines are often more blurry with other
languages.
Best to usually stick with standard unless there is
a very good reason to deviate!
Programming language
concepts
A program consists of an ordered set of
statements expressed (typically) in
some high level programming language.
Statement types
Declarative statements
Imperative statements
Comments
Declarative statements
“define customized terminology that is
used later in the program”
associates names (variables) with locations
in main memory
declares the “data type” of each variable
tells computer how to interpret the bits in
memory
Why is this important?
Data types
Common primitive data types
integers (int)
real (double)
character (char)
Boolean
Example declarations (notations may differ!)
int x, y, amount;
double average;
char grade;
Data structures
an organization or collection of primitive data
types
provides more intuitive ways to manage data
Lists (1 dimensional) or tables (multidimensional)
 arrays
 Homogeneous (same type)
 enables working with them as a single unit
Example declarations (notations may differ!)
 char name[12]; (character string)
 float scores[120][20];
Custom data structures
Example: managing student info
Option 1:
Have one array for each of the following:
last name, first name, SSN, email address, final
average, final grade
Problems?
changing sort order?
Custom data structures
Example: managing student info
Option 2:
Create a custom student data structure that
holds a student’s first and last names, SSN,
email address, and final average and grade.
Have a single array of “students”
Custom data structure
We can declare that a “student” data
structure looks as follows: (notations may
differ!)
typedef struct {
char lastName[20], firstName[20];
int SSN;
char email[40];
float average;
char grade;
} student;
What does that mean?
Is Option 2 better than Option 1? Why or why
not?
Data structures
Just like with primitive data types, data
structures tell the computer how to
interpret the bits in the memory
locations associated with the variable
name!
Variables, constants, and
literals
Values of variables often change during
program execution.
Values of constants and literals don’t.
Literals: explicit numbers (3.1415, 17)
Constants: descriptive names for
numbers (PI)
Literals v. constants
Example:
Program to compute sales price:
has array of items with prices
has to include sales tax (10 %)
 .10
Can use literals everywhere
Problems
 Readability (what does that .1 represent?)
 Maintainability (need to change value of sales tax without
changing the price of things costing a dime)
Use a constant called SALES_TAX (good practice)
To do…
Read chapter 6