Online Python Tutor: Learn programming by visualizing code execution
pythontutor.com
pythontutor.com
Here is some context behind the current incarnation of Online Python Tutor:
This is exactly what I needed to help people visualize their code. I can't tell you how many beginners have a hard time figuring out how a program steps through their code and this is a huge win there.
Huge thanks!
However, my big criticism of these sorts of visualisations is they seem to be entirely geared towards imperative programming. Has anyone seen similar visualisations for more functionally structured code?
Oh, I see you can write your own code to be visualised. Here's a simple list comprehension: http://pythontutor.com/visualize.html#code=myList+%3D+range(...
Not the most enlightening visual.
A similar approach for those mounting towards FP would be certainly nice though, but it would have a completely different target demographic. Also it seems to me that languages like Haskell and F# are better for just learning FP.
My motivation has been to ease the learning path for an existing popular language (Python).
See this 2003 PhD thesis at MIT for two examples of existing languages designed to take full advantage of live programming environments. (Flogo I -graphical- and Flogo II -textual): http://llk.media.mit.edu/papers/ch-phd.pdf Particularly interesting is Flogo II capability to mix the imperative and functional-reactive programming paradigms in the same code block, as parallel runtime processes; I hadn't seen that before.
This should definitely be integrated into Udacity and other learning platforms! Most instructors have to do this by hand in CS 101 lectures anyways.
TL;DR I wish this was the same as a debugger, because then debuggers would be awesome.
Another project he worked on that you may have seen on HN is the PhD Grind book (about getting a CS PhD from Stanford).
locals() and globals() are undefined.
Still crazy slick (if it were the early 90's I'd say "l33t") bit of coding.
In seriousness, any programmer will need to know that functions don't just magically appear... if they don't work, they'll need to know how to pull in some sort of library, or realize why those functions just don't make sense for the current environment (one could explain to a complete novice why it would be a security breach to allow I/O functions, for instance). Python is a language, not a standard library, just as C is C even if you don't #include <stdlib.h>.
Online Python Tutor isn't meant for running large examples. Think of it as a "digital whiteboard"; I don't think anyone would expect to visualize a 100,000-step program with tons of pointers on a whiteboard :)