Live data from Hacker News

Why is it so hard to see code from 5 minutes ago?

web.eecs.utk.edu

91–100 of 424 posts

Re: Why is it so hard to see code from 5 minutes ago?

#91
post #71

For anyone that uses emacs, there is an excellent plugin "undo-tree" that solves this problem in a slightly different way. Everytime you undo a series of actions and then perform a new action, it creates a branch in the "tree". You can then visualize the tree and move through it quickly your entire buffer history.

For those that use vim, gundo.vim visualizes the "undo-tree" and allows you to preview / jump to any revision: https://github.com/sjl/gundo.vim

There's a fork called mundo which has an inline diff mode that I'm a big fan of — https://github.com/simnalamburt/vim-mundo

Re: Why is it so hard to see code from 5 minutes ago?

#92
post #46

I am very surprised by this. I seldom use the control-z shortcut and I've been writing code for several decades...

Indeed. This sounds more like trial-and-error programming.

What's the alternative? What should I be doing instead of cmd-z?

> I'll Ctrl-A and Ctrl-V this into a new tab before it gets too messy

I did this about 400 times today

Re: Why is it so hard to see code from 5 minutes ago?

#93
Tangential to this. Does anyone know of an app/service like etherpad, but for handwritten notes?

Would love to be able to replay notes that I write with the pencil on the iPad.

I also feel it would enable a cool way of storytelling in which you can play with the way you write so readers get to experience the text in different ways. Imagine that as you are reading something all of a sudden the letters start getting bigger, or thicker, or star changing color. Anyway, just replaying handwritten notes would be nice.

Re: Why is it so hard to see code from 5 minutes ago?

#94
so..... the data this is based on is from https://sci-hub.se/10.1109/vlhcc.2014.6883030 which is 21 students programming.

Seems a bit suspect the whole premise really. I don't really end up doing what this article outlines. I find a lot of programming studies are often done on what is immediately available... students, and I think this tends to not really be indicator of what experienced programmers do.

Re: Why is it so hard to see code from 5 minutes ago?

#95
post #67

I don’t think I've ever used this sort of time jumping with code. If I'm refactoring or testing a different segment I just comment out the original for visual memory reference and refactor based on the commented segment. Once I'm done, I chuck the commented section. It's nice to have the reference so I don't have to commit anything to memory.

I do this too. Sometimes I'll duplicate the entire code and comment out the lower one as I write a new version or parts.

Re: Why is it so hard to see code from 5 minutes ago?

#96
post #50

Reading the comments, I'm stunned and disillusioned. Are most modern developers struggling to write code without this? If so, there is a fundamental problem that has nothing to do with levels of undo.

I'm so confused as to why anyone would do this.

Re: Why is it so hard to see code from 5 minutes ago?

#97
post #57

For anyone that uses emacs, there is an excellent plugin "undo-tree" that solves this problem in a slightly different way. Everytime you undo a series of actions and then perform a new action, it creates a branch in the "tree". You can then visualize the tree and move through it quickly your entire buffer history.

Another cool thing about undo in Emacs is that it's context aware. By default, you can select any block of text and the undo command will cycle through the changes only from that region of your buffer.

whoa this is cool

does it understand syntax boundaries like curly braces / functions? ('undo within function' would be key). or just line #?

Re: Why is it so hard to see code from 5 minutes ago?

#98
post #50

Reading the comments, I'm stunned and disillusioned. Are most modern developers struggling to write code without this? If so, there is a fundamental problem that has nothing to do with levels of undo.

I'm so confused as to why anyone would do this.

I write a lot of frontend JS with hot reloading

make change => see result => cmd-z 1 time to fix result OR commit and keep coding

oops, it wasn't really fixed. cmd-z 3 times and see if that works

I know it's wrong, but what's right?

Re: Why is it so hard to see code from 5 minutes ago?

#99
[Works if source is versioned].

I usually use these 3 approaches in IntelliJ (IJ):

1. When a line is changed, IJ will show some marker in the left gutter. If I hover my mouse, I can see the diff.

2. Sometimes I peek Local History.

3. Sometimes I commit with random name e.g. "bla" so I can refer to that commit from time to time. When I'm done, I squash all the blas into 1 proper commit.

Re: Why is it so hard to see code from 5 minutes ago?

#100

For anyone that uses emacs, there is an excellent plugin "undo-tree" that solves this problem in a slightly different way. Everytime you undo a series of actions and then perform a new action, it creates a branch in the "tree". You can then visualize the tree and move through it quickly your entire buffer history.

And if you use IntelliJ/Android Studio there's Local History, which shows your git revisions but also periodic versions of your code outside of your commits
Post reply on HN