The Importance of Programming Language Study

Why study Programming Languages?
Increase your capacity to express ideas (both
programming and in general)
Increase your ability to select a PL for a specific
use
Increase your ability to learn new languages
Provide you with a better understanding of
implementation issues in programming
Increase your ability to design a new PL
Provide you with a better understanding of
computational theory
Language Evaluation Criteria
We will
evaluate
languages
based on 5
criteria:
Readability
Writability
Reliability
Cost
Tradeoffs
Readability
The characteristic of code being easy to understand
Factors include
simplicity of instructions
simpler is better (consider how many ways you can incr in
C++/Java)
orthogonality of instructions
are operators/operations similar between types?
for instance, do you add ints and floats in the same way?
a lack of orthogonality leads to exceptions – that is, using
different approaches for different types
consider in Java that you use == for primitives but the equals
method for objects
too much orthogonality can cause problems though, in Smalltalk,
everything is an object, even a number
operator and method/function overloading keeps instructions
orthogonal
Readability Continued
Two more factors of readability were introduced starting
with ALGOL 60
control statements
early languages had insufficient control structures leading to
extensive use of GO TO statements
most modern languages have adequate control statements so that
GO TO statements are not needed and in many cases, not part of
the language
if/if-then/nested if-then
multi-way statement (switch, case)
two or three types of loops
what about statements like break and continue?
data Types and Structures
enumerable types, boolean type, add to readability
More on Readability
Another issue that impacts readability is of syntactic
expression
identifier rules
early languages restricted length of names
modern languages may differentiate between upper and lower case
letters
special words
those words that make up the language are known as special (or
reserved) words, the choice of words can make a language more
readable
explicit end statements (endif, endfor, enddo)?
form and meaning
are words reserved or based on context?
in C, the usage of static is based on context
in FORTRAN, INTEGER and REAL can be types and names
»
INTEGER REAL
 
// REAL is an INTEGER
»
REAL INTEGER
 
// INTEGER is a REAL
Writability
Simplicity and Orthogonality
simplicity has the same meaning as with readability, but the
opposite effect
the more complex an instruction, the better for the programmer
C’s for loop is very flexible – good for writing, not so good for reading
we still want orthogonal languages
if you have to learn different ways to accomplish some task in
different contexts, it becomes more difficult to learn the language
Support for Abstraction
data abstraction (for data structures)
procedural abstraction (for modularity)
Expressitivity
does the language offer convenient ways to express ideas
are there sufficient control structures?
is the definition for a data type difficult or not available? etc.
Reliability
How reliable can a program be written in the given
language?
Features include
type checking
does the language perform compile-time type checking?
how thoroughly are variables checked?
a 
strongly typed 
language will find all type mismatches at compile
time – unfortunately few languages are strongly typed
subprogram parameter and global variable type checking is
difficult
exception handling
introduced in PL/I in the early 60s, it was largely absent from languages
until the late 1980s but now has become a component in most recent
languages
Reliability Continued
Additional reliability features include
Aliasing
two or more variables reference the same named item
most commonly associated with pointers and parameters
changing the item through one of the aliased names may
be an unnoticed or undesired side effect
most languages do nothing to prevent aliases
Readability and Writability
the more readable the language, the more reliable it will
be
the less writable the language, the greater the chance of
hard-to-find errors
 Cost
Cost is primarily a function of time
training/learning curve
readability positively influences this, writability requires more
training
time to write programs
writability positively influences this
compilation speed/efficiency
affects programmer time
execution speed/efficiency
execution speed is desired because this what the user sees
most languages will sacrifice compilation speed for execution
speed
maintenance
a language that is more readable and reliable is easier to
maintain
Other Factors
Portability
Java excels here as do scripting languages
Generality
most languages today are general enough but some are
too paradigm-specific (e.g., strictly functional
languages)
Well-definedness and standardization
Lack of legacy issues
modern languages generally don’t have legacy issues
Language selection can often be a tradeoff
between
readability and flexibility/writability (more flexible
makes it less readable)
cost and expressiveness
type checking/reliability and abstraction/flexibility
Language Categories and Domains
Historically, languages developed to solve particular
types of problems
FORTRAN – math and science
COBOL – business applications/database accesses
LISP – AI (list processing and recursion)
Languages were divided into programming paradigm
Imperative (procedural like C, Pascal)
Functional (LISP, F# among others)
Declarative (Prolog)
Object-oriented
High-level languages can be classified as
compiled vs interpreted
scripting languages are interpreted although most also have
compilers
PL Paradigms
Procedural – earliest form, still used today when
OOP is not being used (e.g., in C or Java with only
a single class)
represent data
code operates on data
usually group code into subroutines for modularity
OOP – similar except that data and code are
grouped together
rather than thinking in terms of subroutines, you think in
terms of a class, its functionality (what the class does)
and its behavior (how it does it)
OOP and procedural are similar in terms of types of
programming language constructs and how you go about
solving problems
PL Paradigms Continued
Functional – no (or few) local variables, instead
mathematical functions which compute based
(usually) solely on parameters
disallow side effects
f(x) should always return the same value for a given x
recursion used extensively
functional programming is the opposite of OOP
Declarative – no (or few) programming
instructions
declare what you know, ask a question
language contains its own built-in processing (e.g.,
chaining, unification)
Slide Note

By learning about programming languages, you learn about syntax and grammar. This should help you in the future when it comes to learning any language, but most particularly, when you have to learn other programming languages.

You will see as we examine a variety of languages that most contain the same language constructs. The difference is how they are implemented and how you use them. For instance, C languages have a much more flexible for loop than other languages. On the other hand, Java and Lisp use pointers that do not require dereferencing.

We will study in this class the various programming language features that are most commonly found from a use point of view (how you use them) and an implementation point of view. We will examine older languages to see how we evolved to this point, and modern languages to identify issues that are still open to debate.

Embed
Share

Explore the benefits of studying programming languages, including enhanced idea expression, better language selection, and improved learning abilities. Dive into language evaluation criteria and readability factors like simplicity, orthogonality, and control structures. Gain insights into readability through ALGOL, control statements, and syntactic expression rules.

  • Programming languages
  • Readability
  • Language evaluation
  • Implementation issues
  • Computational theory

Uploaded on Sep 28, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Why study Programming Languages? Increase your capacity to express ideas (both programming and in general) Increase your ability to select a PL for a specific use Increase your ability to learn new languages Provide you with a better understanding of implementation issues in programming Increase your ability to design a new PL Provide you with a better understanding of computational theory

  2. Language Evaluation Criteria We will evaluate languages based on 5 criteria: Readability Writability Reliability Cost Tradeoffs Characteristic Readability * Writability * Reliability * Simplicity/ Orthogonality Control Structures Data types/ Structures Syntax Design * * * * * * * * * * * Support for Abstraction Expressitivity * * * * Type Checking Exception Handling Restricted Aliasing *

  3. Readability The characteristic of code being easy to understand Factors include simplicity of instructions simpler is better (consider how many ways you can incr in C++/Java) orthogonality of instructions are operators/operations similar between types? for instance, do you add ints and floats in the same way? a lack of orthogonality leads to exceptions that is, using different approaches for different types consider in Java that you use == for primitives but the equals method for objects too much orthogonality can cause problems though, in Smalltalk, everything is an object, even a number operator and method/function overloading keeps instructions orthogonal

  4. Readability Continued Two more factors of readability were introduced starting with ALGOL 60 control statements early languages had insufficient control structures leading to extensive use of GO TO statements most modern languages have adequate control statements so that GO TO statements are not needed and in many cases, not part of the language if/if-then/nested if-then multi-way statement (switch, case) two or three types of loops what about statements like break and continue? data Types and Structures enumerable types, boolean type, add to readability

  5. More on Readability Another issue that impacts readability is of syntactic expression identifier rules early languages restricted length of names modern languages may differentiate between upper and lower case letters special words those words that make up the language are known as special (or reserved) words, the choice of words can make a language more readable explicit end statements (endif, endfor, enddo)? form and meaning are words reserved or based on context? in C, the usage of static is based on context in FORTRAN, INTEGER and REAL can be types and names INTEGER REAL REAL INTEGER // REAL is an INTEGER // INTEGER is a REAL

  6. Writability Simplicity and Orthogonality simplicity has the same meaning as with readability, but the opposite effect the more complex an instruction, the better for the programmer C s for loop is very flexible good for writing, not so good for reading we still want orthogonal languages if you have to learn different ways to accomplish some task in different contexts, it becomes more difficult to learn the language Support for Abstraction data abstraction (for data structures) procedural abstraction (for modularity) Expressitivity does the language offer convenient ways to express ideas are there sufficient control structures? is the definition for a data type difficult or not available? etc.

  7. Reliability How reliable can a program be written in the given language? Features include type checking does the language perform compile-time type checking? how thoroughly are variables checked? a strongly typed language will find all type mismatches at compile time unfortunately few languages are strongly typed subprogram parameter and global variable type checking is difficult exception handling introduced in PL/I in the early 60s, it was largely absent from languages until the late 1980s but now has become a component in most recent languages

  8. Reliability Continued Additional reliability features include Aliasing two or more variables reference the same named item most commonly associated with pointers and parameters changing the item through one of the aliased names may be an unnoticed or undesired side effect most languages do nothing to prevent aliases Readability and Writability the more readable the language, the more reliable it will be the less writable the language, the greater the chance of hard-to-find errors

  9. Cost Cost is primarily a function of time training/learning curve readability positively influences this, writability requires more training time to write programs writability positively influences this compilation speed/efficiency affects programmer time execution speed/efficiency execution speed is desired because this what the user sees most languages will sacrifice compilation speed for execution speed maintenance a language that is more readable and reliable is easier to maintain

  10. Other Factors Portability Java excels here as do scripting languages Generality most languages today are general enough but some are too paradigm-specific (e.g., strictly functional languages) Well-definedness and standardization Lack of legacy issues modern languages generally don t have legacy issues Language selection can often be a tradeoff between readability and flexibility/writability (more flexible makes it less readable) cost and expressiveness type checking/reliability and abstraction/flexibility

  11. Language Categories and Domains Historically, languages developed to solve particular types of problems FORTRAN math and science COBOL business applications/database accesses LISP AI (list processing and recursion) Languages were divided into programming paradigm Imperative (procedural like C, Pascal) Functional (LISP, F# among others) Declarative (Prolog) Object-oriented High-level languages can be classified as compiled vs interpreted scripting languages are interpreted although most also have compilers

  12. PL Paradigms Procedural earliest form, still used today when OOP is not being used (e.g., in C or Java with only a single class) represent data code operates on data usually group code into subroutines for modularity OOP similar except that data and code are grouped together rather than thinking in terms of subroutines, you think in terms of a class, its functionality (what the class does) and its behavior (how it does it) OOP and procedural are similar in terms of types of programming language constructs and how you go about solving problems

  13. PL Paradigms Continued Functional no (or few) local variables, instead mathematical functions which compute based (usually) solely on parameters disallow side effects f(x) should always return the same value for a given x recursion used extensively functional programming is the opposite of OOP Declarative no (or few) programming instructions declare what you know, ask a question language contains its own built-in processing (e.g., chaining, unification)

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#