The Evolution of Programming Languages - Cecs.csulb.edu

mewstennisSoftware and s/w Development

Nov 4, 2013 (4 years and 3 days ago)

107 views

Programming Languages

CECS 105

Mimi Opkins

What is a Computer Program?


A program is a series of instructions
that a computer uses to carry out a
specific tasks


A programming language is the
syntax used to write that program

Customized Digital Computer

Oj

Ij

Ik

Ok

Task j

Task k

Rig different circuit for each task

Stored Program Computing


In the 1940’s
von Neumann

showed the
existence of a Universal Machine
(
hardware
) that can be customized using
control inputs to carry out different tasks.


Software

is the encoding of the task to
control this machine.


encoding(Tj)

Ij

Oj

ENIAC (1946)

5

ENIAC program for external ballistic equations:

Programming the ENIAC

6

ENIAC Programming

7

Programming done by


rewiring the interconnections


to set up desired formulas,
etc

Problem (what’s the tedious part?)


programming = rewiring


slow, error
-
prone

Solution:


store the program in memory!


birth of
von
Neuman

paradigm

Assembly Language
(UNIVAC 1, 1950)

Idea: mnemonic (assembly) code


Then translate it to machine code by hand (no compiler
yet)


write programs with mnemonic codes (add, sub),

with symbolic labels,


then assign addresses by hand

Example of symbolic assembler

clear
-
and
-
add a

add b

store c

Translate it by hand to something like this
(understood by CPU)

B100 A200

C300

8

Assembly programming caught
on, but …

Problem: Software costs exceeded
hardware costs!


John Backus: “Speedcoding”


An interpreter for a high
-
level language


Ran 10
-
20 times slower than hand
-
written assembly


way too slow

9

Imperative Languages


Imperative programming is a
programming paradigm that describes
computation in terms of statements
that change a program state.


In much the same way that
imperative mood in natural languages
expresses commands to take action,
imperative programs define
sequences of commands for the
computer to perform.

Imperative Languages


Model of Computation


ALU + Memory + Input + Output

(von Neumann architecture)


Levels of Abstraction (“
Human Interface
”)


Machine Language


Binary Representation of the task


Assembly Language


Symbolic Representation of the task

Imperative Languages
-

FORTRAN


Stands for
FOR
mula
TRAN
slation.


Invented in the 1950’s as the first high
level programming language i.e used a
compiler.


Hello World Example:



C


FORTRAN IV WAS ONE OF THE FIRST PROGRAMMING


C


LANGUAGES TO SUPPORT SOURCE COMMENTS




WRITE (6,7)





7 FORMAT(13H HELLO, WORLD)




STOP




END

FORTRAN I (1954
-
57)

Langauge, and the first compiler


Produced code almost as good as hand
-
written


Huge impact on computer science (laid foundations for
cs164)


Modern compilers preserve its outlines


FORTRAN (the language) still in use today


By 1958, >50% of all software is in FORTRAN


Cut development time dramatically


2 weeks


㈠桲h


that’s more than 100
-
fold

13

Imperative Languages


ALGOL 60


Stands for
ALGO
rithmic
L
anguage


Defined in 1960 and was the first to introduce
features still in use today:


block structure and syntax defined by a grammar.


procedure Absmax(a) Size:(n, m) Result:(y) Subscripts:(i, k); value
n, m; array a; integer n, m, i, k; real y;


comment The absolute greatest element of the matrix a, of size n
by m is transferred to y, and the subscripts of this element to
i and k;

begin integer p, q; y := 0; i := k := 1;


for p:=1 step 1 until n do


for q:=1 step 1 until m do



if abs(a[p, q]) > y then




begin y := abs(a[p, q]); i := p; k := q




end

end Absmax


Imperative Languages
-

C


The most successful ALGOL type language.


Lexical variable scope and recursion


A static type system which prevents many
meaningless operations


Function parameters are generally passed
by value (pass
-
by
-
reference is achieved in
C by explicitly passing pointer values)


Heterogeneous aggregate data types
(struct in C) which allow related data
elements to be combined and manipulated
as a unit


A small set (around 30) of reserved
keywords


Functional Languages


Imperative programs are concerened with
programming a series of instructions that change
the
state

of program towards giving the solution.


Functional Programming is concerned with viewing
a program as a series of mathematical functions.


Based upon the maths model of
Lambda Calculus
,
developed by Turing, Church and Kleene in the
1930’s.

Functional Languages


Turing developed a model of
computation called the Turing
Machine …. TCS course.


Church developed
lambda calculus.


This is based on the notion of
parameterized expressions, which
forms the basis of Functional
Programming.


Passing arguments to methods.

Functional Programming


Introduced into programming the
notions of:


First class and higher order functions


Polymorphism


Lists


Recursion


Constructors


Garbage Collection

Mark Hennessy Dept. Computer
Science NUIM CS351

Functional Programming


Difference between FP and Imperative
programming:


IP:

“To compute the
gcd

of
a

and
b
, check to see if
a

and
b

are equal.


If so print one of them and exit. Otherwise replace the larger one


by their difference and repeat.”


FP:

“The
gcd

of
a

and
b

is defined to be
a

when
a=b
, and to be the
gcd

of


c

and
d

when
a!=b
, where
c

is the smaller of
a

and
b

and
d

is their


difference. To compute the
gcd

of a given pair of numbers, expand


and simplify this definition until it finishes.



Mark Hennessy Dept. Computer
Science NUIM CS351

Functional Languages
-

Lisp


Stands for
Lis
t
P
rocessing


Same vintage as Fortran and ALGOL.


Allows for operations on lists


Eg car(0, 2, 4, 6) = 0


Eg cdr(0, 2, 4, 6) = (2, 4, 6)


Lisp Program for factorials:


(defun factorial (n)


(if (<= n 1)


1


(* n (factorial (
-

n 1)))))


Mark Hennessy Dept. Computer
Science NUIM CS351

Functional Languages
-

ML


Stands for Meta Language


Functional Language with syntax
closer to what you are familiar with.


CaML Program for factorials.


let rec fac n =



if n <= 1



then n



else n * fac(n
-
1);;

Logic Programming


Logic programming is, in its broadest
sense, the use of mathematical logic
for computer programming


Designed to allow mathematical
axioms help prove a theorem.


Based on the idea of a Horn clause


H <
-

B
1
, B
2
,….B
n


The arrow means “if” and the
commas mean “and”

Logic Programming
-

Prolog


Name derives from the French
programmation en logique
.


Dates from the early 1970’s.


Based upon Predicate Calculus, the system
uses
backtracking
.

Example Prolog Program for Factorials:

factorial(0,1).

factorial(N,F) :
-



N>0,


N1 is N
-
1,


factorial(N1,F1),


F is N * F1.

Object Oriented Programming


Current paradigm.


We write classes such that data is
hidden, ideas are abstracted and code
is re
-
usable! In theory….


Simula
-
> Smalltalk & Ada
-
> C++
-
>
Java


Sub paradigms


Aspect Oriented Programming


Generic Programming via Templates

Scripting


Another form of programming is via
scripting.


Huge amount of scripting languages,

Awk, sed, Bash, Javascript, UnrealScript
etc

Mark Hennessy Dept. Computer
Science NUIM CS351

Scripting
-

Python


Indentation is essential!


Sample factorial function:


def fac ( num ):


if num == 1:



return 1


else :



return num * fac(num
-
1)

New Languages Will Keep Coming


Be prepared to program in new
languages

Languages undergo constant change


FORTRAN

1953


ALGOL 60

1960


C


1973


C++


1985


Java


1995

Evolution steps: 12 years per widely adopted
language


are we overdue for the next big one?

... or is the language already here?


Hint:
are we going through a major shift in
what computation programs need to express?

28

Develop your own language

Are you kidding? No. Guess who
developed:


PHP


Ruby


JavaScript


perl

29

Where will languages go from here?

The trend is towards higher
-
level
abstractions


express the algorithm concisely!


which means hiding often repeated code
fragments


new language constructs hide more of
these low
-
level details.


Also, detect more bugs when the program
is compiled


with stricter type checking


with tools that loom for bugs in eth
program or in its execution

30

A survey: how many languages
did you use?

31

TIOBE Programming Community Index


The TIOBE Programming Community
index is an indicator of the popularity
of programming languages.


The index is updated once a month.


The ratings are based on the number
of skilled engineers world
-
wide,
courses and third party vendors.


The popular search engines Google,
Bing, Yahoo!, Wikipedia, YouTube
and
Baidu

are used to calculate the
ratings.

TIOBE Programming Community Index


The index can be used to check
whether your programming skills are
still up to date or to make a strategic
decision about what programming
language should be adopted when
starting to build a new software
system.

February Headline: C# and Python are
closing the gap on PHP


The rise of C# and Python are
continuing in 2011. Both languages
scored another old
-
time high this
month and are now busy with
overtaking PHP.


Long Term Trends


Categories of Programming Languages

Java


Java is a general
-
purpose,
concurrent, class
-
based, object
-
oriented language that is specifically
designed to have as few
implementation dependencies as
possible.


It is intended to let application
developers "write once, run
anywhere".


Java is
widely used from application
software to web applications.

C++


C++ is one of the most popular
programming languages ever created
[

and its application domains include
systems software, application
software, device drivers, embedded
software, high
-
performance server
and client applications, and
entertainment software such as video
games.

C++


C++ is also used for hardware
design, where design is initially
described in C++, then analyzed,
architecturally constrained, and
scheduled to create a register transfer
level hardware description language
via high
-
level synthesis.

PHP


Hypertext Preprocessor

(originally
personal home page
) is a general
-
purpose scripting language that was
originally designed for web development
to produce dynamic web pages.


For this purpose, PHP code is embedded
into the HTML source document and
interpreted by a web server with a PHP
processor module, which generates the
web page document.

Visual Basic


Third
-
generation event
-
driven
programming language and integrated
development environment from Microsoft
for its COM programming model.


Relatively easy to learn and use.


Enables the rapid application
development (RAD) of graphical user
interface (GUI) applications, access to
databases


A programmer can put together an
application using the components
provided with Visual Basic itself



JavaScript


Primarily used on the client
-
side,
implemented as part of a web
browser in order to provide enhanced
user interfaces and dynamic websites.
This enables programmatic access to
computational objects within a host
environment.


It can be characterized as an object
-
oriented scripting language


It is also considered a functional
programming language

JavaScript


JavaScript's use in applications
outside web pages

for example in
PDF
-
documents, site
-
specific
browsers and desktop widgets

is
also significant.


Uses syntax influenced by that of C.
JavaScript copies many names and
naming conventions from Java, but
the two languages are otherwise
unrelated and have very different
semantics


C


General
-
purpose computer
programming language developed
between 1969 and 1973 by Dennis
Ritchie at the Bell Telephone
Laboratories for use with the Unix
operating system


Although C was designed for
implementing system software, it is
also widely used for developing
portable application software.

C


C is one of the most popular
programming languages of all
time
[
and there are very few computer
architectures for which a C compiler
does not exist.


C has greatly influenced many other
popular programming languages,
most notably C++, which began as
an extension to C.


Python


General
-
purpose high
-
level
programming language whose design
philosophy emphasizes code
readability


Aims to combine "remarkable power
with very clear syntax” and its
standard library is large and
comprehensive.


Its use of indentation for block
delimiters is unique among popular
programming languages.

Python


Supports multiple programming
paradigms, primarily but not limited
to object oriented, imperative and, to
a lesser extent, functional
programming styles.


Python is often used as a scripting
language, but is also used in a wide
range of non
-
scripting contexts.


C#


A

simple, modern, general
-
purpose,
object
-
oriented programming language.


I
ntended for use in developing software
components suitable for deployment in
distributed environments.


C# is intended to be suitable for writing
applications for both hosted and
embedded systems, ranging from the
very large that use sophisticated
operating systems, down to the very
small having dedicated functions.

Objective C


An

object
-
oriented programming
language that adds messaging to the
C programming language.


Today, it is used primarily on Apple's
Mac OS X and iOS


Objective
-
C is the primary language
used for Apple's Cocoa API,

PERL


High
-
level, general
-
purpose,
interpreted, programming language.
Originally developed by Larry Wall in
1987 as a general
-
purpose Unix
scripting language to make report
processing easier


Since then, it has undergone many
changes and revisions and become
widely popular among programmers.

PERL


Perl borrows features from other
programming languages including C,
shell scripting (sh), AWK, and sed.


The language provides powerful text
processing facilities without the
arbitrary data length limits of many
contemporary Unix tools, facilitating
easy manipulation of text files.


PERL


Perl gained widespread popularity in
the late 1990s as a CGI scripting
language, in part due to its parsing
abilities.


In addition to CGI, Perl is used for
graphics programming, system
administration, network
programming, finance, bioinformatics,
and other applications.


PERL


Nicknamed "the Swiss Army chainsaw
of programming languages" due to its
flexibility and power.


It is also referred to as the "duct tape
that holds the Internet together", in
reference to its ubiquity and
perceived inelegance.