Why I Still Use Vim
medium.com
medium.com
The title should be same as the blog post title: "Why I still use Vim".
I use Vim too by the way.
This isn't just a contest between native and non-native code. It's a contest between efficient non-native code and crap non-native code.
Right now I have Atom open with four different projects. Each project has anywhere between four and twelve files open. The project using the most memory is only 258MB, but the others are all close to 100mb.
On 4gb it only takes a couple of Electron apps to eat half of my ram or more. Factor in the OS and a browser or two and it's already swapping. These are often just chat apps or something, they may be good apps but they aren't doing anything fundamentally new and whatever they replaced probably needed <100mb of ram.
It used to be that developers published minimum and recommended system requirements for their program. Maybe Electron developers need to start disclosing that 4gb ram is the minimum to use their apps and 8gb is recommended.
There don't seem to be many benefits I get from an Electron app that I couldn't be getting by just running Chrome in app mode with a dedicated profile (which consumes a lot less ram).
I would prefer to see developers release a web app first and then perhaps offer an Electron version if you've got ram to burn.
I think a better platform could be a highly stripped down version of web to the point where it is not even web anymore but still familiar and simple to use. Kind of like what Flutter did (Desktop support in flutter would be pretty great actually). Either that or a serious react native platform/framework that focused on Desktop computers.
Maybe if they switch to Servo it might use a little less RAM, but inherently it's always going to be pretty heavy.
This to me is the crux of the issue. Github has a lot of great engineers but they're less likely to be versed in C/C++/whatever else is required to make this kind of thing truly succeed.
It really begs the question of what Microsoft were thinking the day they decided to build Code on it.
https://github.com/mozilla/qbrt
I really hope it sees more development
what?!?
Rendering HTML and running a JS VM might seem like a long way around to get a desktop interface, but you're reading this in just that context, alongside a couple of dozen tabs, many running webapps with complexities to rival Microsoft Word '97. You're not using 4GB per tab; you probably aren't even getting up to 4GB with all your tabs.
Electron can do better.
Think of electron as a single tab open in a browser instance. If you open 12 tabs in chrome, it doesn't use 12x the RAM, because most of the initial RAM is used maintaining the browser instance, not the rendered tab. most electron apps don't have "tabs" but if they did they wouldn't multiply the memory usage either
I'm not saying it does or doesn't, and I'm not defending it, I just think we need to be a little more fair with our comparisons
I did a comparison a while back (though I'd hardly call it scientific). I built a basic "hello world" Electron app, which consumed 69MB of RAM on Windows 10. When I opened the html file of that app in Chrome it took 82MB.
Yes, Electron apps are a bloat considering that each one of them brings its entire runtime like games, and you know that most games will exceed several Gs of disc space and memory. The actual app that runs under electron is probably a few KB up to several megabytes of packed JS. Now consider statically linking the entire Cococa framework and other supporting frameworks in your app. Why would you do that when the OS is doing all the heavy lifting for you? Well, Electron is not part of your OS so if you develop with it you need to absorb the cost. The cost of disk space and memory - don't forget that. The OS does a lot of clever stuff to minimize your memory footprint. For example, DLL code is actually shared across all processes and mapped into each process/thread virtual memory space. This alone is a lot of optimisation taken for granted.
Ignoring decades of progress for the sake premature optimisation is stupid. The web is a reality and there is a lot of investment behind it. What needs to happen is for browser and OS vendors to offer means to execute web apps as part of the OS with all the optimisations needed for it to happen. Windows is able to run web apps (HTA) under the context of an isolated IE using COM but no other mainstream OS does as far as I know. Do you think that having in kernel virtual machine crazy? This feature already exists in all major kernels and your GPU drivers as well. You just don't see it because it is abstracted for away for most development tasks.
So yes, vim is nice and Electron is a bloat. But that only stands if you ignore the fact that the modern browser is effectively a modern OS. So think of Electron apps in the same way you think of docker containers. It is a snapshot of executable code - all the code you will need to run your app and it is portable across OS-es. That is a huge order to fill and it is done almost effortlessly.
Yes, you'd need to update and build apps for each native platform separately, but the end result would be worth it. We're talking about maybe halving ram usage simply by writing a little more native code to package up our javascript
1: https://github.com/jhallen/joes-sandbox/tree/master/editor-p...
---- EDIT: I'm sorry, there's a mention at the end of the article. Either I didn't noticed it before or he added it after this comment.
It's one saving grace is that I thought Sublime was a bit bulky/memory hungry, but Atom gave me a new found appreciation for Sublime which I'm now back in love with!
Unfortunately, IIRC, Sublime does exactly the same thing. It's really frustrating. I haven't been able to find a good all-purpose Mac programmer's editor with working code folding.
My collegue tried VS Code, but it screwed a commit due to not updating the file after a checkout, so he went back to Sublime.
I do wonder whether the measurements take the base overhead of each editor into account. Do the numbers represent the use per file or the total for the file plus the entire app?
These features aren't unique to the JS language though. Extentions do have access to the APIs that implement these features, so you already have them available for most languages (with different levels of quality/completeness).
The biggest advantage of VSCode over ST3 is its code intelligence. It's the kind of quality you'd expect from an IDE like WebStorm/IntelliJ but without the entire weight these IDEs usually bring to the table. VSCode still feels genuinely "fast enough". And if you work with JavaScript, the code intelligence even becomes better if you have dependencies that have community-provided TypeScript typings -- you don't even need to use TS to benefit from the built-in TS support.
Other than that, the extension ecosystem is very strong. I missed a few ST features initially (mostly specific keyboard shortcuts) but there are extensions that provide all of that (including an ST keymap) and more. It's also fairly easy to write an extension yourself if you know a little JS.
I'm glad it works for you but not everyone is willing or has the budget to max out their system's memory in order to run text editors and chat applications. You can run multiple CADs and simulators side by side with half the amount of ram. The difference matters if ram is a precious commodity and for many people, especially on laptops, it is.
I understand the need for a hassle-free multi-platform experience, but there should be a better way to accomplish it than this wasteful approach.
I mean, sublime does it really well without the backing of behemoths like Microsoft.
I'm a web developer. 90% of my work happens either in an editor, a browser or the shell. So yeah, VSCode's memory use doesn't really matter.
If you think Sublime comes anywhere close to VSCode in terms of features you haven't really given it a try. The code intelligence alone was worth the switch and perf-wise I see no practical difference in day to day use.
Granted, but features have nothing to do with the issue here (wasting resources). Microsoft could have easily offered the same feature set with a different implementation. I have visual studio at work with 7 projects loaded and it sits at a comfortable 400 MB
If your laptop is your work system, it makes sense to have something powerful that costs a few grand. But then personally I'd pay a few extra and get a full featured IDE, why bother with text editors?
Electron apps are often slow, memory hogs, but VS Code is neither of those things - it's an example of a great Electron app that absolutely flies, despite being stuffed with features.
However, to spend 800Mb to change a single file is too much. Atom is not a complete IDE as VSCode or Eclipse by any means. Yes Atom has IDE packages and capabilities are started to be rolled in, but it's too young.
God knows what will be the memory usage of Atom when it grows to a complete IDE with project-wide knowledge.
Also, having enough resources is never a good excuse for an application to use massive amounts of memory.
I can see this conversation in the future:
"I have 128TB of RAM"
"Why the hell do you need so much RAM, what's the point?"
"I use electron apps."
"Oh..."
[...]
"Why the hell do you need so much RAM, what's the point?"
"It's a Chrome box running web-native apps."
"Oh..."
WASM is defining our future. It might not be chrome boxes, it could be Safari boxes, or Edge boxes, or Brave boxes, or... Why use MacOS/Windows/Linux when everything is available to a sufficiently powerful JS interpreter with built-in sandboxing?
I already said it's a trade-off. Even with multiple instances side by side, VSCode barely registers. A gig of RAM may matter to you but I'm going to guess your needs are very different from mine and VSCode helps me do my job better than the alternatives I've tried.
Also, as you might be unaware of that: you're being a bit of an ass.
> Also, as you might be unaware of that: you're being a bit of an ass.
If you are offended that your favorite text editor uses as much RAM as an entire web browser, then shooting the messenger isn't going to help.
The people behind Atom and VSCode are putting this out for free.. How about we each use whatever we want and stop complaining about having too much choice.
That's astonishing considering that Sublime uses GUI and vim is a console editor.
I also like vim, but Sublime + vintage ( vim-mode ) works good and you have the benefits of both worlds.
1) Replacing 10000 words took Sublime 6 seconds instead of Vim 4 seconds. Both very quick compared to the competition.
2) It is nowhere near as bloated as VSCode or Atom. More comparisons here [1].
3) In the "Rehighlight test" at [1], Vim is slower than Sublime as well. Vim fails with "Time to load 3 GB file, insert character at start and exit" [1] while Sublime loads in 75 seconds. Many editors choked on that. Some refused to try, other tried and failed/died.
4) Performance is going to differ per plugin and dotfile which is often a unique setup for pro users.
5) Arguably these don't compete with each other as Sublime is a GUI application while Vim is CLI. They don't necessarily attempt to cater to the same type of user. You could say the same about IDEs though.
Sublime has the reputation of being a closed source (proprietary), portable (running on all 3 major GUI OSes), GUI text-editor which is very quick [2] and great for development, particularly because it can be extended via plugins, and being JSON under the hood (config files). Its even free to use for non-commercial use, and doesn't nag the user about a software license except for mentioning UNREGISTERED at the bottom right. I prefer open source software, but in closed source software this is about as honest, kind, friendly as it gets.
[1] https://github.com/jhallen/joes-sandbox/tree/master/editor-p...
[2] Quick as being perceived, as well as proven by these benchmarks.
Yes, there is a way to get all that using Vim. Install a bunch of plugins, like `alm` and syntax for stuff, and all of Tim Pope's amazing plugins, etc...
But then just moving the cursor in Vim becomes sluggish and slow. Sometimes hitting the `u` undo button might take 20 seconds or even a whole minute. That is not a fun experience.
The same thing with VS Code is immediate. In the rare occurrence that I want to jump to some weird place, I can move my hand to the mouse but in general, everything is accessible via keyboard shortcuts. The VIM-Mode of VS Code is almost perfect, the only gripe I have with it is that it cannot currently do proper block-mode copy-paste (but it does have block-mode! yey!)
So although I really want to love Vim and use it. The speed of VS Code is more important for me.
All those people who edit code without syntax highlighting, completion, typescript/flowtype popups, auto feedback from tests and lint, ... I just don't get how you can write code that way. It is silly to forego all this just because of a couple hundred megabytes of memory.
I run the linter, type checker and tests in a separate terminal tab (with split views). So before I commit I quickly switch to that terminal tab, see whether everything is ok and I am good to go.
My VIM is blazing fast and barely uses any resources. It launches nearly instantly and rarely gets in my way.
Quite efficient for me personally. I am not saying it would work for you, I am merely showing the way I use it. It's a bit of a different approach. You're trying to use VIM as an IDE. For me, my entire terminal is the IDE, of which VIM is a small part.
Alas, this evasive approach to disclosing precise information seems so often to be the case once money is involved; just yesterday I had to delve deep (as far as the T&Cs) to confirm that Zoos Victoria’s advertised “$9/month” membership actually means “$108/year, but you can pay in monthly instalments if you like”.
> Or, well, just anything that is not a web browser masquerading as a text editor.
> If not Vim, then maybe Emacs. Or, well, just anything that is not a web browser masquerading as a text editor.
I'll just leave this here: https://www.emacswiki.org/emacs/w3
;)
Well, Electron has finally delivered on the original GUI promise of Java over a decade ago: every single application I use on a daily basis is now cross platform.
That matters to me because it means it doesn't matter what OS I'm using - I can recreate my setup on Windows or macOS if I can't use Linux. I don't have to worry about platform differences beyond the shell and filesystem.
The security concerns people have with Electron are great but I'd wish they applied the same skepticism to all applications written in C++ or C. Unsandboxed applications are inherently unsafe. They don't just suddenly become unsafe because you write them in JS.
If I'm writing a lot of fresh code or exploring a new codebase, I like to use GUI based editors.
Anything quick or repetitive, I tend to open up vim because its speedy to open and edit.
In an IDE world, you fire up your environment once when you power on. For the next week or so until you reboot, opening a file is instant.
Granted, it uses memory in the background. But you have 32gb of it on your laptop. Keeping a couple of those in reserve to never have to edit code as though it were text seems like a fine trade off for those who choose to make it.
Editors aren't slow and I can be productive, it's simple as that.
But i still kept Sublime installed for handling large files, which would mostly horribly crash Atom or take ages to open.
Spending a lot of time designing it's quite some work to keep up with the technology I'm coding for already, so getting to know vim more in depth always felt a bit overwhelming. So the takeaway for me here is clearly to go back to Sublime, I didn't realize how dramatic the performance difference is in the end and am often feeling itchy waiting up for a lagging Atom on larger projects...
This will be a matter of syntax highlighting configuration. I’m presuming this means “open the file and press G”, in which case it’ll come down to the :syn-sync value; this defaults to 100 lines, which should be basically instantaneous, but my guess is that he’s got it going fromstart, or else possibly enabled g:xml_syntax_folding, because that’s really the only reason I can imagine why it would not be blazingly fast.
I'm more concerned about how much work I'm able to get done, and with Vim frustration eats up more of my time than with a modern GUI.
I'm not sure I even understand the reasoning behind the thing. Yeah, fine, we want to do the web-thing in a desktop applikation. But then why a whole Chrome with a showroom of kitchen sinks? We can still run an html-stack without gobbling up every ressource in sight, you know.
I'm looking at this HN page in latest Firefox (and assuming Chrome would be much the same). And in another window the same page in Netsurf (http://www.netsurf-browser.org). One needs half a gigabyte and then some. The other does fine in 50MB.
Plenty of stuff which gets wrapped in Electron actually works without a hitch in Netsurf and similar minimalistic environments.
Professional pride, anyone?