Visualizing Code - PowerPoint PPT Presentation

About This Presentation
Title:

Visualizing Code

Description:

Does the Sapir-Whorf hypothesis have relevance to programming languages and code? What is a language? Should we look at programming language grammars? – PowerPoint PPT presentation

Number of Views:84
Avg rating:3.0/5.0
Slides: 16
Provided by: Owen54
Learn more at: https://www2.cs.duke.edu
Category:

less

Transcript and Presenter's Notes

Title: Visualizing Code


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 Minards 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

Perl 1.766 0.84 47.5
Python 2.373 0.71 29.8
C 0.352 0.187 53.1
C 1.29 0.254 19.7
Java 3.592 2.361 65.7
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 dont 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 (i1 iltNF i) print tolower(i)'
    1 sort uniq -c sort --key1rn,2d
  • cat 1 tr A-Z a-z tr -sc A-Za-z '\012'
    sort uniq -c sort -r -n
  • awk 'for (i1 iltNF i) print tolower(i)'
    1 sort uniq -c LC_COLLATEC sort
    --key1rn,2 awk 'print 1"\t"2'
  • tr "upper" "lower" lt 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
Write a Comment
User Comments (0)
About PowerShow.com