Live data from Hacker News

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

web.eecs.utk.edu

351–360 of 424 posts

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

#351

When making changes to a block of code or block of text, I frequently just comment out the code and rewrite it anew. I might copy-paste existing code (just to avoid stupid transcription errors). If its too large to see both what I'm writing, and the old code, at the same time, I just use two windows on the same file. This is relevant to writing fiction or non-fiction as well. For example, I didn't like this, so I com…

Huh, I thought your first example was much more poetic. The vaguely run-on sentence does a much better job of evoking what's happening in the scene.

Thanks. I'll think about it.

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

#352

Earlier quoted context omitted.

I do the same. Many people comment about commiting frequently but that doesn't work for me: delete code + commit => I don't see the code anymore and my brain magically forgets about it. I need the quick feedback loop: commented code + uncommented code (all in one screen) => new code is going to look like a mix of both. If I have to use git to see commented code then the feedback loop is broken.

Commiting frequently also has a substantial cost of needing to think of a commit message. If you don't think of a commit message, you'll never be able to find this version again. If you think up a message every 2 minutes, you'll quickly find you spend more time thinking of commit messages than writing code. I wish there was some kind of auto generated commit message. Things like: "Added function xyz()" or "Adjusted c…

People are getting way to hung up about their commit history in most cases. If you're just experimenting, even "asdf" can be a totally fine commit message. And it shouldn't be hard to come up with something at least a little more descriptive in You can edit the history later when it's required by somebody else working on the code.

Or you can just not care. 99% of the value of your git repo should be in the most recent commit.

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

#353
post #350

I didn't even realize I did this until reading this article. I think the issue is that the undo/redo concept is inadequate. The author's solution of a persistent, read-only history seems like a step in the right direction, but that seems like it's much too slow of a workflow to beat out CTRL+Z/Y/Shift+Z, which is muscle memory for most. Maybe we need something like a hyper lightweight git that can be controlled via k…

That's what IDEA has integrated as "local history" and I use it every day for this purpose.

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

#354

Earlier quoted context omitted.

"Sounds like trial and error" Isn't that what coding is?

Maybe to some extent, but most of coding in my experience is planning things out, figuring out exactly what you're trying to do and then just writing it. Bug fixes have a bit more trial and error to them obviously, but it's usually not reading entire code blocks. If some function becomes too gordian I start working on a refactoring branch to fix it. I also use 2+ monitors so I experience very little of the code delet…

People obviously have different preferred ways to think, and this holds for programming just like for math or any other cognitive endeavour. Compilers, type systems, REPLs and so on are specifically designed to be thinking aids, and it seems to me that using them to their full extent to augment one’s cognition is a perfectly valid way to write code.

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

#355
post #314
post #264

Earlier quoted context omitted.

You can assign a custom shortcut to it via Settings > Keymap and then the action "Main Menu > File > Local History". I myself have assigned the shortcut control+shift+=

Thanks, did that. I decided on Alt+Z, because Ctrl+Z is Undo, so I though this makes sense.

And Ctrl+Alt+Z is revert changes. Either the whole (or selected) file, or the current block you're in. I use it all the time.

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

#356
> ... introduces a problem of premature commitment, 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

Why is that a problem? Just commit, as many times as you want, to a throwaway branch.

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

#357
post #350

I didn't even realize I did this until reading this article. I think the issue is that the undo/redo concept is inadequate. The author's solution of a persistent, read-only history seems like a step in the right direction, but that seems like it's much too slow of a workflow to beat out CTRL+Z/Y/Shift+Z, which is muscle memory for most. Maybe we need something like a hyper lightweight git that can be controlled via k…

Undo/Redo shortcuts and a button to see the history in a timeline, my biggest problem is writing while in a undo state overrides the redo stack. Jetbrains has a Local History functionality, by it has a linear timeline instead of branching like the author plugin

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

#358
post #98

Earlier quoted context omitted.

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?

> I know it's wrong, but what's right? Nah, it's not wrong. You're testing your code changes live.

no it's webpack HMR

(I know you're joking)

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

#359

When making changes to a block of code or block of text, I frequently just comment out the code and rewrite it anew. I might copy-paste existing code (just to avoid stupid transcription errors). If its too large to see both what I'm writing, and the old code, at the same time, I just use two windows on the same file. This is relevant to writing fiction or non-fiction as well. For example, I didn't like this, so I com…

How do you comment things out in the "English fiction/non-fiction" programming language?

I'm writing in markdown. I use the quoting > character, instead of the more verbose [comment]: #(my comment) syntax. Emacs markdown mode changes the color of the text, and that is enough for me. I use the [comment]: $(my comment) syntax for actual commentary on the text.

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

#360

Earlier quoted context omitted.

> Also the second rendition makes doesn't include what the rest of the joggers are doing ... Something is amiss here.

Karma/backlash for my rude post. I will leave it unedited, but s/makes// in case it is not clear.

I didn't take it as rude. Should I have?
Post reply on HN