Live data from Hacker News

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

web.eecs.utk.edu

81–90 of 424 posts

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

#81

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.

Newb emacs user here. Heavily reliant on spacemacs and tutorials and copy-paste, but I use it often. The undo-tree terrifies me.

It's easier than it looks! Poke around with the arrow keys a little. You'll get the hang of it pretty quick.

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

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

What's the problem? I do this often.

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

#83

Earlier quoted context omitted.

This is excellent... for Vim users. A lot of developers either are not willing or haven't gotten around to learning the complexities of Vim, and use other IDEs like JetBrains or Eclipse. This workflow won't work for them.

I am one of those "not willing" people. I encounter the same issue discussed here without even thinking about it, and solve it as such: 1. Realize I need to check how my new code looked like 5 min back. 2. Copy full file into clipboard, undo by a few steps 3. Do a temp commit on GitHub desktop 4. Paste the new code back and look at the diff on GitHub desktop, and if needed undo the temp commit from above. Is this mor…

> The other analogy is cars - for most people it's something that gets them places, for others it's a way of life if not at least a more involved proposition.

But if code is your way of life, which it is for many people here, it is beneficial to learn the tools that allow you to do it easier. If someone can see how their code was 5 minutes ago in a few keystrokes, they’re going to take advantage of that significantly more frequently than someone using your cumbersome method.

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

#84

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

Commit early, Commit often!

If I have to commit my whole undo history then I’m using git very wrong. I commit (even temporarily) to save progress, but only when it makes sense to so. Sometimes I don’t know whether I’ll need this specific version again in the future.

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

#85

Earlier quoted context omitted.

This was my first thought. A timeline is nice, but the problem with a linear undo history is that if you undo and then edit, you lose access to the state before you undid. A tree is clearly the right structure for undo history.

You could just append a new state to the end of the timeline when you “undo”, so you never lose history. This is how undo works in Emacs by default.

Heck it's how boring business apps handle bookkeeping data since forever. You never delete a record to correct a mistake, you create a new record to do it.

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

#86
post #75

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

It might not be exactly what you're looking for, but I saw this linked on Twitter recently and have been meaning to try it out, so maybe worth a look? https://marketplace.visualstudio.com/items?itemName=Wattenbe...

This solves another problem I had, so I’ll try it, but it’s completely unrelated to edit history.

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

#87
post #73

Earlier quoted context omitted.

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

(Ok, looking at your profile and your background, I must be missing something. You surely don't need 5 or 10 minute history of code to know what you are doing.) Please help me understand what I am missing from this conversation!

You know what? Most of these ‘disagreements’ about coding workflow and tool choice in which one person is telling another person that they’re Doing It Wrong boil down to different strokes for different folks.

This seems to be a fine example of that.

(Though I must admit that consternation about how often someone presses Ctrl-Z is a bit lower level than I’m used to seeing.)

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

#88
so how do you handle the "undo make a change and no longer can redo" conundrum? Just have the branches in the tree of edits laid out flat in chronological order so that in order to bring changes back from the past you go to an earlier time, copy and then paste the changes to the alternative branch in the present?

Idk I do think version control is probably a much better tool to sanely manage rapid workflow when working at scale on huge projects, I just think the problem is that there too many features and far to few people who actually take the time to learn how to use them effectively.

To prove my point, the awk tool is super powerful and solves many "quality of life" problems developers begrudgingly deal with on a daily basis over and over again.

Now lets see a raise of hands of people in here that can actually write an awk script one liner without referring to the manual?

We have all these wonderful tools but most of us are too spoiled by having a mouse and powerful editors that we don't ever learn how to use them to improve our performance as developers.

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

#89

> 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 intermedi…

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

Low-level plumbing commands, if the VCS has them, can help with that, e. g. `git commit-tree`.

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

#90

Earlier quoted context omitted.

Committing removes the diff view in PyCharm, and I can't lose that. By "diff view" I mean I can see all the changes I've done from the main branch.

Personally, when I'm ready to submit a pull request, I usually do a soft reset to the point where I branched off from, then redo my commits and force push to the branch, for exactly that reason. I can't remember exactly which lines I've changed over the past few days unless I see all the diffs together.

Interesting idea...

I suppose I can stash my current code, reset to where I started somehow, and then unstash.

I've also toyed with the idea of having two repos on my disk.

Post reply on HN