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
no text concepts found
Transcript
Introduction to CS260
Programming Languages
WHY MORE?
Wasn’t ONE ENOUGH?
Cart before the horse
• Before contrasting(text), get a feel for how
languages are similar
• But as author does -> You need to think of
programming on a different level
• You know how to implement algorithms
• Now learn to do it better
• In order to assess whether you have the best
approach, you need to understand
consequences of your choices
• Does your approach take too long or too
much memory?
• Is your approach easy to understand?
Readable?
• Is it prone to errors
• Is your program reasonably extendable or
have you programmed yourself into a
corner?
• How can you possibly judge?
It’s a little early
• Your understanding of these concepts will
become clearer with time and experience
• Understanding examples from other
languages to illustrate a point is basically
premature
• Start slowly
• First look for similarities in languages and
then differences
• Develop a vocabulary for language issues
Similarities
• Learning new languages is not as difficult
as it appears
• Many of the languages are similar to c/c++
• This leverages you into a position of
immediate knowledge of other languages
• Knowing how to categorize differences
leads you to know lots of other information
• E.g. knowing the sex of a person leads you
to be able to reach a number of other
conclusions -> physical, emotional, etc
Major categories
• Representation of data
• Flow of control
– expression
– statement
– procedure
• Interpreted vs compiled
• Scope of access to data and procedures
• Information hiding
Influence of language
• Try to think of any concept or idea without
the use of words / language
• LANGUAGE shapes the way you think
• Greek language has a number of different
words for different types of love. English
tries to use the same word in different
contexts. We struggle to differentiate the
types of love.
• Programming language dictates our solution
Language influence
User Interfaces
Methodologies
design
tcl
Provide
access to
create
Language
utilize
Architectural
Features
create design
Applications
use
OS
Applications are Interaction of
Data
Operations
Language understanding begins
by examining these areas!
Data
•
•
•
•
Simple data types
Aggregate data types
User/Programmer extendable types
System supplied and hardware supplied
Operations
•
•
•
•
Expression level
Statement level
Procedural level
Process level
Binding times
• Many of the features are characterized by
when the feature can change
• E.g. consider allocation and initialization of a
simple data type
–
–
–
–
compilation
beginning of execution
entry into procedure
entry into a code block
Scope
• How do you determine access to data
– minimization is good
• Access to procedures
– should you have access to all functions and all
versions
Languages specialize
•
•
•
•
•
•
•
Business -> COBOl
Scientific -> FORTRAN
Systems (OS) -> C
General Purpose -> C/C++/Ada/java
Internet -> java
Scripting -> shell
Artificial Intelligence -> Lisp/Prolog
Languages have tradeoffs
• Readability (Simplicity) vs Power (Functionality)
• Too little orthogonality (features dependent on
other features - too many exceptions) vs too
much orthogonality (independence creates too
many possibilities and increased complexity)
– c allows functions to return structs but not arrays(little)
– allowing complicated expressions which evaluate to
allocation on LHS of assignment is unreasonable
• e.g.
(&c)+23=y+z
• Syntax rules promoting readability may create
programs more cumbersome to write
– generally we accept the short-term inconvenience
– Aside (syntax/form vs semantics/meaning)
• for statement
•
•
•
•
•
Size of language vs cost of support tools
Reliability vs cost/speed of execution
Flexibility vs complexity/cost/safety
Our most important concern is COST
Many poor decisions are a result of not
considering real costs!
Compiled vs interpreted
• Compiled
– translate entire program into machine language
– execute
• Interpret
–
–
–
–
translate piece
execute
repeat
more flexibility (e.g. changing data type)
Environments
• Development/testing environments
influence our choices
• visual vs command line
• debugging aids
• compiler error assistance
Most important factors
• Machine architecture
– von Neumann
– in the end you have to implement what you
design
• Methodology
– modular
– structured (top-down design)
– object oriented
Time makes languages a
melting pot of all good in
other languages
• Java like c like pascal like algol like fortran
…
• All embrace
procedures/parameters/objects/etc
• Fundamentally different approaches become
fewer