Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE S. Tanimoto Comparing Languages

Similar presentations


Presentation on theme: "CSE S. Tanimoto Comparing Languages"— Presentation transcript:

1 CSE 341 -- S. Tanimoto Comparing Languages
Wrapup Programming Languages as systems for specifying computation Comparing Languages CSE S. Tanimoto Comparing Languages

2 CSE 341 -- S. Tanimoto Perl Introduction
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 S. Tanimoto Perl Introduction

3 CSE 341 -- S. Tanimoto Perl Introduction
Language Comparison Lisp: uniform syntax, interpreted, mostly functional. ML: functional, with strong, static typing and type inference. Java: typical syntax, compiled, mostly object-oriented. Prolog: logic programming paradigm, unification and resolution, weakly typed. Perl: permissive syntax, compiled, multi-paradigm, scripting. CSE S. Tanimoto Perl Introduction

4 CSE 341 -- S. Tanimoto Perl Introduction
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 CSE S. Tanimoto Perl Introduction

5 CSE 341 -- S. Tanimoto Perl Introduction
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 S. Tanimoto Perl Introduction

6 CSE 341 -- S. Tanimoto Perl Introduction
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 S. Tanimoto Perl Introduction

7 CSE 341 -- S. Tanimoto Perl Introduction
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 S. Tanimoto Perl Introduction

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

9 CSE 341 -- S. Tanimoto Perl Introduction
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 S. Tanimoto Perl Introduction

10 CSE 341 -- S. Tanimoto Perl Introduction
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 S. Tanimoto Perl Introduction

11 CSE 341 -- S. Tanimoto Perl Introduction
Final Exam 40 questions from quizzes 1 and 2, slightly changed. 10 questions on Perl and regular expressions. All multiple choice. CSE S. Tanimoto Perl Introduction


Download ppt "CSE S. Tanimoto Comparing Languages"

Similar presentations


Ads by Google