4 ms·
Looks good. However, my big criticism of these sorts of visualisations is they seem to be entirely geared towards imperative programming. Has anyone seen simil
by upthedale 14y ago
Looks good.
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(10)%0Atotal+%3D+%5B2+*+x+for+x+in+myList+if+x+%25+2+%3D%3D+0%5D&mode=display&cumulative=true&py=2&curInstr=0 http://pythontutor.com/visualize.html#code=myList+%3D+range(...
Not the most enlightening visual.
- agentultra 14y agoGenerators are similarly confusing to visualize... http://pythontutor.com/visualize.html#code=def+fib(n)%3A%0A++++i+%3D+0%0A++++a,+b+%3D+(0,+1)%0A++++while+i+%3C%3D+n%3A%0A++++++++yield+b%0A++++++++i+%2B%3D+1%0A++++++++a,+b+%3D+(b,+b%2Ba)%0A%0A++++++++%0Afor+x+in+fib(8)%3A%0A++++print+x&mode=display&cumulative=false&py=2&curInstr=0 http://pythontutor.com/visualize.html#code=def+fib(n)%3A%0A+...
- anonymous 14y agoIt does look a bit confusing, but it does step through the program in the order it executes. Unlike list comprehension, where it completely misses some instructions.
- lquist 14y agoCheckout DrRacket's debugger. Obviously not as well documented as this, but amazingly insightful.
- pgbovine 14y agoThe inherent limitation here is that Online Python Tutor is built upon a line-oriented single-step debugger (Python's bdb module), so there's no way for it to step inside of subexpressions (e.g., in your list comprehension example).
- DeepDuh 14y agoI still believe that imperative is the best paradigm to start programming. I.e. once you understand all the subtleties of for/while and branching, you can undertand a list comprehension as an abstraction on top of that, applicable for certain situations. In that light I think OP's tool is exactly what one needs to get going. 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.