Hudak and Jones Haskell vs Ada vs C vs Awk vs Yale University Tech Report 1994

# Hudak and jones haskell vs ada vs c vs awk vs yale

• 30

This preview shows page 23 - 30 out of 30 pages.

Hudak and Jones, Haskell vs Ada vs C++ vs Awk vs …, Yale University Tech Report, 1994
Disadvantages of Functional Prog Functional programs often less efficient. Why? Change 3rd element of list x to y (cons (car x) (cons (cadr x) (cons y (cdddr x)))) Build new cells for first three elements of list (rplaca (cddr x) y) Change contents of third cell of list directly However, many optimizations are possible A B C D
Sample Optimization: Update in Place Function uses updated list (lambda (x) ( … (list-update x 3 y) (cons ‘E (cdr x)) ) Can we implement list-update as assignment to cell? May not improve efficiency if there are multiple pointers to list, but should help if there is only one. A B C D
Sample Optimization: Update in Place Initial list x A B C D List x after (list-update x 3 y) A B y D 3 C This works better for arrays than lists.
Sample Optimization: Update in Place Approximates efficiency of imperative languages Preserves functional semantics (old value persists) Update(A, 3, 5) Array A 2 3 6 7 11 13 19 17 2 3 5 7 11 13 19 17 3 6
Von Neumann bottleneck Von Neumann Mathematician responsible for idea of stored program Von Neumann Bottleneck Backus’ term for limitation in CPU-memory transfer Related to sequentiality of imperative languages Code must be executed in specific order function f(x) { if (x<y) then y = x; else x = y; } g( f(i), f(j) );
Eliminating VN Bottleneck No side effects Evaluate subexpressions independently Example function f(x) { return x<y ? 1 : 2; } g(f(i), f(j), f(k), … ); Does this work in practice? Good idea but ... Too much parallelism Little help in allocation of processors to processes ... David Shaw promised to build the non-Von ... Effective, easy concurrency is a hard problem

#### You've reached the end of your free preview.

Want to read all 30 pages?

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern