Live data from Hacker News

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

web.eecs.utk.edu

61–70 of 424 posts

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

#61
> Want to know what we saw developers doing instead? They either duplicate code files or took screenshots of relevant code while in the middle of a change. Even I have done something similar before: I'm about to mess this up... I'll Ctrl-A and Ctrl-V this into a new tab before it gets too messy, and then I can put the window beside my editor to use as a reference. I even observed a professional developer with 20 years experience doing this!

I do this kinda stuff all the time in my digital art practice. Duplicate a layer, hide the duplicate, start making changes. Does it work better? Awesome, delete the duplicate. Did my idea not improve it after all? Cool, delete the new version and rename the duplicate back.

It's simple and reliable and builds easily on existing structures.

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

#62
> I'll walk through some reasons why version control does not save the day here. While a developer is making changes to code, they may not realize that they want some intermediate version from a few minutes ago until they are well into making the change and become stuck. We saw this repeatedly in our studies. This introduces a problem of premature commitment3, which forces the developer to decide to save an intermediate version (or not to save it) before they have the information needed to make the decision (whether they will need it or not). Unless you commit code to your git repository every few minutes, working or not working, then version control won't help you here.

Presuming DVCS here; if you’re still on a centralized VCS this is surely Not Good:

So, you need an editor utility that automatically commits every save (and possibly autosaves and commiys every completed undo-list item)on a special temporary branch that gets deleted when you do a real commit, and if you go back to prior state on that branch it automatically does the same but starts a new temporary branch with the next item, deleting the whole temp tree on a real commit. Or maybe leave the temp branches around until manually cleaned up, but provide a UI to do that in an all-at-once sweep.

The obvious challenges seem to be managing temp-branch vs. “real” current branch state in a way that doesn't mess up or get messed up by other tools interacting with the repo (including ha sling things like pulls and other inbound changes to your “real” active branch), and generating non-noise automated commit messages. Advantages would be all the tools you have for VCS history can then be deployed to your edit history without any additional friction.

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

#63
post #20
post #2

jetbrains IDEs have a local history feature that seems to do this

Came here to say this. It is a really old feature.

It is, and yes I've found it useful. However, the idea of a slider that you can just yank around sounds really appealing.

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

#64
post #46

Earlier quoted context omitted.

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

Yes, and I've always believed that short-term memory is a very important mental training for a coder.

My short term memory is much reduced compared to my younger self. Consequently, I work in ways which allow me to reduce cognitive load and still accomplish the task. FP is a godsend for me, even if I just adopt some of its principles.

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

#66

Does anyone know if there’s a good way to do this in VS Code? I often hold cmd-z until I get to some version and copy code from it. Ideally I’d like to have a separate window where I can see a previous version without affecting the current file/view. Before anyone comments, git doesn’t cut it for this because no one commits after every -+1

You can stage/unstage selected ranges with vscode+git, useful but not a tree. Has bad behavior if you choose some portion of a range, or if the unstage will stomp on some other inflight change

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

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

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

#69

I just searched and couldn't find a plugin for Atom called Yestercode. If there was one, I'd definitely use it.

It isn’t public [yet]. You should check out our plug-in CodeRibbon though! Available for Atom. https://utk-se.github.io/CodeRibbon/

> It isn’t public [yet].

Ah hah. I'd like to use the code history slider plugin too. You've done well to identify a common problem many of us face.

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

#70
post #42

Earlier quoted context omitted.

That's what a git browser is for. It's not like your code is gone forever, unless you are undisciplined.

I certainly don’t commit things every five minutes, so this doesn’t help.

In my 30 years of professional programming, and even with my admittedly declining short term memory, I have never felt lost without access to versions of code from 5-15 minutes ago.

Not to be harsh, but I really think that this indicates some fundamental approach issue rather than a tooling problem.

If it cannot be written on paper (or tablet note with pen) as rough pseudocode... or even drawing boxes and arrows for the visually-inclined, then the problem is not understood. Take what is understood and codify it, pushing the complexity and the unknowns to the edges. At least that reduces the complexity.

One aid I do lean on heavily though is a REPL. Load the code and do some interactive work with it. Inspect the data, test some transformations, and then write code to do what works. That's my current approach to situations that I cannot immediately and accurately write in one pass.

Post reply on HN