cse 341, s. tanimoto wrapup - 1 wrapup programming languages as systems for specifying computation...
TRANSCRIPT
CSE 341, S. Tanimoto Wrapup -
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, seehttp://www.ionet.net/~timtroyr/funhouse/beer.html
CSE 341, S. Tanimoto Wrapup -
5
BASICBeginners’ All purpose Symbolic Instruction Code
10 REM Basic version of 99 bottles of beer20 FOR X=99 TO 1 STEP -130 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
Javapublic 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 FutureUbiquitous 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.