Presentation is loading. Please wait.

Presentation is loading. Please wait.

+ CS1001. Python. November 14 th, 2011. + Scripting languages Scripting languages foster an exploratory, incremental approach to writing code Historically.

Similar presentations


Presentation on theme: "+ CS1001. Python. November 14 th, 2011. + Scripting languages Scripting languages foster an exploratory, incremental approach to writing code Historically."— Presentation transcript:

1 + CS1001. Python. November 14 th, 2011

2 + Scripting languages Scripting languages foster an exploratory, incremental approach to writing code Historically interpreted Favor your time and energy over the CPUs Include libraries for common tasks Examples AWK [1977], Perl [1987], Python [1991]

3 + Style Java: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world"); } } Python: print hello world Perl: print hello world\n; AWK: BEGIN { print "Hello, world!" }

4 + Philosophy More time Thinking about the problem Experimenting with solutions Less time Writing code

5 + Perl Larry Wall, 1987 (linguist) Report writing (text processing!) There is more than one way to do it. What was text processing essential for in the early 90s?

6 + Websites per year (log scale) Source: http://www.useit.com/alertbox/web-growth.html

7 + Which is more important? Code should be easy to write Code should be easy to read (This is a false dichotomy)

8 + Obfuscated code contest `$=`;$_=\%!;($_)=/(.)/;$==++$|; ($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:, @%)=($!=~/(.)(.).(.)(.)(.)(.)..(.)(.) (.)..(.)......(.)/,$"),$=++;$.++;$.+ +; $_++;$_++;($_,$\,$,)=($~.$"."$;$ /$%[$?]$_$\$,$:$%[$?]",$"&$~,$ #,);$,++;$,++;$^|=$";`$_$\$,$/$: $;$~$*$%[$?]$.$~$*${#}$%[$?]$ ;$\$"$^$~$*.>&$=` Perl

9 + Obfuscated code contest `$=`;$_=\%!;($_)=/(.)/;$==++$|; ($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:, @%)=($!=~/(.)(.).(.)(.)(.)(.)..(.)(.) (.)..(.)......(.)/,$"),$=++;$.++;$.+ +; $_++;$_++;($_,$\,$,)=($~.$"."$;$ /$%[$?]$_$\$,$:$%[$?]",$"&$~,$ #,);$,++;$,++;$^|=$";`$_$\$,$/$: $;$~$*$%[$?]$.$~$*${#}$%[$?]$ ;$\$"$^$~$*.>&$=` $ Just another Perl hacker. Perl

10 + Obfuscated code contest C

11 + C

12 + Python Emphasizes readability There should be one – and preferably only one – way to do it. Large standard library (batteries included) Cross platform and open source

13 + Parsing text files (and reading them back!)

14 + Getting the weather http://weather.yahooapis.com/forecastrss?w=2459115

15 + Technically Dynamic typing Garbage collected Multi-paradigm Compiles to bytecode Exception based error handling Extensible

16 + Dynamic typing pi = 3.1459 print pi pi = "I'd love to have " + str(pi) + " pies" print pi print "In fact, I'd like one more" pi = pi + 1 # TypeError: cannot concatenate 'str' and 'int' objects print pi

17 + Books Ordered by technical complexity - notice anything?

18 + Internet humor Source: http://xkcd.com/534/


Download ppt "+ CS1001. Python. November 14 th, 2011. + Scripting languages Scripting languages foster an exploratory, incremental approach to writing code Historically."

Similar presentations


Ads by Google