1 / 11

Wrapup

Wrapup. Programming Languages as systems for specifying computation Comparing Lisp, Java and Perl The future. Programming. 1. Specify computation 2. Using a finite-length expression, specify arbitrarily long computations using looping or recursion.

lucian
Download Presentation

Wrapup

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Wrapup Programming Languages as systems for specifying computation Comparing Lisp, Java and Perl The future CSE 341, S. Tanimoto Wrapup -

  2. Programming 1. Specify computation 2. Using a finite-length expression, specify arbitrarily long computations using looping or recursion. 3. Key criterion is that the program description be effective, so that a computer really can interpret/compile and execute it. CSE 341, S. Tanimoto Wrapup -

  3. Language Comparison Lisp: uniform syntax, interpreted, mostly functional. Java: typical syntax, compiled, mostly object-oriented. Perl: permissive syntax, compiled, multi-paradigm, scripting. CSE 341, S. Tanimoto Wrapup -

  4. 99 Bottles of Beer The next step up from “Hello World” Print the words to the song, “99 Bottles of Beer on the Wall.” For solutions in over 200 languages, see http://www.ionet.net/~timtroyr/funhouse/beer.html CSE 341, S. Tanimoto Wrapup -

  5. BASIC Beginners’ All purpose Symbolic Instruction Code 10 REM Basic version of 99 bottles of beer 20 FOR X=99 TO 1 STEP -1 30 PRINT X;"Bottle(s) of beer on the wall,";X;"bottle(s) of beer" 40 PRINT "Take one down and pass it around," 50 PRINT X-1;"bottle(s) of beer on the wall" 60 NEXT CSE 341, S. Tanimoto Wrapup -

  6. Lisp ;;; Print the words to 99 Bottles of beer. (defun b (n) (format nil "~A bottle~A of beer" n (if (= n 1) "" "s")) ) (defun bb (n) (format t "~A on the wall, ~A.~%~A ~A.~%" (b n)(b n) "Take one down and pass it around, " (b (1- n)) ) (if (> n 1) (bb (1- n))) ) (bb 99) CSE 341, S. Tanimoto Wrapup -

  7. Java public class Bottle { public static void main(String Argv[]) { for(int i=99; i>0; i--) { String b = b(i); System.out.println(b + " on the wall, " + b + ".\n" + "Take one down and pass it around, " + b(i-1) + " on the wall."); } } static String b(int n) { String s = "s"; if (n == 1) s = ""; return n + " bottle" + s + " of beer"; } } CSE 341, S. Tanimoto Wrapup -

  8. Perl # Print words to '99 Bottles of Beer' -- S. Tanimoto $w = " on the wall"; $t = "\nTake one down and pass it around, "; for (reverse(1 .. 99)) { print b($_),"$w, ",b($_),". ",$t,b($_-1),"$w.\n"; } sub b() { ($n) = @_; $p = ($n != 1) ? "s" : ""; "$n bottle$p of beer"; } CSE 341, S. Tanimoto Wrapup -

  9. Prolog bbw(1) :- write(' One bottle of beer on the wall'). bbw(N) :- write(N), bob, write(' on the wall'). bb(1) :- bbw(1), write(', one bottle of beer'), tod, write(' No'), bob, write('.'). bb(N) :- bbw(N), write(', '), write(N), bob, tod, M is N - 1, bbw(M), write('.\n'), bb(M). bob :- write(' bottles of beer'). tod :- write('. Take one down; pass it around - '). CSE 341, S. Tanimoto Wrapup -

  10. The Future Ubiquitous computing, wireless Internet, embedded systems Computers will be everywhere! Your toaster MAY be programmable. What kind of programming system will it offer? What will be the consequences of inability to program? End-user programming languages and systems will play a key role in letting ordinary people be in control of the devices in their own homes. CSE 341, S. Tanimoto Wrapup -

  11. Final Exam • Coverage includes topics from: • Lisp quiz • Java quiz + • regular expressions (theory and Perl practice), • syntax description using BNF and EBNF, • logic programming (clauses, literals, unification, Prolog’s search procedure) • orthogonality, polymorphism, language paradigms • data type -- strong vs weak typing, structural equivalence of types vs name equivalence. CSE 341, S. Tanimoto Wrapup -

More Related