5 reasons why I will never autosave code again (and why you shouldn't)
Used to be a fan but the pains started outweighing the gains and I had to turn it off forever.
1. I actually don't have unlimited CPU and RAM
You can't dare call VS Code a "text editor" in 2023; The bloat is real.
Thanks to Electron, we now live in an era where a near-empty app boasts installation sizes of almost 100MB and proudly gobbles as much as 500MB of RAM.
My dozens of extension probably has something to do with this, but many of these extensions only run for specific types of projects and VS Code commands.
And none of this 1,200 MB RAM and 16.9% CPU came from my running anything in the terminal! I'm sure that there are some background tasks here and there, but I was doing absolutely nothing -- no typing, no building, no long-running tasks.
So what do you think will happen when a build watcher like Create React App is also running? Or a massive memory hog like the Android emulator, constantly reloading on every autosave?
2. Where's our formatting
VS Code doesn't care about auto-save in its "auto-format on save" feature.
And why should it happen when you've just barely finished typing?
Format-on-save only makes sense for real saves; you usually only press Ctrl + S when you've reached some sort of checkpoint; like after a bug fix attempt or a UI change and you want to see our changes in action.
If I want auto-formatting I'm still going to be using
Ctrl + D, D my personal keyboard shortcut for auto-formatting. So, no thanks -- I'll rather save and format together.
3. Autosave demands perfection
Autosave wants you to be superhuman.
There's no breathing room to make mistakes with auto-save; any you type gets written to disk within seconds.
Like can't you even make a single typo? Can't you have doubts about which direction to take the code in?
Now you'll say there's Git and all, but here's something to think about: within every commit, there are multiple "micro-commits". Even if you're blindly committing every single day there'll be intermediary changes within those 24 hours that you won't want to compromise or discard.
With autosave you'll never get a warning when you close a file after making an unwanted and buggy change -- potentially leading to hours of debugging code you thought was working just a few days back.
4. A save should be a micro-commit
Even if you Ctrl + S all the time you'll probably wait until the end of the statement. Because subconsciously you see Ctrl + S as a micro-commit, and it would be senseless to make those micro-commits at random.
But build watchers like Create React App don't see it this way.
These tools couldn't care less about whether the code that's been auto-saved is complete or not; they just re-build and re-build and re-build again.
That's distracting and unnatural. And you can't avoid it -- the best you can you is to set an autosave delay to reduce how much this happens or close the terminal. The former comes with its own set of problems (as we'll see), and the latter is simply unthinkable.
5. The lag tradeoff is annoying
Imagine what would happen if VS Code and others weren't sensible enough to have a delay before any autosave?
Your CPU usage would go crazy; Even if you're an extra-terrestrial typing god going at 10000 words per minute, you're still not going to be fast enough; there'll be a disk write for every single character you put down.
Even worse when you have a heavy build tool like Create React App watching your files and re-building.
So yes there had to be an autosave delay.
But a delay is a delay and no one likes waiting, even if it's a 3-second delay. Especially when you can get rid of it.
When I press Ctrl + S, I instantly know my changes are saved. I know my build watcher will run immediately. I have instant feedback and there is zero noticeable delay.
I find small things like these make a non-trivial impact on the development experience.
So I'm no longer autosaving my code. I had it on for some months back after I discovered such a feature even existed in VS Code, and then I went on and off, and then finally -- no more! Like many devs, I'm already used to Ctrl + S so it's no big deal. Let's see if my mind changes in the future -- how about you?
- The real danger of magic numbers in your code (AVOID)
- Why "Yarn 2" is actually Yarn 3
- Create React App alternative: 5 times leaner, 0 vulnerabilities
- 10 essential VS Code tips & tricks for greater productivity: Part 2