39 points · by vruiz · 11y ago · 59 comments
Code editors are surprisingly complex, it's not about simply putting lines on the screen. A good exercise in understanding the complexity is writing a simple syntax highlighting code viewer with native controls (not HTML) and see how much memory/CPU cycles your implementation uses for a 2MB file.
Tons of optimization needs to happen - for example, as far as I know very little information about lines that aren't visible is kept in memory in Visual Studio - so called "virtual lines." I'm sure other more mature code editors have this type of optimization as well. From a native perspective this type of optimization isn't a complete nightmare to implement (although it's hard if you consider code folding), however, imagine trying to do it in HTML. The browser is still going too do all the reflow etc. for the lines that aren't even visible, eating up CPU cycles and memory.
Even merely syntax highlighting is a problem. If you make one edit the entire file might be re-lexed: once again you need a unique solution for editors ("progressive lexing").
The question on my mind is, why do it in HTML? Especially if you're going to wrap that browser in something that approximates a desktop app anyway.
Imagine if designers tried to do everything in PowerPoint for some unknown reason. "3D animation? Yeah, we can do it in PowerPoint with this incredible hack that makes slides sort of like faces on a mesh..."
That's how it is with HTML today.
Light Table doesn't have any issues with large files, and is built on essentially the same stack (Electron + native HTML/JS/CSS for Atom vs Electron + ClojureScript compiled HTML/JS/CSS for Light Table).
Visual Studio Code doesn't have any issues with large files, and is also built on web technologies (no source available but I assume some variant of Electron + TypeScript?).
The problem is somewhere in Atom itself.
A fair percentage of the employees where I work seem to have reached that point already - reports, training material, data for general discussion, GANTT charts with individual symbols that I guess must be manually moved every week. Gah!
True, but as a programmer i very often generate and need to view files greater than 2MB.
Not to mention log files which commonly consume megabytes.
Insisting on all tools having an X because X is a useful thing is how you get the very bloat the GP is talking about.
So, it makes sense to me that they would assume only "human sized" data (and expect users to use another tool for looking at large files, "do one thing well" and all that) and opt for a slightly simpler programming model. Apparently, they decided that the assumption was wrong, and so changed the model.
The limit came about because trying to open a 100MB file as an html page (even without all the extra styling and interactive options) will break any browser. It was just a hard problem to solve, having an HTML-based editor deal with so much text at once.
https://github.com/atom/atom/commit/ec65a71d6dc8c3c44cb1b77a...
If I have 64GB of RAM, I expect my applications to be able to use all of it when asked to, and not just give up completely. It's fine to slow down, and giving a warning "Opening large files may be slow. Do you want to continue?" would be nice, but working with a 2097151-byte file and giving up if it's 2097152 bytes is really unpleasant.
There was this little gem a while back:
“Fixed an issue where Atom would to fail to launch from directories that contained a file named undefined or null.”
If they're not treating filenames as strings - and nothing but strings - then it could have some pretty surprising security implications, possibly to running arbitrary code just by opening files or directories with certain contents?
I just tried a bundled 3MB+ .js file and it loaded practically instantaneously. Even opening a 10MB+ .mp3 file (for science!) didn't result in any delay longer than a second. Whereas opening the same files on the latest Atom took a good 5 seconds for the .js and 10 seconds for the .mp3 (and it looks like Atom had to give up on doing syntax highlighting on the .js file, whereas Light Table did not). These tests were all performed on a rather modest Core M processor, so YMMV.
AFAIK, both Atom and Light Table are built on Electron and web technologies (Light Table uses ClojureScript but at the end of the day they both compile down to HTML/JS/CSS).
So my takeaway from this is: Atom's performance woes are most likely not intrinsic to the web-based platform it's built on, but are rather results of implementation flaws of Atom itself.
I'll stick to what works, thank you.
I agree the Sublime Text isn't as good as some other editors when it comes to large files, but 50 MB is generally not a problem
Oh. Now I know where the name comes from!
NAME
sed - stream editor for filtering and transforming textFor this reason, I generally use Notepad2 to handle larger text files (5 to 300 MB).
My suggestion though is to turn of SQL highlighting and disable word wrapping when opening a large file (I do the exact same with SQL and CSV files).
I bite the bullet and use a Java based IDE because frankly there are very few good ones that aren't Java based and support the languages I use, but if you're just using it as an editor there are plenty of native apps for Mac, Windows and Linux.
I've been using Atom for a bit now. I like it. I started out with vim but it never really stuck. I still use vim bindings in Atom for basic movement/yanking/pasting et cetera, but I admit, I am a GUI using creature and I like to grab the mouse every once in a while.
I rather enjoy the fact that I can poke at my editor just using a basic understanding of web development technologies. I enjoy that Atom was easy to set up and install plugins, unlike the dozen different ways you can/should customize vim. I already have a much more tweaked environment with Atom simply because slogging through .vimrc and vim bundles (even with vundle) was a major pain for me. I've never run into performance issues or the 2MB file limit (yes, I do have to deal with log files, but opening them in a text editor is not part of my workflow).
Clearly, others have different skills and priorities and Atom doesn't work for them. That's great. I'm glad there are options out there. Vim isn't a giant pile of shit just because it doesn't work for me.
On Windows notepad.exe, wordpad and notepad++ aren't really prepared for that task. Helpful would be an editor that streams in only a small part of a big text file.
Vim does a quite good job too.
vi does that.