SlideShare a Scribd company logo
Programming and Paradigms
Course overview
Edward (Ned) Blurock
Lecture: Programming
Paradigm
CIS: Edward Blruock
LANGUAGES
Why so many programming Languages?
Lecture: Programming
Paradigm
CIS: Edward Blruock
Programming Language
Lecture: Programming
Paradigm
CIS: Edward Blruock
The process of developing and implementing
various sets of instructions
to enable a computer to do a certain task.
The language used to program computers is not understood by an
untrained eye. Computer programming continues to be a necessary
process as the Internet continues to expand.
Read more: http://www.businessdictionary.com/definition/computer-
programming.html#ixzz3jLVEiKeK
Top Ten Programming Languages
Lecture: Programming
Paradigm
CIS: Edward Blruock
Top Ten
Lecture: Programming
Paradigm
CIS: Edward Blruock
1. http://spectrum.ieee.org/computing/software/the-2015-top-ten-
programming-languages
2. http://www.tiobe.com/index.php/content/paperinfo/tpci/index.h
tml
3. http://timesofindia.indiatimes.com/tech/slideshow/10-
programming-languages-you-need-to-know-in-
2015/itslideshowviewall/46286489.cms
4. http://www.inc.com/larry-kim/10-most-popular-programming-
languages-today.html
5. http://mashable.com/2015/01/18/programming-languages-
2015/
Wierdest
Lecture: Programming
Paradigm
CIS: Edward Blruock
http://tutorialzine.com/2013/12/the-10-weirdest-programming-languages/
High-level programming language
Lecture: Programming
Paradigm
CIS: Edward Blruock
"High-level language" refers to the higher level of
abstraction from machine language.
Abstraction penalty:
Execution modes
• Interpreted
• Compiled
• Machine code generation: assembly language
• Intermediate code: byte code
• Source to Source: trans-compiled
https://en.wikipedia.org/wiki/High-level_programming_language
AbstractionPenalty
Lecture: Programming
Paradigm
CIS: Edward Blruock
While high-level languages are intended to make complex
programming simpler, low-level languages often produce more
efficient code. Abstraction penalty is the border that prevents
high-level programming techniques from being applied in
situations where computational resources are limited. High-level
programming exhibits features like more generic data structures,
run-time interpretation, and intermediate code files; which often
result in slower execution speed, higher memory consumption,
and larger binary program size
Abstraction
Lecture: Programming
Paradigm
CIS: Edward Blruock
Abstraction can apply to control or to data:
Control abstraction is the abstraction of actions while
Data abstraction is that of data structures.
Control abstraction
involves the use of subprograms and related concepts control flows
Data abstraction
allows handling data bits in meaningful ways.
For example, it is the basic motivation behind datatype.
One can view the notion of an object as a way to combine abstractions of data and code.
The same abstract definition can be used as a common interface for a family of objects
with different implementations and behaviors but which share the same meaning.
The inheritance mechanism in object-oriented programming can be used to define an
abstract class as the common interface.
History
Lecture: Programming
Paradigm
CIS: Edward Blruock
http://www.paulgraham.com/fix.html
What languages fix
A view of the development of languages:
The NEXT language
fixes short-comings
of the PREVIOUS language
Power of a Language
Lecture: Programming
Paradigm
CIS: Edward Blruock
All languages are equally powerful in the sense of being Turing equivalent, but
that's not the sense of the word programmers care about. (No one wants to
program a Turing machine.)
The kind of power programmers care about may not be formally definable,
but one way to explain it would be to say that it refers to features you could only
get in the less powerful language by writing an interpreter for the more powerful
language in it.
If language A has an operator for removing spaces from strings
and language B doesn't, that probably doesn't make A more powerful,
because you can probably write a subroutine to do it in B.
But if A supports, say, recursion, and B doesn't,
that's not likely to be something you can fix by writing library functions.
Paul Graham: http://www.paulgraham.com/avg.html
Blub Paradox
Lecture: Programming
Paradigm
CIS: Edward Blruock
Programmers get very attached to their favorite languages,
and I don't want to hurt anyone's feelings, so to explain this point I'm
going to use a hypothetical language called Blub.
Blub falls right in the middle of the abstractness continuum.
It is not the most powerful language,
but it is more powerful than Cobol or machine language.
Paul Graham: http://www.paulgraham.com/avg.html
The Blub Paradox
Lecture: Programming
Paradigm
CIS: Edward Blruock
As long as our hypothetical Blub programmer is looking down the power continuum,
he knows he's looking down.
Languages less powerful than Blub are obviously less powerful,
because they're missing some feature he's used to.
But when our hypothetical Blub programmer looks in the other direction, up the
power continuum,
he doesn't realize he's looking up.
What he sees are merely weird languages.
He probably considers them about equivalent in power to Blub, but with all this other
hairy stuff thrown in as well.
Blub is good enough for him, because he thinks in Blub.
Paul Graham: http://www.paulgraham.com/avg.html
Blub Paradox
Lecture: Programming
Paradigm
CIS: Edward Blruock
You can't trust the opinions of the others, because of the Blub paradox:
they're satisfied with whatever language they happen to use,
because it dictates the way they think about programs.
I know this from my own experience,
as a high school kid writing programs in Basic.
That language didn't even support recursion.
It's hard to imagine writing programs without using recursion,
but I didn't miss it at the time.
I thought in Basic.
And I was a whiz at it.
Master of all I surveyed.
Paul Graham: http://www.paulgraham.com/avg.html
A reason to take this course
Lecture: Programming
Paradigm
CIS: Edward Blruock
Learn at least one new [programming] language every
year.
Different languages solve the same problems in
different ways.
By learning several different approaches, you can help
broaden your thinking and avoid getting stuck in a rut.
The Pragmatic Programmer: From Journeyman to Master
Andrew Hunt
http://www.amazon.com/The-Pragmatic-Programmer-Journeyman-Master/dp/020161622X
© O. Nierstrasz PS — Denotational Semantics 8.16
Defining Programming Languages
There are three main characteristics of
programming languages:
1. Syntax: What is the appearance and structure of its programs?
2. Semantics: What is the meaning of programs?
The static semantics tells us which (syntactically valid) programs are
semantically valid (i.e., which are type correct) and the dynamic semantics
tells us how to interpret the meaning of valid programs.
3. Pragmatics: What is the usability of the language? How easy is it to
implement? What kinds of applications does it suit?
Programming Languages
© O. Nierstrasz PS — Denotational Semantics 8.17
1. Syntactic Abstraction Mechanism:
to reduce repetitive "boilerplate" code that cannot be abstracted
from using another language's built-in abstraction mechanisms.
2. Thought shaper:
to induce a paradigm shift in how one should structure software
(changing the "path of least resistance").
3. Simplifier:
to boil down an existing paradigm to just its essential parts, often to
increase understanding and insight.
4. Law Enforcer:
to enforce important properties or invariants, possibly to make it
easier to infer more useful properties from programs.
Tom Van Cutsam: http://soft.vub.ac.be/~tvcutsem/whypls.html
syntactic abstraction mechanism
Lecture: Programming
Paradigm
CIS: Edward Blruock
Purpose:
Lightweight syntax that lets programmers do the same
things as before, but with less code
Example: C
provides multiple looping constructs,
multiple conditional constructs,
multiple constructs for incrementing/updating the value of a variable.
loop through the elements of arrays
increment or decrement the values of variables
perform multiway conditionals based on numeric or character values.
Programming language designers provide special purpose syntactic constructs that
handle the most common patterns.
The opposite: no syntactic abstraction
Lecture: Programming
Paradigm
CIS: Edward Blruock
Language: Chicken http://torso.me/chicken
https://isotropic.org/papers/chicken.pdf
https://www.youtube.com/watch?v=yL_-1d9OSdk
Language: Chickens
Lecture: Programming
Paradigm
CIS: Edward Blruock
1. A chicken program consists of the tokens "chicken", " " and "n”.
2. Every line has a number of chickens separated by spaces.
3. The number of chickens corresponds to an opcode.
4. Trailing newlines are significant, as an empty line will produce a "0" opcode.
5. Instructions are loaded onto the stack and executed there directly, which allows for
injecting arbitrary code and executing it through a jump.
6. Self-modifying code is also possible because the program stack is not bounded.
7. The user is able to supply an input value before executing the program. This input is
stored in one of the two registers.
The operations:
http://esolangs.org/wiki/Chicken
thought shaper
Lecture: Programming
Paradigm
CIS: Edward Blruock
The goal of a thought shaper language is to change the way a programmer thinks about
structuring his or her program.
The basic building blocks provided by a programming language,
as well as the ways in which they can (or cannot) be combined,
will tend to lead programmers down a "path of least resistance",
for some unit of resistance.
For example,
an imperative programming style is definitely the path of least resistance in C.
It's possible to write functional C programs, but as C does not make it the path of least
resistance, most C programs will not be functional.
Thought Shaper
Lecture: Programming
Paradigm
CIS: Edward Blruock
Experienced programmers carry quite a number of patterns around in their heads.
They may have learned these patterns from books or by hard won experience.
The patterns enable a fluid style of programming where attention can be maintained on
the unknown parts of the task at hand and work feels productive.
Programmers tend to like programming languages
that have good support for the patterns they use.
Programmers don't like languages
that disallow or inconvenience the patterns they use.
They are also rarely impressed by language features that support patterns they don't
know or use.
http://c2.com/cgi/wiki?BlubParadox
Thought Shaper
Lecture: Programming
Paradigm
CIS: Edward Blruock
(pure) Functional Programming
Functional programming languages, by the way, are a good example of
thought shaper languages.
By taking away assignment from the programmer's basic toolbox,
the language really forces programmers coming from an imperative language
to change their coding habits.
Thought Shaper
Lecture: Programming
Paradigm
CIS: Edward Blruock
linguistic relativity
holds that cognitive processes, such as thought and experience,
may be influenced by the categories and patterns of the language a
person speaks.
From the field of linquistics
https://en.wikipedia.org/wiki/Linguistic_relativity
the structure of a language affects the ways in which its respective
speakers conceptualize their world, i.e. their world view, or
otherwise influences their cognitive processes.
a simplifier
Lecture: Programming
Paradigm
CIS: Edward Blruock
A designer knows he has achieved perfection not when there is nothing
left to add, but when there is nothing left to take away.
In software, the most beautiful code, the most beautiful functions, and the
most beautiful programs are sometimes not there at all.
Bentley, Jon, The most beautiful code I never wrote, Beautiful Code, O'Reilly Media, Inc.,2007
law enforcer
Lecture: Programming
Paradigm
CIS: Edward Blruock
http://www.cs.cornell.edu/courses/cs1130/2012sp/1130selfpaced/module1/module1part4/strongtyping.html
One property that is sometimes looked for in
a programming language is safety
Safety:
Any attempt to misinterpret data is caught at compile time
or generates a well-specified error at runtime.
definition used in the year 2000 by an ad hoc committee that
recommended that the Advanced Placement (AP) test in programming be
based on the programming language Java
Strong Typing
Lecture: Programming
Paradigm
CIS: Edward Blruock
Some errors arise from lack of understanding;
others are logical errors caused by inadequate thinking and design;
and some are simply typos.
In all cases, finding errors early, at compile time, can save
immense amounts of time.
Safety and strong typing make possible
the early detection of many errors.
A strongly typed language has one simple feature: knowledge of a value’s type at runtime.
Strong vs. Weak Typing
Lecture: Programming
Paradigm
CIS: Edward Blruock
String foo = "Hello, world!";
Object obj = foo;
String bar = (String) obj;
Date baz = (Date) obj;
The above example will run perfectly fine
until the last line,
which will raise a ClassCastException.
This is because Java is indeed strongly typed.
Even though the obj variable is of the type Object, its value
is still a String. Casting it to a String works fine, but trying to
cast it to a Date fails.
char* foo = "Hello, world!";
int x = foo * 10;
printf("%in", x);
The above block is valid C code,
but the output is not well-defined.
…. This is because C does not store anything in memory
other than the raw values—it would be impossible at
runtime to know that foo was a char* and x was an int.
Strong
Weak
Program Verification:
Bugs
Lecture: Programming
Paradigm
CIS: Edward Blruock
Here are some famous ones:
ESA Ariane 5 Flight 501 self-destruction
40 seconds after takeoff (June 4, 1996).
A conversion from 64-bit floating point to 16 bit integer
with a value larger than possible with Arian 4.
The overflow caused a hardware trap
The Pentium bug
Incorrect floating-point division.
Cost Intel ~ $400,000,000
The 2003 North America blackout
was triggered by a local outage that went undetetected.
A race condition in General Electric’s monitoring software prevented an alarm
Program Verification:
Testing
Lecture: Programming
Paradigm
CIS: Edward Blruock
When you look at a big commercial software company like Microsoft,
there's actually as much testing that goes in as development. We have
as many testers as we have developers. Testers basically test all the
time, and developers basically are involved in the testing process about
half the time…
Bill Gates:
The test cases are unbelievably expensive; in fact, there's more lines
of code in the test harness than there is in the program itself. Often
that's a ratio of about three to one
Program Verification
Lecture: Programming
Paradigm
CIS: Edward Blruock
Formal = based on rigorous mathematical logic concepts.
Once we formally specify what we expect from the program, we
can try to prove that the program satisfies the specification.
Styles of formal semantics
Lecture: Programming
Paradigm
CIS: Edward Blruock
Operational.
Meanings for program phrases defined in terms of the steps
of computation they can take during program execution.
Axiomatic.
Meanings for program phrases defined indirectly via the axioms
and rules of some logic of program properties.
Denotational.
Concerned with giving mathematical models of programming
languages. Meanings for program phrases defined abstractly
as elements of some suitable mathematical structure.
Denotational Semantics Example
Lecture: Programming
Paradigm
CIS: Edward Blruock
<expr> → number
| ( <expr> )
| <expri>+ <expr>
| <expri>− <expr>
| <expri>∗ <expr>
| <expr>/<expr>
[[n1 + n2]] = rep(n1) + rep(n2)
[[e1+e2]] = [[e1]] + [[e2]]
Denotational Semantics Example
Lecture: Programming
Paradigm
CIS: Edward Blruock
Operational Semantics
Lecture: Programming
Paradigm
CIS: Edward Blruock
A category of formal programming language semantics
in which certain desired properties of a program,
such as correctness, safety or security,
are verified by
constructing proofs from
logical statements about its execution,
rather than by attaching mathematical meanings to its terms
(denotational semantics).
The operational semantics for a programming language describes how a
valid program is interpreted as sequences of computational steps
Operational Semantics
Lecture: Programming
Paradigm
CIS: Edward Blruock
Two categories:
structural operational semantics
(or small-step semantics)
formally describe how the individual steps of a computation
take place in a computer-based system.
natural semantics
(or big-step semantics)
describe how the overall results of the executions are obtained.
Operational Semantics
Lecture: Programming
Paradigm
CIS: Edward Blruock
The process:
1. Identify a virtual machine (an idealized computer)
2. Build a translator (translates source code to the machine code
of an idealized computer)
3. Build a simulator for the idealized computer
Operational semantics is sometimes called translational
semantics, if an existing PL is used in place of the virtual machine
http://courses.cs.vt.edu/~cs3304/Spring00/notes/Chapter-3b/index.htm
Axiomatic Semantics
Lecture: Programming
Paradigm
CIS: Edward Blruock
• An assertion before a statement is called a precondition
• An assertion following a statement is a postcondition
Based on formal logic (first order predicate calculus)
Original purpose: formal program verification
Approach:
Define axioms or inference rules
for each statement type in the language
Inference rule
allows one to transform expressions to other expressions
assertions
state the relationships and constraints among variables
that are true at a specific point in execution
Axiomatic Semantics
Lecture: Programming
Paradigm
CIS: Edward Blruock
Logic Programming (declarative) view of program
Translation to logical statements means you can construct a proof
For example:
Can verify the correctness of the program
automatically through
automatic theorem provers
If the precondition on the first statement is the same as the program spec,
the program is correct
Program proof process:
The postcondition for the whole program is the desired results
Work back through the program to the first statement
Denotational Semantics
Lecture: Programming
Paradigm
CIS: Edward Blruock
denotational semantics (initially known as mathematical semantics or Scott–
Strachey semantics) is an approach of formalizing the meanings of
programming languages by constructing mathematical objects (called
denotations) that describe the meanings of expressions from the languages.
Other approaches to providing formal semantics of programming languages
include axiomatic semantics and operational semantics.
https://en.wikipedia.org/wiki/Denotational_semantics
With formal semantics we give programs meaning by mapping them into
some abstract but precise domain of objects. Using denotational semantics,
we provide meaning in terms of mathematical objects, such as integers,
truth values, tuples of values, and functions. For this reason, denotational
semantics was originally called mathematical semantics.
http://homepage.cs.uiowa.edu/~slonnegr/plf/Book/Chapter9.pdf

More Related Content

PPTX
Programming paradigm
PPTX
CS152 Programming Paradigm
PPTX
Programming Paradigm & Languages
PPTX
Paradigms
PPTX
Prgramming paradigms
PPTX
Imperative programming
DOC
Programming paradigms
PDF
Programing paradigm &amp; implementation
Programming paradigm
CS152 Programming Paradigm
Programming Paradigm & Languages
Paradigms
Prgramming paradigms
Imperative programming
Programming paradigms
Programing paradigm &amp; implementation

What's hot (20)

PPTX
Programming Paradigms Seminar 1
PDF
Programming Paradigms
PPT
Programming language
PDF
Programming languages and concepts by vivek parihar
PPT
SD & D Types of programming language
PDF
Principles of-programming-languages-lecture-notes-
PPT
SD & D Implementation
PPT
Programming language design and implemenation
PPT
Programing Language
PPTX
Procedural programming
PPT
Introduction to programming languages part 1
PPT
Text Editors and IDEs
PPT
Lect 1. introduction to programming languages
PDF
Ppl for students unit 1,2 and 3
PPT
PROGRAMMING LANGUAGES
PPTX
Go programing language
PPTX
Programming landuages
PPT
Programming Languages An Intro
PPTX
Basic programming concepts
PPT
Introduction to programing languages part 1
Programming Paradigms Seminar 1
Programming Paradigms
Programming language
Programming languages and concepts by vivek parihar
SD & D Types of programming language
Principles of-programming-languages-lecture-notes-
SD & D Implementation
Programming language design and implemenation
Programing Language
Procedural programming
Introduction to programming languages part 1
Text Editors and IDEs
Lect 1. introduction to programming languages
Ppl for students unit 1,2 and 3
PROGRAMMING LANGUAGES
Go programing language
Programming landuages
Programming Languages An Intro
Basic programming concepts
Introduction to programing languages part 1
Ad

Viewers also liked (20)

PDF
Programming paradigm
PPTX
Programming Paradigm & Languages
PPTX
Programming languages
PPTX
Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!
PDF
Comparison of Type Systems
PPTX
Webinar: Strongly Typed Languages and Flexible Schemas
PDF
Plc (1)
PPTX
ADA programming language
PPT
Thesis power point dream
PPT
Programming paradigm and web programming
PDF
Describe professional programing languages and talks
PPTX
Parsing
PPTX
C++ language
PDF
Intro to functional programming
PPTX
Overview of programming paradigms
PDF
Introduction of Functional Programming
PPT
Generations Of Programming Languages
PDF
Programming Paradigms Which One Is The Best?
Programming paradigm
Programming Paradigm & Languages
Programming languages
Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!
Comparison of Type Systems
Webinar: Strongly Typed Languages and Flexible Schemas
Plc (1)
ADA programming language
Thesis power point dream
Programming paradigm and web programming
Describe professional programing languages and talks
Parsing
C++ language
Intro to functional programming
Overview of programming paradigms
Introduction of Functional Programming
Generations Of Programming Languages
Programming Paradigms Which One Is The Best?
Ad

Similar to Programming Languages (20)

PDF
Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi
PPTX
Ch1 language design issue
PDF
The epistemology of programming language paradigms
PPTX
L1.1 Introduction to Programming Languages.pptx
PPTX
Plc part 1
PPT
Introduction to Computer
PPTX
Introduction to programming
PPT
Programming Language Introduction Lecture
PPT
software principle programming language
PPT
Python and principle of programming language.ppt
PPT
brief intro for Programming Languages 02-chapter-1
PPT
02-chapter-1.ppt programming languages 10
PPT
Ppl 13 july2019
PPTX
computer programming computer programmin
PDF
Why Languages Matter 20090123
PDF
Introduction
PPT
02-chapter-1.ppt
PPT
Ppt for engineering students PPL subject
PDF
Principles of Programming Languages - Lecture Notes
PPTX
Principles of Intro to Programming Languages
Programming Languages Categories / Programming Paradigm By: Prof. Lili Saghafi
Ch1 language design issue
The epistemology of programming language paradigms
L1.1 Introduction to Programming Languages.pptx
Plc part 1
Introduction to Computer
Introduction to programming
Programming Language Introduction Lecture
software principle programming language
Python and principle of programming language.ppt
brief intro for Programming Languages 02-chapter-1
02-chapter-1.ppt programming languages 10
Ppl 13 july2019
computer programming computer programmin
Why Languages Matter 20090123
Introduction
02-chapter-1.ppt
Ppt for engineering students PPL subject
Principles of Programming Languages - Lecture Notes
Principles of Intro to Programming Languages

More from Edward Blurock (20)

PPTX
Ontology for the semantic enhancement, database definition and management and...
PPTX
Ontology for the Semantic Enhancement, Database Definition and Management and...
PPTX
Use of Ontologies in Chemical Kinetic Database CHEMCONNECT
PDF
KEOD23-JThermodynamcsCloud
PPTX
BlurockPresentation-KEOD2023
PPTX
KEOD-2023-Poster.pptx
PDF
ChemConnect: Poster for European Combustion Meeting 2017
PPTX
ChemConnect: SMARTCATS presentation
PPTX
EU COST Action CM1404: WG€ - Efficient Data Exchange
PPTX
ChemConnect: Viewing the datasets in the repository
PPTX
ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...
PDF
Poster: Characterizing Ignition behavior through morphing to generic curves
PDF
Poster: Very Open Data Project
PDF
Poster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISAT
PPTX
Characterization Ignition Behavior through Morphing to Generic Ignition Curves
PPTX
Computability, turing machines and lambda calculus
PPTX
Relational algebra
PPTX
Database normalization
PPTX
Generalization abstraction
PPTX
Overview
Ontology for the semantic enhancement, database definition and management and...
Ontology for the Semantic Enhancement, Database Definition and Management and...
Use of Ontologies in Chemical Kinetic Database CHEMCONNECT
KEOD23-JThermodynamcsCloud
BlurockPresentation-KEOD2023
KEOD-2023-Poster.pptx
ChemConnect: Poster for European Combustion Meeting 2017
ChemConnect: SMARTCATS presentation
EU COST Action CM1404: WG€ - Efficient Data Exchange
ChemConnect: Viewing the datasets in the repository
ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-­‐...
Poster: Characterizing Ignition behavior through morphing to generic curves
Poster: Very Open Data Project
Poster: Adaptive On-­‐the-­‐fly Regression Tabula@on: Beyond ISAT
Characterization Ignition Behavior through Morphing to Generic Ignition Curves
Computability, turing machines and lambda calculus
Relational algebra
Database normalization
Generalization abstraction
Overview

Recently uploaded (20)

PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Yogi Goddess Pres Conference Studio Updates
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Trump Administration's workforce development strategy
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
Cell Types and Its function , kingdom of life
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
History, Philosophy and sociology of education (1).pptx
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Lesson notes of climatology university.
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Yogi Goddess Pres Conference Studio Updates
UNIT III MENTAL HEALTH NURSING ASSESSMENT
Microbial disease of the cardiovascular and lymphatic systems
Trump Administration's workforce development strategy
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Cell Types and Its function , kingdom of life
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Anesthesia in Laparoscopic Surgery in India
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Weekly quiz Compilation Jan -July 25.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
History, Philosophy and sociology of education (1).pptx
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Lesson notes of climatology university.

Programming Languages

  • 1. Programming and Paradigms Course overview Edward (Ned) Blurock Lecture: Programming Paradigm CIS: Edward Blruock
  • 2. LANGUAGES Why so many programming Languages? Lecture: Programming Paradigm CIS: Edward Blruock
  • 3. Programming Language Lecture: Programming Paradigm CIS: Edward Blruock The process of developing and implementing various sets of instructions to enable a computer to do a certain task. The language used to program computers is not understood by an untrained eye. Computer programming continues to be a necessary process as the Internet continues to expand. Read more: http://www.businessdictionary.com/definition/computer- programming.html#ixzz3jLVEiKeK
  • 4. Top Ten Programming Languages Lecture: Programming Paradigm CIS: Edward Blruock
  • 5. Top Ten Lecture: Programming Paradigm CIS: Edward Blruock 1. http://spectrum.ieee.org/computing/software/the-2015-top-ten- programming-languages 2. http://www.tiobe.com/index.php/content/paperinfo/tpci/index.h tml 3. http://timesofindia.indiatimes.com/tech/slideshow/10- programming-languages-you-need-to-know-in- 2015/itslideshowviewall/46286489.cms 4. http://www.inc.com/larry-kim/10-most-popular-programming- languages-today.html 5. http://mashable.com/2015/01/18/programming-languages- 2015/
  • 6. Wierdest Lecture: Programming Paradigm CIS: Edward Blruock http://tutorialzine.com/2013/12/the-10-weirdest-programming-languages/
  • 7. High-level programming language Lecture: Programming Paradigm CIS: Edward Blruock "High-level language" refers to the higher level of abstraction from machine language. Abstraction penalty: Execution modes • Interpreted • Compiled • Machine code generation: assembly language • Intermediate code: byte code • Source to Source: trans-compiled https://en.wikipedia.org/wiki/High-level_programming_language
  • 8. AbstractionPenalty Lecture: Programming Paradigm CIS: Edward Blruock While high-level languages are intended to make complex programming simpler, low-level languages often produce more efficient code. Abstraction penalty is the border that prevents high-level programming techniques from being applied in situations where computational resources are limited. High-level programming exhibits features like more generic data structures, run-time interpretation, and intermediate code files; which often result in slower execution speed, higher memory consumption, and larger binary program size
  • 9. Abstraction Lecture: Programming Paradigm CIS: Edward Blruock Abstraction can apply to control or to data: Control abstraction is the abstraction of actions while Data abstraction is that of data structures. Control abstraction involves the use of subprograms and related concepts control flows Data abstraction allows handling data bits in meaningful ways. For example, it is the basic motivation behind datatype. One can view the notion of an object as a way to combine abstractions of data and code. The same abstract definition can be used as a common interface for a family of objects with different implementations and behaviors but which share the same meaning. The inheritance mechanism in object-oriented programming can be used to define an abstract class as the common interface.
  • 10. History Lecture: Programming Paradigm CIS: Edward Blruock http://www.paulgraham.com/fix.html What languages fix A view of the development of languages: The NEXT language fixes short-comings of the PREVIOUS language
  • 11. Power of a Language Lecture: Programming Paradigm CIS: Edward Blruock All languages are equally powerful in the sense of being Turing equivalent, but that's not the sense of the word programmers care about. (No one wants to program a Turing machine.) The kind of power programmers care about may not be formally definable, but one way to explain it would be to say that it refers to features you could only get in the less powerful language by writing an interpreter for the more powerful language in it. If language A has an operator for removing spaces from strings and language B doesn't, that probably doesn't make A more powerful, because you can probably write a subroutine to do it in B. But if A supports, say, recursion, and B doesn't, that's not likely to be something you can fix by writing library functions. Paul Graham: http://www.paulgraham.com/avg.html
  • 12. Blub Paradox Lecture: Programming Paradigm CIS: Edward Blruock Programmers get very attached to their favorite languages, and I don't want to hurt anyone's feelings, so to explain this point I'm going to use a hypothetical language called Blub. Blub falls right in the middle of the abstractness continuum. It is not the most powerful language, but it is more powerful than Cobol or machine language. Paul Graham: http://www.paulgraham.com/avg.html
  • 13. The Blub Paradox Lecture: Programming Paradigm CIS: Edward Blruock As long as our hypothetical Blub programmer is looking down the power continuum, he knows he's looking down. Languages less powerful than Blub are obviously less powerful, because they're missing some feature he's used to. But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well. Blub is good enough for him, because he thinks in Blub. Paul Graham: http://www.paulgraham.com/avg.html
  • 14. Blub Paradox Lecture: Programming Paradigm CIS: Edward Blruock You can't trust the opinions of the others, because of the Blub paradox: they're satisfied with whatever language they happen to use, because it dictates the way they think about programs. I know this from my own experience, as a high school kid writing programs in Basic. That language didn't even support recursion. It's hard to imagine writing programs without using recursion, but I didn't miss it at the time. I thought in Basic. And I was a whiz at it. Master of all I surveyed. Paul Graham: http://www.paulgraham.com/avg.html
  • 15. A reason to take this course Lecture: Programming Paradigm CIS: Edward Blruock Learn at least one new [programming] language every year. Different languages solve the same problems in different ways. By learning several different approaches, you can help broaden your thinking and avoid getting stuck in a rut. The Pragmatic Programmer: From Journeyman to Master Andrew Hunt http://www.amazon.com/The-Pragmatic-Programmer-Journeyman-Master/dp/020161622X
  • 16. © O. Nierstrasz PS — Denotational Semantics 8.16 Defining Programming Languages There are three main characteristics of programming languages: 1. Syntax: What is the appearance and structure of its programs? 2. Semantics: What is the meaning of programs? The static semantics tells us which (syntactically valid) programs are semantically valid (i.e., which are type correct) and the dynamic semantics tells us how to interpret the meaning of valid programs. 3. Pragmatics: What is the usability of the language? How easy is it to implement? What kinds of applications does it suit?
  • 17. Programming Languages © O. Nierstrasz PS — Denotational Semantics 8.17 1. Syntactic Abstraction Mechanism: to reduce repetitive "boilerplate" code that cannot be abstracted from using another language's built-in abstraction mechanisms. 2. Thought shaper: to induce a paradigm shift in how one should structure software (changing the "path of least resistance"). 3. Simplifier: to boil down an existing paradigm to just its essential parts, often to increase understanding and insight. 4. Law Enforcer: to enforce important properties or invariants, possibly to make it easier to infer more useful properties from programs. Tom Van Cutsam: http://soft.vub.ac.be/~tvcutsem/whypls.html
  • 18. syntactic abstraction mechanism Lecture: Programming Paradigm CIS: Edward Blruock Purpose: Lightweight syntax that lets programmers do the same things as before, but with less code Example: C provides multiple looping constructs, multiple conditional constructs, multiple constructs for incrementing/updating the value of a variable. loop through the elements of arrays increment or decrement the values of variables perform multiway conditionals based on numeric or character values. Programming language designers provide special purpose syntactic constructs that handle the most common patterns.
  • 19. The opposite: no syntactic abstraction Lecture: Programming Paradigm CIS: Edward Blruock Language: Chicken http://torso.me/chicken https://isotropic.org/papers/chicken.pdf https://www.youtube.com/watch?v=yL_-1d9OSdk
  • 20. Language: Chickens Lecture: Programming Paradigm CIS: Edward Blruock 1. A chicken program consists of the tokens "chicken", " " and "n”. 2. Every line has a number of chickens separated by spaces. 3. The number of chickens corresponds to an opcode. 4. Trailing newlines are significant, as an empty line will produce a "0" opcode. 5. Instructions are loaded onto the stack and executed there directly, which allows for injecting arbitrary code and executing it through a jump. 6. Self-modifying code is also possible because the program stack is not bounded. 7. The user is able to supply an input value before executing the program. This input is stored in one of the two registers. The operations: http://esolangs.org/wiki/Chicken
  • 21. thought shaper Lecture: Programming Paradigm CIS: Edward Blruock The goal of a thought shaper language is to change the way a programmer thinks about structuring his or her program. The basic building blocks provided by a programming language, as well as the ways in which they can (or cannot) be combined, will tend to lead programmers down a "path of least resistance", for some unit of resistance. For example, an imperative programming style is definitely the path of least resistance in C. It's possible to write functional C programs, but as C does not make it the path of least resistance, most C programs will not be functional.
  • 22. Thought Shaper Lecture: Programming Paradigm CIS: Edward Blruock Experienced programmers carry quite a number of patterns around in their heads. They may have learned these patterns from books or by hard won experience. The patterns enable a fluid style of programming where attention can be maintained on the unknown parts of the task at hand and work feels productive. Programmers tend to like programming languages that have good support for the patterns they use. Programmers don't like languages that disallow or inconvenience the patterns they use. They are also rarely impressed by language features that support patterns they don't know or use. http://c2.com/cgi/wiki?BlubParadox
  • 23. Thought Shaper Lecture: Programming Paradigm CIS: Edward Blruock (pure) Functional Programming Functional programming languages, by the way, are a good example of thought shaper languages. By taking away assignment from the programmer's basic toolbox, the language really forces programmers coming from an imperative language to change their coding habits.
  • 24. Thought Shaper Lecture: Programming Paradigm CIS: Edward Blruock linguistic relativity holds that cognitive processes, such as thought and experience, may be influenced by the categories and patterns of the language a person speaks. From the field of linquistics https://en.wikipedia.org/wiki/Linguistic_relativity the structure of a language affects the ways in which its respective speakers conceptualize their world, i.e. their world view, or otherwise influences their cognitive processes.
  • 25. a simplifier Lecture: Programming Paradigm CIS: Edward Blruock A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away. In software, the most beautiful code, the most beautiful functions, and the most beautiful programs are sometimes not there at all. Bentley, Jon, The most beautiful code I never wrote, Beautiful Code, O'Reilly Media, Inc.,2007
  • 26. law enforcer Lecture: Programming Paradigm CIS: Edward Blruock http://www.cs.cornell.edu/courses/cs1130/2012sp/1130selfpaced/module1/module1part4/strongtyping.html One property that is sometimes looked for in a programming language is safety Safety: Any attempt to misinterpret data is caught at compile time or generates a well-specified error at runtime. definition used in the year 2000 by an ad hoc committee that recommended that the Advanced Placement (AP) test in programming be based on the programming language Java
  • 27. Strong Typing Lecture: Programming Paradigm CIS: Edward Blruock Some errors arise from lack of understanding; others are logical errors caused by inadequate thinking and design; and some are simply typos. In all cases, finding errors early, at compile time, can save immense amounts of time. Safety and strong typing make possible the early detection of many errors. A strongly typed language has one simple feature: knowledge of a value’s type at runtime.
  • 28. Strong vs. Weak Typing Lecture: Programming Paradigm CIS: Edward Blruock String foo = "Hello, world!"; Object obj = foo; String bar = (String) obj; Date baz = (Date) obj; The above example will run perfectly fine until the last line, which will raise a ClassCastException. This is because Java is indeed strongly typed. Even though the obj variable is of the type Object, its value is still a String. Casting it to a String works fine, but trying to cast it to a Date fails. char* foo = "Hello, world!"; int x = foo * 10; printf("%in", x); The above block is valid C code, but the output is not well-defined. …. This is because C does not store anything in memory other than the raw values—it would be impossible at runtime to know that foo was a char* and x was an int. Strong Weak
  • 29. Program Verification: Bugs Lecture: Programming Paradigm CIS: Edward Blruock Here are some famous ones: ESA Ariane 5 Flight 501 self-destruction 40 seconds after takeoff (June 4, 1996). A conversion from 64-bit floating point to 16 bit integer with a value larger than possible with Arian 4. The overflow caused a hardware trap The Pentium bug Incorrect floating-point division. Cost Intel ~ $400,000,000 The 2003 North America blackout was triggered by a local outage that went undetetected. A race condition in General Electric’s monitoring software prevented an alarm
  • 30. Program Verification: Testing Lecture: Programming Paradigm CIS: Edward Blruock When you look at a big commercial software company like Microsoft, there's actually as much testing that goes in as development. We have as many testers as we have developers. Testers basically test all the time, and developers basically are involved in the testing process about half the time… Bill Gates: The test cases are unbelievably expensive; in fact, there's more lines of code in the test harness than there is in the program itself. Often that's a ratio of about three to one
  • 31. Program Verification Lecture: Programming Paradigm CIS: Edward Blruock Formal = based on rigorous mathematical logic concepts. Once we formally specify what we expect from the program, we can try to prove that the program satisfies the specification.
  • 32. Styles of formal semantics Lecture: Programming Paradigm CIS: Edward Blruock Operational. Meanings for program phrases defined in terms of the steps of computation they can take during program execution. Axiomatic. Meanings for program phrases defined indirectly via the axioms and rules of some logic of program properties. Denotational. Concerned with giving mathematical models of programming languages. Meanings for program phrases defined abstractly as elements of some suitable mathematical structure.
  • 33. Denotational Semantics Example Lecture: Programming Paradigm CIS: Edward Blruock <expr> → number | ( <expr> ) | <expri>+ <expr> | <expri>− <expr> | <expri>∗ <expr> | <expr>/<expr> [[n1 + n2]] = rep(n1) + rep(n2) [[e1+e2]] = [[e1]] + [[e2]]
  • 34. Denotational Semantics Example Lecture: Programming Paradigm CIS: Edward Blruock
  • 35. Operational Semantics Lecture: Programming Paradigm CIS: Edward Blruock A category of formal programming language semantics in which certain desired properties of a program, such as correctness, safety or security, are verified by constructing proofs from logical statements about its execution, rather than by attaching mathematical meanings to its terms (denotational semantics). The operational semantics for a programming language describes how a valid program is interpreted as sequences of computational steps
  • 36. Operational Semantics Lecture: Programming Paradigm CIS: Edward Blruock Two categories: structural operational semantics (or small-step semantics) formally describe how the individual steps of a computation take place in a computer-based system. natural semantics (or big-step semantics) describe how the overall results of the executions are obtained.
  • 37. Operational Semantics Lecture: Programming Paradigm CIS: Edward Blruock The process: 1. Identify a virtual machine (an idealized computer) 2. Build a translator (translates source code to the machine code of an idealized computer) 3. Build a simulator for the idealized computer Operational semantics is sometimes called translational semantics, if an existing PL is used in place of the virtual machine http://courses.cs.vt.edu/~cs3304/Spring00/notes/Chapter-3b/index.htm
  • 38. Axiomatic Semantics Lecture: Programming Paradigm CIS: Edward Blruock • An assertion before a statement is called a precondition • An assertion following a statement is a postcondition Based on formal logic (first order predicate calculus) Original purpose: formal program verification Approach: Define axioms or inference rules for each statement type in the language Inference rule allows one to transform expressions to other expressions assertions state the relationships and constraints among variables that are true at a specific point in execution
  • 39. Axiomatic Semantics Lecture: Programming Paradigm CIS: Edward Blruock Logic Programming (declarative) view of program Translation to logical statements means you can construct a proof For example: Can verify the correctness of the program automatically through automatic theorem provers If the precondition on the first statement is the same as the program spec, the program is correct Program proof process: The postcondition for the whole program is the desired results Work back through the program to the first statement
  • 40. Denotational Semantics Lecture: Programming Paradigm CIS: Edward Blruock denotational semantics (initially known as mathematical semantics or Scott– Strachey semantics) is an approach of formalizing the meanings of programming languages by constructing mathematical objects (called denotations) that describe the meanings of expressions from the languages. Other approaches to providing formal semantics of programming languages include axiomatic semantics and operational semantics. https://en.wikipedia.org/wiki/Denotational_semantics With formal semantics we give programs meaning by mapping them into some abstract but precise domain of objects. Using denotational semantics, we provide meaning in terms of mathematical objects, such as integers, truth values, tuples of values, and functions. For this reason, denotational semantics was originally called mathematical semantics. http://homepage.cs.uiowa.edu/~slonnegr/plf/Book/Chapter9.pdf