Live data from Hacker News

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

web.eecs.utk.edu

121–130 of 424 posts

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

#121

Please don't make me use a slider. IntelliJ has local history, and I have that instinct to Cmd-S after every change. Problem already solved.

What’s funny is that Ctrl+S does absolutely nothing in IntelliJ-based IDEs - all changes are saved automatically there, but we all still press it, because old habits die hard - and IntelliJ creators know this and don’t bind Ctrl+S to anything by default.

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

#122

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

Where would you want to use `git commit-tree`?

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

#123
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 too am struggling to understand this use of undo.

If I'm reading this correctly it means applying a large number of undos to get to a previous editor state, followed by an equally large number of redos to then get back to where you started.

I can't recall every doing something like this.

The only time I seem to use undo is when I genuinely make some sort of editing mistake.

One reason I know I don't subconsciously do this is because I never struggle to execute an undo action.

However, on the rare occasions I need to do a redo I tend to struggle with the short cut key and usually go to the menu instead.

That tells me I use undo much more than redo.

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

#125
Jetbrains IDEs have a local history feature that provides snapshots with diffs and allows partial rollbacks.

I only use it when experimenting with different approaches.

Mostly I only use the "Local Changes" tab in the Git panel that shows the diff compared to the last commit, or "Compare with branch" to see the overall changes relative to the base branch.

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

#126
post #2

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

Yep, it's quite a handy feature at times. I don't use it a ton, but it is very helpful when I want it. One very nice aspect is that you can scope it to a specific section within a file (the same can be done with git history as well).

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

#127

Oh hey, I've built this! My version would watch code files and snapshot a diff every few seconds. It took a little work to tweak the constants to keep the watching performant, but it was super neat being able to replay code. The main problem I faced was that changes often occur in different places in the file, so the history replaying jumps around a lot. With some proper editor integration, I could see it being prett…

I would 100% use this! I do exactly what is described in the note. I use undo/redo a lot to traverse between two states of code and found this incredibly frustrating.

Until this point I thought that was just a bad practice on my end, so never saw the need/opportunity for something like a state slider.

Honestly never thought other people were using undo/redo like this.

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

#128

Earlier quoted context omitted.

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.

Git doesn't mandate to only commit useful stuff.

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

#129
post #111

Earlier quoted context omitted.

Likewise. This whole thread is totally bizarre. The closest imaginable thing I might do is wrapping some block of code in an if(false) {..} or #ifdef it out, when I'm refactoring and feeling unsure about my changes. But is that even the same thing that we're talking about here?

Hello from the bizarro universe of people who do this all the time and can't imagine the opposite. Do you never rewrite some code only to realize it didn't precisely capture all the edge cases of the thing you rewrote? In those cases I use the git gutter in VSCode to view what the old code looked like and compare and contrast to the new version to see what I missed. It seems to me that that's the same as what these e…

I suspect that is exactly the method most developers would uses in that situation.

All versions controls have a way to compare, merge and revert historical changes in and out of the current working copy.

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

#130
post #111

Earlier quoted context omitted.

Likewise. This whole thread is totally bizarre. The closest imaginable thing I might do is wrapping some block of code in an if(false) {..} or #ifdef it out, when I'm refactoring and feeling unsure about my changes. But is that even the same thing that we're talking about here?

Hello from the bizarro universe of people who do this all the time and can't imagine the opposite. Do you never rewrite some code only to realize it didn't precisely capture all the edge cases of the thing you rewrote? In those cases I use the git gutter in VSCode to view what the old code looked like and compare and contrast to the new version to see what I missed. It seems to me that that's the same as what these e…

Yeah, sure it happens. Then I type “git diff”. But never have I unraveled the entire undo buffer stack only to peek at it and re-push the entire contents. That’s super weird to me.
Post reply on HN