I thought notepad, being the most simple text reader is also the fastest, but I discovered when I tried to open very large text files that Wordpad opens them much much more quickly.
What could be the reason for this?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
A plain basic editor like Notepad might be so simple that it doesn't have the ability to deal with complex situations, because it's only used for easy use cases.
A smart editor will determine many factors to decide which strategy is the best to use. For example instead of reading the file line-by-line or byte-by-byte like a stupid editor it'll load into a big buffer for fast reading later. Or it can map the file to memory. But how big should the buffer or the map area be? It depends on each specific case and the editor should also account for that. Instead of loading a whole several-GB file into memory and stuck because that simply doesn't fit in, a smart editor just checks the file size and loads only the currently viewing part then seek later when needed.
All of that require a more careful design with a lot of logic that doesn't exist in Notepad, since its source code hasn't changed much for a decade.
Windows 10 build 17713 introduced a lot of changes to Notepad, one of which improves Notepad's behavior on large files
- We’ve improved the performance when opening large files in Notepad.
- Notepad now supports Ctrl+Backspace to delete the previous word.
- Arrow keys now correctly unselect text first and then move the cursor.
- When saving a file in Notepad, the line and column number no longer reset to 1.
- Notepad now correctly displays lines that don’t fit entirely on the screen.
Now there are also Unix line ending support, text zooming ability and status bar in word wrap mode
It's also confirmed that Notepad does use memory-mapped file, but that's the beginning part. The difficult thing is to parse the line and do the line wrapping. Even Notepad++ sucks when opening super huge files. See Poor performance with large .txt
Notepad is little more than a shell around the Windows Edit control. It was designed for editing small amounts of text and was optimized for such. Early versions had to run in systems with very limited resources where these optimizations were important. Windows 95 had an official requirement of only 4 MB RAM and for technical reasons the Edit control was limited to 64K of text. The NT platform was not so limited but it too had to work with limited resources.
Designing an editor for small files is relatively simple. Designing one that works efficiently with large files is anything but simple and requires a great deal of complex code. Small and simple editors do not work well with large files. All such editors, not just notepad, will choke on multi gigabyte files, even on a powerful computer. Some advanced editors can handle this with ease.
Notepad still works well for it's intended purpose and has had few changes over the years. The Windows Edit control is used in some form in most Windows applications so the potential for incompatibilities is great if major changes were made. Why take the chance of making unnecessary changes? Experience has shown that the most trivial of changes can cause incompatibilities in applications
If you need to edit larger files there are plenty of other editors available. Notepad was never designed for this.