Presentation is loading. Please wait.

Presentation is loading. Please wait.

First appearedFeaturesMain paradigmsPopular uses COMPUTING Basic FOR A=1 TO 100 IF A MOD 15 = 0 THEN PRINT “FizzBuzz” ELSE IF A MOD 3 = 0 THEN PRINT “Fizz”

Similar presentations


Presentation on theme: "First appearedFeaturesMain paradigmsPopular uses COMPUTING Basic FOR A=1 TO 100 IF A MOD 15 = 0 THEN PRINT “FizzBuzz” ELSE IF A MOD 3 = 0 THEN PRINT “Fizz”"— Presentation transcript:

1 First appearedFeaturesMain paradigmsPopular uses COMPUTING Basic FOR A=1 TO 100 IF A MOD 15 = 0 THEN PRINT “FizzBuzz” ELSE IF A MOD 3 = 0 THEN PRINT “Fizz” ELSE IF A MOD 5 = 0 THEN PRINT “Buzz” ELSE PRINT A END IF NEXT A 1964 Simplicity, hundreds of dialects and implementations Computer Science education, scripting, games Imperative, procedural

2 First appearedFeaturesMain paradigmsPopular uses COMPUTING C #include int main (int argc, char** argv) { int i; for (i = 1; i <= 100; i++) { if (!(i % 15)) printf("FizzBuzz\n"); else if (!(i % 3)) printf("Fizz\n"); else if (!(i % 5)) printf("Buzz\n"); else printf("%d\n", i); } return 0; } 1972 Low level, manual memory management Operating systems, compilers, interpreters, embedded systems, games Imperative, statically typed

3 First appearedFeaturesMain paradigmsPopular uses COMPUTING Scheme (define (fizzbuzz x y) (println (cond (( = (modulo x 15) 0 ) "FizzBuzz") (( = (modulo x 3) 0 ) "Fizz") (( = (modulo x 5) 0 ) "Buzz") (else x))) (if (< x y) (fizzbuzz (+ x 1) y))) (fizzbuzz 1 100) 1975 Tail-recursion, homoiconicity, minimalism, lexical scoping Computer Science education, scripting, academic research Functional, dynamically-typed http://www.schemers.org

4 First appearedFeaturesMain paradigmsPopular uses COMPUTING Python for i in range(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print( i ) 1991 Usually interpreted, duck typing, reflection, meaningful indentation Computer Science education, scripting, RAD, web-based programming, games Imperative, object- oriented, dynamically-typed, some functional aspects http://www.python.org

5 First appearedFeaturesMain paradigmsPopular uses COMPUTING Java public class FizzBuzz { public static void main (String[] args) { for (int i = 1; i <= 100; i++) { if (i % 15 == 0) { System.out.println("FizzBuzz"); } else if (i % 3 == 0) { System.out.println("Fizz"); } else if (i % 5 == 0) { System.out.println("Buzz"); } else { System.out.println(i); } 1995 Security management, garbage collection, reflection, generics Applications, mobile devices, programming tools, games Imperative, object- oriented, statically typed http://www.java.com

6 First appearedFeaturesMain paradigmsPopular uses COMPUTING Ruby 1.upto(100) do |n| print "Fizz" if a = (n % 3).zero? print "Buzz" if b = (n % 5).zero? print n unless (a || b) print "\n" end 1995 Usually interpreted, duck typing, reflection Web-based programming, RAD, scripting Imperative, object- oriented, dynamically-typed, some functional aspects http://www.ruby-lang.org

7 First appearedFeaturesMain paradigmsPopular uses COMPUTING C# using System; namespace FizzBuzz { class Program { static void Main(string[] args) { for (int i = 1; i <= 100; i++) { string output = ""; if (i % 3 == 0) output += "Fizz"; if (i % 5 == 0) output += "Buzz"; if (String.IsNullOrEmpty(output)) output = i.ToString(); Console.WriteLine(output); } 2001 Type safety, garbage collection, reflection, generics,.NET interoperability Business applications, games Imperative, object- oriented, statically- typed

8 First appearedFeaturesMain paradigmsPopular uses COMPUTING Scratch 2007 Online collaboration, integrated content creation Computer Science education Imperative, visual http://scratch.mit.edu/

9 First appearedFeaturesMain paradigmsPopular uses COMPUTING PHP <?php for(a = 1; a <= 100; a++) { if(a % 15 == 0) echo “FizzBuzz”; elsif(a % 3 == 0) echo “Fizz”; elsif(a % 5 == 0) echo “Buzz”; } ?> 1995 Web server integration, some object-oriented and functional features Web-based programming, scripting Imperative, procedural, dynamically-typed, weakly-typed http://www.php.net

10 First appearedFeaturesMain paradigmsPopular uses COMPUTING JavaScript for (a=1; a<=100; a++) if(a%15 ===0){ console.log("FizzBuzz"); } else if ( a % 3 === 0 ) { console.log("Fizz"); } else if (a % 5 === 0 ) { console.log("Buzz"); } else { console.log(a); } 1995 Prototype-based inheritance, manipulation of document object model Client-side web- based programming, desktop widgets, games Imperative, object- oriented, dynamically-typed, weakly-typed, some functional aspects

11 First appearedFeaturesMain paradigmsPopular uses COMPUTING Visual Basic.NET For a = 1 To 100 If a Mod 15 = 0 Then Console.WriteLine("FizzBuzz") ElseIf a Mod 5 = 0 Then Console.WriteLine("Buzz") ElseIf a Mod 3 = 0 Then Console.WriteLine("Fizz") Else Console.WriteLine(a) End If Next 2001 Garbage collection, reflection, event handling,.NET interoperability Business applications, RAD, games Imperative, object- oriented, statically- typed

12 First appearedFeaturesMain paradigmsPopular uses COMPUTING Pascal program fizzbuzz(output); var a: integer; begin for a := 1 to 100 do if a mod 15 = 0 then writeln('FizzBuzz') else if a mod 3 = 0 then writeln('Fizz') else if a mod 5 = 0 then writeln('Buzz') else writeln(a) end. 1968 Simplicity, type safety, enforces good style EducationImperative, procedural, structured

13 First appearedFeaturesMain paradigmsPopular uses COMPUTING COBOL IDENTIFICATION DIVISION. PROGRAM-ID. fizzbuzz. DATA DIVISION. WORKING-STORAGE SECTION 01 CNT PIC 9(03) VALUE 1. 01 REM PIC 9(03) VALUE 0. 01 QUOTIENT PIC 9(03) VALUE 0. PROCEDURE DIVISION. *PERFORM UNTIL CNT > 100 DIVIDE 15 INTO CNT GIVING QUOTIENT REMAINDER REM IF REM = 0 THEN DISPLAY "FizzBuzz " WITH NO ADVANCING ELSE DIVIDE 3 INTO CNT GIVING QUOTIENT REMAINDER REM IF REM = 0 THEN DISPLAY "Fizz " WITH NO ADVANCING ELSE DIVIDE 5 INTO CNT GIVING QUOTIENT REMAINDER REM IF REM = 0 THEN DISPLAY "Buzz " WITH NO ADVANCING ELSE DISPLAY CNT " " WITH NO ADVANCING END-IF ADD 1 TO CNT END-PERFORM DISPLAY "“ STOP RUN. 1959 Intended to look like natural language, many different implementations Business processes, mainframe programming Imperative, procedural, statically-typed, weakly-typed

14 First appearedFeaturesMain paradigmsPopular uses COMPUTING Perl foreach (1.. 100) { if (0 == $_ % 15) { print "FizzBuzz\n"; } elsif (0 == $_ % 3) { print "Fizz\n"; } elsif (0 == $_ % 5) { print "Buzz\n"; } else { print "$_\n"; }; }; 1987 Language support for text processing, such as string interpolation and regular expressions Text processing, scripting, image generation, web- based programming Imperative, procedural, dynamically-typed, some functional and OO features http://www.perl.org

15 First appearedFeaturesMain paradigmsPopular uses COMPUTING ALGOL 68 main:( FOR a TO 100 DO printf(($gl$, IF a %* 15 = 0 THEN "FizzBuzz" ELIF a %* 3 = 0 THEN "Fizz" ELIF a %* 5 = 0 THEN "Buzz" ELSE a FI )) OD ) 1968 One of the earliest languages to have a formal specification Computer Science research and publications, mainframe programming Imperative, procedural, structured, statically-typed

16 First appearedFeaturesMain paradigmsPopular uses COMPUTING Prolog fizzbuzz(X) :- 0 is X mod 15, write('FizzBuzz'). fizzbuzz(X) :- 0 is X mod 3, write('Fizz'). fizzbuzz(X) :- 0 is X mod 5, write('Buzz'). fizzbuzz(X) :- write(X). dofizzbuzz :- foreach(between(1, 100, X), (fizzbuzz(X),nl)).ismodwriteismodwriteismodwrite nl 1972 Rule-based resolution, tail- recursion, reflection, homoiconicity Expert systems, artificial intelligence, computational linguistics, query systems Declarative, logic programming

17 First appearedFeaturesMain paradigmsPopular uses COMPUTING Haskell main = mapM_ (putStrLn. fizzbuzz) [1..100] fizzbuzz x | x `mod` 15 == 0 = "FizzBuzz" | x `mod` 3 == 0 = "Fizz" | x `mod` 5 == 0 = "Buzz" | otherwise = show x 1990 Monads, type inference, pattern matching Computer Science research, concurrent programming, software verification Functional, statically-typed, lazy evaluation https://www.haskell.org/

18 First appearedFeaturesMain paradigmsPopular uses COMPUTING C++ 1983 Manual memory management, templates, extensive standard library Systems programming, high- performance business applications, games Imperative, object- oriented, statically- typed https://isocpp.org/ #include #include #include int main() { std::vector range(100); std::iota(range.begin(), range.end(), 1); std::vector values; values.resize(range.size()); auto fizzbuzz = [](int i) -> std::string { if ((i%15) == 0) return "FizzBuzz"; if ((i%5) == 0) return "Buzz"; if ((i%3) == 0) return "Fizz"; return std::to_string(i); }; std::transform(range.begin(), range.end(), values.begin(), fizzbuzz); for (auto& str: values) std::cout << str << std::endl; return 0; }

19 First appearedFeaturesMain paradigmsPopular uses COMPUTING Assembly 1949 Direct control over the machine code produced Device drivers, extreme optimization, processor-specific features, new hardware Imperative, generally untyped and unchecked Assembly languages vary depending on processor - this is for the 8086 mov dx,03030h mov ah,0Eh mov bl,100d xor cx,cx xor bh,bh writeloop: inc dl cmp dl,3Ah jnz writeloop1 mov dl,30h inc dh writeloop1: inc bh cmp bh,03h jz writefizz cmp dl,30h jz writebuzz cmp dl,35h jz writebuzz mov al,dh int 10h mov al,dl int 10h writespace: mov al,020h int 10h dec bl jnz writeloop programend: cli hlt jmp programend writefizz: mov si,offset fizz call write xor bh,bh cmp dl,30h jz writebuzz cmp dl,35h jnz writespace writebuzz: mov si,offset buzz call write jmp writespace write: mov cl,04h write1: mov al,[si] inc si int 10h loop write1 ret fizz: db "fizz" buzz: db "buzz"


Download ppt "First appearedFeaturesMain paradigmsPopular uses COMPUTING Basic FOR A=1 TO 100 IF A MOD 15 = 0 THEN PRINT “FizzBuzz” ELSE IF A MOD 3 = 0 THEN PRINT “Fizz”"

Similar presentations


Ads by Google