Docsity

Historical Development of Algebra and Declarative Programming Languages, Study notes of Computer Science

Partial preview of the text

Download Historical Development of Algebra and Declarative Programming Languages and more Study notes Computer Science in PDF only on Docsity!

DECLARATIVE

PROGRAMMING LANGUAGES

Jim Royer

EECS Department

A HISTORICAL DIGRESSION

I Algebra is largely an Arabic in- vention.

  • Muhammed ibn-Musa al- Khwarizmi – 9th^ century AD
  • “completing the square”
  • “solving quadratic equations” (ax^2 + bx + c)

CARDANO’S RHETORICAL ALGEBRA (CIRCA 1550)

Solve: Let a cube and six times its side equal 20. x^3 + 6x = 20

A Solution: Cube one third the number of sides (i.e., the coef. of x). Add to it the square of one- half the constant of the equation and take the square root of the whole. You will put this twice, and to the one of the two you add one-half the number you have squared and from the other you subtract one haft the same. √ You will then have a binomium (i.e., 108+10) and its apotome (i.e.,

√ 108 − 10 ). Then, subtracting the cube root of the apo- tome from the cube root of the binomium the remainder is the required side.

x = 3

√√ 108 + 10 − 3

√√ 108 − 10

THE MODERN NOTATION

I Fran¸cois Vi`ete 1540 – 1603

  • French lawyer, royal counselor, math- ematician, and cryptographer
  • 1592: “In Artem Analyticem Isagoge”

PROGRAMMING: IMPERATIVE VS. DECLARATIVE

Ordinarily technology changes fast. But programming languages are different: programming languages are not just technology, but what programmers think in. They’re half technology and half religion. — Paul Graham, “Beating the Averages”

Imperative programming languages

I E.g, C, C++,...

I spell out computations

I tricky to manipulate

Declarative programming languages

I E.g., Lisp, Scheme, ML, Haskell, Python,...

I spell out relations (ideally)

I easy to manipulate

I more abstract

DECLARATIVE LANGUAGES: PROS AND CONS

Cons

I Weak programmers do not fare well.

I There is sometimes a price in performance, but not always.

I Some things can be tricky to express, e.g., “: =” in Haskell.

Pros

I Creative programmers fare well.

I Some things are easy to express that are unheard of

in the imperative setting, e.g., Lisp macros.

I Programs can be very close to specifications.

I There is a long, successful track record in prototyping.

E.g., Perl 6 is being developed in Haskell.

SOME PLACES TO FIND OUT MORE

I P. Graham’s essays, especially “Beating the Averages” http://www.paulgraham.com/articles.html

I Wikipedia’s Haskell entry: http://en.wikipedia.org/wiki/Haskell (programming language) Under external links see especially:

  • “Wearing the hair shirt: A retrospective on Haskell” by S.P. Jones
  • “Haskell vs. Ada vs. C++ vs. Awk vs. ... An Experiment in Software Prototyping Productivity” by P. Hudak and M. Jones

I H. Abelson and G. Sussman’s “Structure and Interpretation of Computer Programs, 2/e”, MIT Press, 1996.

I L. Paulson’s “ML for the Working Programmer”, Cambridge Univ. Press, 1996.

AN EXAMPLE

-- The list of all primes via the Sieve of Eratosthenes -- A bit slow, but cute!

primes = sieve [2 ..] where sieve (x:xs) = x : sieve [ y | y <-xs, y ‘mod‘ x > 0]

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,