Cool Code

47
Cool Code @KevlinHenney

description

Presented at GeeCON (18th May 2012) Video available on Vimeo: https://vimeo.com/44792649 In most disciplines built on skill and knowledge, from art to architecture, from creative writing to structural engineering, there is a strong emphasis on studying existing work. Exemplary pieces from past and present are examined and discussed in order to provoke thinking and learn techniques for the present and the future. Although programming is a discipline with a very large canon of existing work to draw from, the only code most programmers read is the code they maintain. They rarely look outside the code directly affecting their work. This talk examines some examples of code that are interesting because of historical significance, profound concepts, impressive technique, exemplary style or just sheer geekiness.

Transcript of Cool Code

Page 1: Cool Code

Cool Code

@KevlinHenney

Page 2: Cool Code
Page 3: Cool Code
Page 4: Cool Code

There is an art, craft, and science to

programming that extends far beyond

the program. The act of programming

marries the discrete world of computers

with the fluid world of human affairs.

Programmers mediate between the

negotiated and uncertain truths of

business and the crisp, uncompromising

domain of bits and bytes and higher

constructed types.

Page 5: Cool Code
Page 6: Cool Code
Page 7: Cool Code
Page 8: Cool Code
Page 9: Cool Code
Page 10: Cool Code
Page 11: Cool Code
Page 12: Cool Code

RUD, noun Rapid Unscheduled Disassembly

Rocket science and amateur rocketry jargon that's acronymous,

euphemistic and explosively self-explanatory

WordFriday

Page 13: Cool Code

cool, adjective fashionably attractive or impressive

excellent

used to express acceptance or agreement

used as an intensive

used when a conversation goes silent

marked by deliberate effrontery or lack of due respect or discretion

restrained or relaxed in style

code, noun a system of words, figures or symbols used to represent others

a set of instructions for a computer

a computer program, or a portion thereof

a set of conventions or principles governing behaviour or activity

in a particular domain

a system or collection of rules or regulations on any subject

a collection of writings

Oxford English Dictionary ∙ Concise Oxford English Dictionary ∙ Merriam-Webster's Collegiate Dictionary ∙ Urban Dictionary

Page 14: Cool Code

http://www.kuro5hin.org/story/2001/8/10/12620/2164

Page 15: Cool Code

http://lambda-the-ultimate.org/node/3522

Page 16: Cool Code
Page 17: Cool Code
Page 18: Cool Code

http://www.computerworld.com.au/article/216844/a-z_programming_languages_awk/

Page 19: Cool Code
Page 20: Cool Code
Page 21: Cool Code

#!/usr/bin/perl # -------------------------------------------------------- PerlInterpreter # PerlInterpreter must be the first line of the file. # # Copyright (c) 1995, Cunningham & Cunningham, Inc. # # This program has been generated by the HyperPerl # generator. The source hypertext can be found # at http://c2.com/cgi/wikibase. This program belongs # to Cunningham & Cunningham, Inc., is to be used # only by agreement with the owner, and then only # with the understanding that the owner cannot be # responsible for any behaviour of the program or # any damages that it may cause. # -------------------------------------------------------- InitialComments

# InitialComments print "Content-type: text/html\n\n"; $DBM = "/usr/ward/$ScriptName"; dbmopen(%db, $DBM , 0666) || &AbortScript("can't open $DBM"); $CookedInput{browse} && &HandleBrowse; $CookedInput{edit} && &HandleEdit; $CookedInput{copy} && &HandleEdit; $CookedInput{links} && &HandleLinks; $CookedInput{search} && &HandleSearch; dbmclose (%db); if ($ENV{REQUEST_METHOD} eq POST) { $CookedInput{post} && &HandlePost; } # &DumpBinding(*CookedInput); # &DumpBinding(*old); # &DumpBinding(*ENV); # -------------------------------------------------------- WikiInHyperPerl

Page 22: Cool Code
Page 23: Cool Code

http://www.adampetersen.se/articles/fizzbuzz.htm

Page 24: Cool Code

http://www.adampetersen.se/articles/fizzbuzz.htm

Page 25: Cool Code
Page 26: Cool Code
Page 27: Cool Code
Page 28: Cool Code
Page 29: Cool Code
Page 30: Cool Code
Page 31: Cool Code
Page 32: Cool Code
Page 33: Cool Code

/^1?$|^(11+?)\1+$/

Page 34: Cool Code

:;while [ $? -eq 0 ];do nc -vlp 8080 -c'(r=read;e=echo;$r a b c;z=$r;while [ ${#z} -gt 2 ];do $r z;done;f=`$e $b|sed 's/[^a-z0-9_.-]//gi'`;h="HTTP/1.0";o="$h 200 OK\r\n";c="Content";if [ -z $f ];then($e $o;ls|(while $r n;do if [ -f "$n" ]; then $e "<a href=\"/$n\">`ls -gh $n`</a><br>";fi;done););elif [ -f $f ];then $e "$o$c-Type: `file -ib $f`\n$c-Length: `stat -c%s $f`";$e;cat $f;else $e -e "$h 404 Not Found\n\n404\n";fi)';done

Page 35: Cool Code
Page 36: Cool Code

There have always been fairly severe

size constraints on the Unix operating

system and its software. Given the

partially antagonistic desires for

reasonable efficiency and expressive

power, the size constraint has

encouraged not only economy but a

certain elegance of design.

Dennis Ritchie and Ken Thompson "The UNIX Time-Sharing System", CACM

Page 37: Cool Code
Page 38: Cool Code
Page 39: Cool Code
Page 40: Cool Code
Page 41: Cool Code

Any application that can be

written in JavaScript, will

eventually be written in

JavaScript.

Atwood's Law

Page 42: Cool Code
Page 43: Cool Code
Page 44: Cool Code

If you don’t have time to read, you don’t have the time or the tools to write.

Stephen King

Page 45: Cool Code

geecon

Page 46: Cool Code

geecon

Page 47: Cool Code

geecoff