175 points · by thunderbong · 3y ago · 156 comments
With a tiling window manager, the built-in notebook/tiling functionality is not really useful (the window manager is more flexible and has universal keybindings) so when looking at the time required to pop a full new window in either single or shared instance they were actually behind regular xterm. Resource usage wasn't stellar either (xterm was still better than most lightweight libvt-based terminals). Couldn't feel much of a latency improvement (again, X without compositor).
I'm sure at full throughput the difference is there, but who is looking at pages of output you can't read? I do keep terminals open for days, but my most common usage case is mostly open window -> run a small session -> close and I got annoyed fast.
Like, why? Over 20 years of using terminal emulators not even single time I was like "Man, I wish my terminal was faster".
Is this just a fun project to do, like, "yay, I wrote a GPU-accelerated terminal emulator!"?
The litmus test I use is how smooth can the terminal emulator run `cmatrix` at fullscreen
[1] https://news.ycombinator.com/item?id=28743687 (It takes a PhD to develop that) [2] https://github.com/cmuratori/refterm [3] https://www.youtube.com/watch?v=hxM8QmyZXtg, https://www.youtube.com/watch?v=pgoetgxecw8
I have started to see "terminal" apps that won't run on a real terminal, though. Using UTF-8 regardless of your locale, using 256-color xterm escapes regardless of your TERM setting, being unreadable without 256 colors, etc, and in general not using termcap/terminfo.
even on an integrated GPU, text rendering is far faster when you use the GPU to render glyphs to a texture then display the texture instead of just displaying the glyphs individually with the CPU.
With high refresh rate displays it really helps avoid a blurry mess too
I can read the stream almost like The Matrix
GPUs aren't really meant for bit blitting sprite graphics. (Which is what a terminal really does.)
Nowadays, everything is done with the same pipeline as the 3D graphics, there's no need for two pipelines.
GPUs are meant for this. Modern ones. Your knowledge is incomplete, outdated, or both.
Even worse: although many terminal emulators claim to emulate some "ANSI" terminal or be "VT100 compatible" and so on, most of them aren't at all. Simply run vttest in your terminal of choice and be surprised, especially by how many of them fail at very basic cursor movement tests. One of the few terminal emulators which gets most things right is xterm. It's also one of the very few terminal emulators which even supports exotic graphics capabilities like Sixel/ReGIS/Tek4014. Nobody should underestimate xterm …
I am not. It makes next to no sense to me. Maybe if you have a highres screen and dedicated VRAM. Otherwise going through the GPU interfacing ceremony just adds overhead.
For the second group, startup perf is everything, because users hit that multiple times a day. For the first group, not so much.
Some of the other tiling functionality is also more helpful for folks that aren't on platforms with as powerful of window managers (macOS, Windows)
Also i'm using xterm and i always found it very fast, i never thought that i'd like a faster terminal.
many modern wm's and terminals have multitab and multiwindow features but i invested time only into learning tmux and i can use it anywhere. and of course nohup functionality is builtin by definition.
i have said it before and i can say it again: terminals come and go, tmux stays.
- Keyboard cut-and-paste. CtlShiftSpace to highlight likely selections, matching letter to cut, shift letter to cut AND paste.
- Built in mosh+tmux-like functionality, but at the GUI level. I do a lot of terminal work at home from my Mac connected to my Linux laptop WezTerm instance, with multiple panes/tabs.It is not an automatic badge of quality for the program itself, but it is an indicator that someone, somewhere is using $LANGUAGE to make a program like that.
It isn't so much promotion for the program itself, but for $LANGUAGE both to attract like-minded programmers who like it as well as show other programmers that $LANGUAGE is using for making things - which perhaps will give them an incentive to check out the language too, if for no other reason than perhaps answering the curiosity some may have about how a program like that is written in that language.
Hacker News is a place full of programmers after all and programmers do tend to care about programming languages and their uses.
Why does the title say "written in rust" then, if not because the author believes it's inherently worthy of merit? It's largely irrelevant to users of the software.
I follow HN mostly through RSS with various filters. Rust is one of the keywords that I follow.
Would you say the same if something was written in FORTRAN, COBOL or assembly?
Why? Because a project written in Rust will certainly be using Cargo for package management, which is absolutely delightful relative to just about any other language’s package manager.
I can git clone and start hacking on just about any Rust project almost immediately. If I’m using 100 tools throughout the day (that’s a conservative estimate) I’d much prefer each of those were written in Rust than C or C++, for instance. Otherwise that’s 100 opportunities for me to find a missing feature or bug and end up futzing with autotools and cmake and ninja and distro-packaged but-not-quite-the-right-version dynamic libraries and broken pkg-config files and and and…
As an example, I recently needed to add support to probe-rs for debugging embedded devices via JTAG with a CMSIS-DAP probe. One git clone and I immediately have all of my dependencies resolved, my editor immediately has go to definition and autocomplete working, and I have a host of debug target definitions for debugging probe-rs itself.
OpenOCD doesn’t support the chip I’m targeting, so if I wanted to use that instead of probe-rs I’d have to first set up a dev env for it and add that support myself. That consists of using a tool like bear to trace the build execution so it can spit out a compile_commands.json file so the C and/or C++ language server can make sense of the project. Oh, and I need to repeat that step if I realize later that I missed a couple defines, otherwise the lang server will think huge swathes of code are preprocessed-out. And this is all after I’ve chased down the myriad of build and runtime dependencies.
I find missing functionality and/or critical show stopping bugs regularly in the tools I use, and it doesn’t matter if the tools are commercially funded or super popular or whatever: I opened an issue for a critical miss-linking problem in Google’s bazel build rules for the Go language, and that’s still open something like 6 years later. And ironically, I discovered the bug while working on a project that uses Go, C++ and C++ protobufs — two of those things are Google inventions, and the other is a predominant language in the Google stack! Their own stuff doesn’t even work together.
So no, it’s not a matter of me choosing bad tools, to be clear. I’m just often put in a position that the best course of action is rolling up my sleeves and fixing whatever issue I’ve discovered.
For someone like me, knowing something is written Rust gives me some peace of mind, knowing that it’ll be (comparatively) easy to work on when I inevitably discover a deficiency. Not because the language is great (though that’s also true), but because the package management simply doesn’t suck.
So please, please stop with the fallacy that “it has no merits on its own”. It does have merits, though maybe you don’t personally appreciate them. And that’s okay. But some of us do appreciate those merits — and they very much unequivocally, objectively are there.
In the case of wezterm, a quick glance shows that not only is this correct (lots of unsafe rust, even beyond the normal use of wrapped functions), there is also not a lot of documentation about what the safety conditions of the various unsafe code is.
(which is the usual good practice in handling this sort of thing).
So to your point, saying it's "written in rust" doesn't matter here.
If the use of GPUs is via CUDA, there are my wrappers [1] which are RAII/CADRe, and therefore less unsafe. And on the Rust side - don't you need a bunch of unsafe code in the library enabling GPU support?
There is lots of "bad" unsafe code that is much worse, and over time, they will have just as much trouble trying to handle this overall as C++ does.
(and no the ability to say you don't want unsafe transitive crates doesn't fix anything)
One thing that put a sour taste in my mouth for WezTerm is they document all escape sequences [0] using a deviation from standard syntax (sometimes using `:` over `;` like for RGB colors, at least I've not found any other documentation about this being commonly adopted). They do put a disclaimer at one point in the document but that only helps if you read it linearly and it feels weird to document your implementation of a standard to only work with your terminal, locking people's applications into it.
As for rendering, I had problems with what look like correct escape sequences not rendering correctly (alternative underline styles, colored underlines). I still need to dig further into this where in the stack the problem is (my application or where in WezTerm)
Using ";" is popular, and some parsers even require it, but it makes little sense. A terminal that doesn't know about 38 (anything old) will interpret that 5 as blink if you use ";", which is not what anyone wants.
The colons are more correct, but the semicolons are seemingly more broadly supported.
That doesn't stop terminals from supporting it of course, just from saying they do.
Where would I find this documented and how broadly is it supported? So far, the most exhaustive documentation I've found is wikipedia [0], vt100 [2], and wezterm with only wezterm talking about this. I also have not seen `:` handled in the various parsers (e.g. `vte` for alacritty) or generators (e.g. `termcolor`) I've looked at.
* via <https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-F...> (search for "CSI Pm m Character Attributes (SGR)"):
If 88- or 256-color support is compiled, the following apply:
[snip]
o The 88- and 256-color support uses subparameters described
in ISO-8613-6 for indexed color. ISO-8613-6 also mentions
direct color, using a similar scheme. xterm supports
that, too.
o xterm allows either colons (standard) or semicolons
(legacy) to separate the subparameters (but after the
first colon, colons must be used).
The indexed- and direct-color features are summarized in the
FAQ, which explains why semicolon is accepted as a
subparameter delimiter:
Can I set a color by its number?
(This links to <https://invisible-island.net/xterm/xterm.faq.html#color_by_n...>.)The `ctlseqs` document continues:
These ISO-8613-6 controls (marked in ECMA-48 5th edition as
"reserved for future standardization") are supported by xterm:
[snip example with colons ":"]
This variation on ISO-8613-6 is supported for compatibility
with KDE konsole:
[snip example with semicolons ";"]
So, the confusion between use of ";" and ":" separators is because the RGB values are not actually parameters (specified as separated by ";"), rather, the RGB values are subparameters (specified as separated by ":"). [Edit #1]This is covered in more detail by <https://invisible-island.net/xterm/xterm.faq.html#color_by_n...> (mentioned above):
We used semicolon (like other SGR parameters) for separating the R/G/B
values in the escape sequence, since a copy of ITU T.416 (ISO-8613-6)
which presumably clarified the use of colon for this feature was costly.
Using semicolon was incorrect because some applications could expect their
parameters to be order-independent. As used for the R/G/B values, that was
order-dependent. The relevant information, by the way, is part of ECMA-48
(not ITU T.416, as mentioned in Why only 16 (or 256) colors?). Quoting from
section 5.4.2 of ECMA-48, page 12, and adding emphasis (not in the
standard):
[snip]
Of course you will immediately recognize that 03/10 is ASCII colon,
and that ISO 8613-6 necessarily refers to the encoding in a parameter
sub-string. Or perhaps you will not.
:D [snip]
Later, in 2012 (patch #282), I extended the parser to accommodate the
corrected syntax. The original remains, simply because of its widespread
use. As before, it took a few years for other terminal developers to
notice and start incorporating the improvement. As of March 2016, not
all had finished noticing.
[snip]
* Going forward (e.g., xterm patch #357), these terminfo building blocks
are used in ncurses:
* xterm+256color2 is the building-block for standard terminals
* xterm+256color is a building-block for nonstandard terminals
It's unfortunately seemingly not possible to directly link to the specific text but hopefully that's enough pointers for people to find it themselves.Once again, seems it's amazing that anything works anywhere. :D
[Edit #1: Corrected from subparameter separator from "," (which is correct for one of the specs I read but incorrect here) to ":".]
[Edit #2: Typo fix.]
https://sw.kovidgoyal.net/kitty/
https://github.com/kovidgoyal/kitty/releases
I used iTerm2 on macOS for many years and still keep it around, but switched to kitty as my daily driver in late 2021 and have been very happy with it.
http://www.9bis.net/kitty/index.html#!index.md
> KiTTY is a fork from version 0.76 of PuTTY
> KiTTY is only designed for the Microsoft® Windows® platform.
I have only one complain: I tried everything to configure it to open in a specific position in the screen (top left corner), and for FSM's sake, It's impossible! (Windows 10)
local wezterm = require("wezterm")
wezterm.on('gui-startup', function(cmd) -- set startup Window position
local tab, pane, window = wezterm.mux.spawn_window(cmd or
{position={x=0,y=0},width=100,height=20}
)
end)I just couldn't stand the petulant attitude of Alacritty's maintaner(s) and it didn't take much to find something else. Although I can't give this for granted now I haven't seen there's the same sort of behavior on WezTerm.
--
0: https://sw.kovidgoyal.net/kitty/conf/#shortcut-kitty.Open-UR...
1: https://wezfurlong.org/wezterm/hyperlinks.html#explicit-hype...
{ key="e", mods="CTRL|ALT", action=wezterm.action{QuickSelectArgs={
patterns={
"http?://\\S+",
"https?://\\S+"
},
action = wezterm.action_callback(function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.open_with(url)
end)
} }
},0: https://sw.kovidgoyal.net/kitty/conf/#shortcut-kitty.Browse-...
It’s a very nice application, easy to configure, very customisable, stable. I’ve only have experienced one bug with app, I opened an issue in GH and Wez had a nightly version with a fix in just a few hours.
If you haven’t check it out yet, I highly recommend it.
This makes it seem pretty squarely targeted at i3/Sway/vim sorts of users, which doesn't make it bad but an odd fit for more general users.
Eventually I uninstalled it and back to iTerm2. Maybe one day I'll learn Lua and use it again.
I don't personally like all of its design decisions, but an Emacs-like vibe really intrigues and attracts me.
I spent ages trying to get Wezterm font rendering to match iTerm2. After spending far too long in the font section of configuration, it turns out this was the solution.
- WezTerm has windows/tabs/panes in it, and one use case would be ~10 panes on a 4K display in various columns/rows.
- Within those you might have applications that themselves have columns/rows of panes, like vim.
- Why not use the GPU to draw the graphics so you can offload the CPU? When there's a lot of text to go through (something scrolling stdout hard, jumping through a big file), the extra performance can be nice.That would be pretty small in modern times. Certainly some people are working with terminals that size, often then spilling out into multiple terminals side by side on the screen, but modern resolutions are good enough to support a lot more text per terminal than that. As a single data point, my half-screen terminal right now is 140x75.
This is basic mechanical sympathy.
A terminal editor needs GPU acceleration for the same reasons any other displayed item needs GPU acceleration.
Fast enough bitmap terminals have existed since the 1980's, and it takes really naive rendering for the rendering to be a bottleneck ever since then. Resolutions have increased, sure, but overall the increase in resolution and colour depth has been slower than the increase in CPU speed.
If you test various terminals, you'll find the difference in throughput is massive and the most popular ones are not necessarily the highest throughput ones, because people rarely run into the use cases where it makes a difference.
(the one step up from naive rendering that makes the most difference: the renderer should run in a separate thread, at most once per frame, and scroll the required number of lines with a single copy - that copy might well be optimised to a blit using the GPU by the X server or whatever, but that's besides the point; do just that and output does not bottleneck on the rendering as long as the renderer can render individual frames fast enough)
In general if GPU style processors had better dev experience, less fragmentation and other chilling effects, we might be running a lot of our software on them for general efficiency.
On Linux, it’s no contest, I love WezTerm over Kitty on Linux and didn’t have any of these issues.
Alacritty and Wezterm have very different--if not opposite--philosophies. Choose Alacritty if you want something simple, fast, focused, done right. Choose WezTerm for flexibility and being a cross-platform environment by itself.
I can't care less about the throughput of a terminal; xterm was fast enough 20 years ago.
that's worse than an electron terminal
something is wrong
2 % tree .
.
└── Contents
├── Info.plist
├── MacOS
│ ├── strip-ansi-escapes
│ ├── wezterm
│ ├── wezterm-gui
│ └── wezterm-mux-server
├── Resources
│ ├── terminal.icns
│ └── wezterm.sh
└── _CodeSignature
└── CodeResources
2 % du -hs Contents/MacOS/*
2.8M Contents/MacOS/strip-ansi-escapes
48M Contents/MacOS/wezterm
119M Contents/MacOS/wezterm-gui
44M Contents/MacOS/wezterm-mux-server
A bit of duplicative bloat, but there's nothing wrong with that for an young project trading a bit of space for an easier build/release process.Unlike other terminal emulators, this project is entirely statically compiled, so the code for the built-in SSH client, serial port support, muxing server/client protocol, shader compilation engines, image decoding libraries, D-BUS clients, threading libraries, HTTP(S) (1.1/2/3) with several types of compression, and of course the GPU shader compilers and APIs.
I built Wezterm on my machine and the binary is about 21MiB in size. About 12MB of that is code, the rest is debug symbols. 2MB of that is the Rust standard library and another 1MB is a LUA runtime. Then there are several image libraries that take about half a megabyte.
The compiled source code itself is only 893KiB in my file. The rest is just dependencies and random ELF segments.
So yes, the terminal emulator is about one Windows 95 installation in size, but that's all quite explainable if you care about the features.
For comparison, I've run `debtree` on gnome-terminal (3.4KiB on disk) and the dependency tree is reported to be 691MiB. Microsoft's Windows Terminal is distributed in 18.6MiB - 66.4MiB (I don't know the compression msixbundles use if any) which is comparable. iTerm2 seems to be about 74MiB decompressed. Even `xterm` (the most barebones terminal emulator I can find) relies on 20MiB of dependencies.
If xterm is all you need, then there's no need to download anything else. If you want more features in a terminal emulator, you're going to have to deal with larger binaries.
On my machine:
* WezTerm 224 MB
* iTerm2 74 MB
* Terminal (default MacOS) 10 MB
And yet, I have read comments proclaiming that iTerm is bloatware.
p.s. I've been using Wezterm for more than a year, and I love it.
The on-disk size != RAM usage, and on-disk size really doesn't matter on modern systems, unless you're on a very resource constrained system, in which case, you probably don't want a feature-heavy GUI anyway.
If you think "but terminal multiplexing and SSH!", then feel free to add 0.9MB for screen (or 1MB for tmux) and 4.8MB for openssh, and you're still way below the size of wezterm.
[nix-shell:~]$ du -hs $(nix-build '<nixpkgs>' -A wezterm)
94M /nix/store/w7hpqwqqp7xq70wjsm8bd1yara0rhk9v-wezterm-20220408-101518-b908e2dd
[nix-shell:~]$ du -hs $(nix-build '<nixpkgs>' -A kitty)
25M /nix/store/9k0jn3219l6l7ywcqyvbifhd38cagfd9-kitty-0.25.2
[nix-shell:~]$ du -hs $(nix-build '<nixpkgs>' -A alacritty)
6.2M /nix/store/cq7zaagwcwn9blynw027bqszhnld2sk2-alacritty-0.10.1
Is the feature set difference between these really that much? At least, between kitty and wezterm?