
Online Python Tutor - llambda
http://people.csail.mit.edu/pgbovine/python/tutor.html#mode=edit
======
pgbovine
whoa what a pleasant surprise seeing my project on the HN front page this
morning! just an FYI: this is a "demo-quality" project, not production-
quality. it's probably not ready for HN-level traffic! please email me if you
have more detailed suggestions or bug reports, thanks.

~~~
lhnz
Have you seen this presentation by Bret Victor [0], as he touches on user
experience in writing code? It seems like it might improve your product. :)

[0] <http://vimeo.com/36579366>

------
thefool
This is awesome.

Would be cool to see a version for a lower level language like C that would
help people understand the stack and visualize pointer arithmetic.

~~~
DanielRibeiro
If you found this awesome, Bret Victor will blow your mind (the coding tool is
the third example): <http://vimeo.com/36579366>

~~~
johncoltrane
Thank you. This guy is unbelievable. He blows my mind every time he publishes
something.

I __want __his editor.

~~~
DanielRibeiro
I've emailed him asking for it! Gregory Bell asked him on twitter as well:
<https://twitter.com/#!/worrydream/status/169497569855143937>

No response so far.

~~~
johncoltrane
I don't think he will answer positively. It's only a demo and somehow I don't
see him releasing an unfinished program. But I can imagine other people
picking up his ideas.

Actually there is someone in the Vimeo comment thread who has started a live
canvas editor(1) inspired by one of the demos.

Edit: (1)<http://www.youtube.com/watch?v=TBUC-7D1LIc>

------
ht_th
Although I like these kind of tools, I doubt that they're useful to learn
basic programming as they need a lot of prior knowledge to be present to
already understand the visualization. For example, what is a stack or heap to
a novice programmer? What will the effect of this visualization be on their
construction of an operational understanding of basic programming language
concepts? And these constructs, will they be helpful, have no effect, or even
be detrimental for developing understanding of more complex programming
structures?

On the other hand, in a more advanced course, say at university level, it
might help to construct knowledge about how programming languages work
internally and how this relates to their already existing understanding of
basic programming constructs. So, as a teacher be sure to evaluate the effect
of the educational tools you use. I know it is easy to use existing cool tools
(and this one definitely belongs to that category), but what is its effect on
your students' learning?

~~~
samdk
Having been a teaching assistant for intro programming classes targeted at
non-CS majors, I disagree. You don't need to understand what a 'stack' or
'heap' is to understand what's going on and for this to be useful.

And even if it's too complicated to be useful for people on their own, being
able to use something like this as a teaching aid would be very helpful. The
number of people who have trouble grasping even what most of us consider
_very_ basic concepts like iteration over a list is astonishing. Trying to
explain something you find trivially easy to someone who doesn't understand it
at all is an exercise in frustration for both people. I usually resorted to
doing a manual step-through on a whiteboard or piece of paper, but this is
much nicer.

I _would_ discourage people from using this constantly, just because I think
having a step-through debugger handy constantly will prevent you from
developing necessary debugging skills. (The concept of wrapping something in
_print_ statements is another thing I take for granted that's not obvious to
some people.) But I still don't see how something like this could be anything
but a net positive.

~~~
ht_th
> But I still don't see how something like this could be anything but a net
> positive.

The student will construct their own knowledge of programming by some learning
process. This tool has an effect on that process, as has every tool. It could,
for example, let some students construct an understanding of a variable that
makes it harder to start learning about, say, memoization in dynamic
programming. (This is just an conjectured example, mind)

I don't say it will, and I do have to say that the visualization given is
quite nice and sound. But because we, as experienced programmers, like a tool
because it visualizes how we think about programming and program execution,
that does not mean that this is transferable in a similar way to novice
programmers. As a high school computer science teacher I have been growing
more and more worried about so called _anti-didactic inversion_ in programming
education. Especially at lower levels of education.

In programming education, we often use professional programming tools with
professional programming languages and professional measures of programming
quality. When students are learning to become professional programmers, this
is a good idea. But is it as good an idea for teaching programming to those
who do not want to become professional programmers. Or for those who are
learning programming as a basic skill (like math, language, etc)?

------
norvig
It is great that Hacker News has caught up with this -- Philip has done a
great job with the Python Tutor. Next step: user-definable layout for display
of different data types.

~~~
abecedarius
There was a paper on that sort of thing: Korn & Appel, "Traversal-based
visualization of data structures". (It's online but I can't get the link out
of the search result easily.)

------
ilovecomputers
As someone who went through Intro to CS courses. I must say that including the
object oriented paradigm of Java in an intro class really confused me for a
good three years. It wasn't until I learned how data was organized and
executed inside a computer that it all became clear to me what programming
really consisted of.

This tool is wonderful. It visualizes the inner workings of a computer very
well and how it translates to code. I hope this teaching tool is used on
students after they've learned some basic programming concepts and syntax.

------
mckoss
Works great on iPad -- well done!

~~~
rainboiboi
yea! Surprisingly!

------
bp_
The tool is awesome, but I wouldn't rely too much on the instruction bounds.
For example, the greatest sums exercise
([http://people.csail.mit.edu/pgbovine/python/question.html?op...](http://people.csail.mit.edu/pgbovine/python/question.html?optimize-
sum#mode=edit)) can be solved in six "steps" for _all_ input lengths, while
it's certainly no O(1) business.

    
    
      def maxPairSum(data):
        return sum(sorted(data)[-2:]) # one "step"

~~~
tobiasSoftware
Actually, both your solution and theirs are not O(1). Theirs is n^2, while
yours is n lg n due to the use of a sort function. The best way to do this
would simply be to find the largest element, ignore that element and find the
largest element again, which is O(n).

~~~
cmurphycode
I do believe the GP's message was that the tutor told him his solution took
one "step", which is not equivalent to O(1), because sorted() takes O(nlgn).

In other words, he was pointing out the limitations of the tutor program's
analysis.

------
forbes
This is a fantastic tool. I love it.

On line #9 of the example program, the string "hello" is assigned to y. On
line #12 another string "hello" is used. I don't know anything about the inner
workings of Python, but I imagine that these strings would be stored on the
heap and possibly 'interned' by the interpreter. Maybe this is being ignored
for simplicity, or I am way off the mark.

------
paufernandez
Thanks a lot! I wish I had something like this for basic C++, my students
would love it!

------
morenoh149
I need 4 lines to do the mergesort correction. What's the way that is expected
here? I would do,

    
    
        if i = len(left):
             result.append(right[j])
        if j = len(right):
             result.append(left[i])

~~~
morenoh149
nevermind, sneaked a peek at the original code
<http://en.literateprograms.org/Merge_sort_(Python)>

------
agumonkey
100% cpu usage on chrome 19.0.1042.0 canary 0% cpu usage on firefox 13.0a1
(2012-02-18) until foo/bar execution (100% cpu usage too)

Like it anyway. Great job

------
vng
This should be insanely useful for someone new to Computer Science. I wish I
had this during my undergrad career. Good job!!

------
gahahaha
Does anything like this exist for Javascript?

------
bwarp
I'd love to see this in debugger form!

------
ya3r
Where was the aliasing?

~~~
leke
Was it y = x perhaps?

------
beggi
Really, really cool.

------
indubitably
unicode breaks it

~~~
pgbovine
thanks! that's a known bug in my todo list

------
wilfra
If you want to learn Python, MIT OCW Intro to Programming is probably the best
resource there is: [http://ocw.mit.edu/courses/electrical-engineering-and-
comput...](http://ocw.mit.edu/courses/electrical-engineering-and-computer-
science/6-00-introduction-to-computer-science-and-programming-fall-2008/)

~~~
salemh
I got through 20% of Learn Python the Hard Way, stopped for a number of
months, and have now delved into a few of the linked lectures. Learn Python
the Hard Way is already much more intuitive and simple to pick up (in a good
way). <http://learnpythonthehardway.org/>

However, I think the lectures are complementary. :D

