Live data from Hacker News

Online Python Tutor: Learn programming by visualizing code execution

pythontutor.com

41–46 of 46 posts

Re: Online Python Tutor: Learn programming by visualizing code execution

#41

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(... Not the most enlightening visual.

The 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).

Re: Online Python Tutor: Learn programming by visualizing code execution

#42

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(... Not the most enlightening visual.

I 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.

Re: Online Python Tutor: Learn programming by visualizing code execution

#43

It's not exactly Python (or I'm doing something wrong). Which is very confusing / "dangerous" for people learning Python (They will learn it wrong and not have the xp/confidence to question tutor) locals() and globals() are undefined. Still crazy slick (if it were the early 90's I'd say "l33t") bit of coding.

If you're learning Python and are using locals() and globals() as anything more than a debugging tool... I'd venture to say you are doing something wrong ;)

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 .

Re: Online Python Tutor: Learn programming by visualizing code execution

#45

Hey guys, Isn't this the same as a debugger. Can people not learn from that?

Even now, after almost 10 years of programming, I still wish my debuggers had arrows pointing to data structures in a nice GUI. Sometimes, you don't want to interrupt your train of thought to recall the gdb or pdb command you need, or to remember "was 0xAE32F542 the first node in the list or the second node?" And consider the WebKit debugger for Javascript: just by looking at the Scope Variables tag, it's not obvious to catch a bug where you did `x = y` rather than `x = deepClone(y)`.

TL;DR I wish this was the same as a debugger, because then debuggers would be awesome.

Re: Online Python Tutor: Learn programming by visualizing code execution

#46

Hey guys, Isn't this the same as a debugger. Can people not learn from that?

Not quite. The visualizations are great, but the ability to rewind and replay time is the critical piece here. How many times have you had to stop and restart debugging because you missed something critical?
Post reply on HN