1 / 15

Visualizing Code

Visualizing Code. Does the Sapir-Whorf hypothesis have relevance to programming languages and code? What is a language? Should we look at programming language grammars? What languages should we investigate? What factors (should) influence language choice? How do we measure efficiency?

bert-terry
Download Presentation

Visualizing Code

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visualizing Code • Does the Sapir-Whorf hypothesis have relevance to programming languages and code? • What is a language? • Should we look at programming language grammars? • What languages should we investigate? • What factors (should) influence language choice? • How do we measure efficiency? • What problem are we solving? • What do we know, what itch are we scratching? • How do we think about code?

  2. Why do we know about this?

  3. http://chir.ag/phernalia/preztags/ • Similarities to Minard’s graphic? • Timeline • Size matters • Shading/color matter • What state-of-the-art technologies enable this? • Done in CSS and HTML, no flash, no Javascript, no … • How does this work? • Is there something here for us to use in our courses?

  4. Tagcloud of ? http://www.tagcloud.com

  5. Tastes Great! aka Emacs v. vi [two years ago] we lamented the state of our educational discipline. There were remnants of the language wars, extensive focus on the best way - or tool - to teach language X, and ambivalence toward the state of our discipline. I think languages matter since languages determine how easy or hard it is to work with the base language constructs. To do anything, we and our students must express abstract ideas in one or more concrete languages.

  6. Fundamental parts of Tagcloud • Determining word frequencies • What is a word? • Issues in stemming? • Other issues? • Differentiate among frequencies • Smooth curve? • Step function? • Other issues? • Output • Straightforward? CSS? …

  7. Language and Social Experiment • Post to SIGCSE and Dulug • Submit code • 70 out of 565?

  8. Eight solutions in C++

  9. Twenty-one Java solutions

  10. Seventeen Python Solutions

  11. Eleven Perl Solutions

  12. What about Performance? • Kjv10.txt, time in seconds, read only, read as percentage

  13. What about understanding? • Shade in yellow the code that updates counts • C++, Java, Python, Perl • Shade in another color the code that “sorts” the data appropriately • C++, Java, Python, Perl • Where should you add this line or its equivalent? • word = removePunctutation(word); • What is the equivalente in the different languages? • Stemming (reduce to canonical form) location?

  14. Alternatives (that don’t work:-) cat $1 | tr A-Z a-z | tr '\t' ' ' | tr ' ' '\n' | grep -v '^$' | sort | uniq -c | sed -e 's/^ *//' | sort -k 1,1nr -k 2,2 | tr ' ' '\t' awk '{for (i=1; i<=NF; i++) print tolower($i)}' $1 | sort | uniq -c | sort --key=1rn,2d cat ${1} | tr A-Z a-z | tr -sc A-Za-z '\012' | sort | uniq -c | sort -r -n awk '{for (i=1; i<=NF; i++) print tolower($i)}' $1 | sort | uniq -c | LC_COLLATE=C sort --key=1rn,2 | awk '{print $1"\t"$2}' tr "[:upper:]" "[:lower:]" < $1 | tr -s "[:space:]" "[\n*]" | sort | uniq -c | sort -n -r -b -s -k 1,1 | sed 's/^ *//' | tr "[:blank:]" "[\t*]"

  15. What about fun? • Making the code work with PHP • Documentation for sorting was a headache • Finally made it work, but spent 2 hours • Not fun • Making the code work with Ruby • Documentation online was superb • Took 20 minutes to get canonical solution • Was very fun

More Related