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

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
Image of page 23
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
Image of page 24
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
Image of page 25
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.
Image of page 26
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
Image of page 27
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) );
Image of page 28
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
Image of page 29
Image of page 30

You've reached the end of your free preview.

Want to read all 30 pages?

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors