Live data from Hacker News

We rewrote the Ghostty GTK application

mitchellh.com

81–90 of 228 posts

Re: We rewrote the Ghostty GTK application

#81
post #60

Earlier quoted context omitted.

In general: whenever you call into C, you get all the safety of C, because C code can trivially have memory corruption bugs that corrupt memory "belonging" to Rust as well, inducing undefined behavior across your whole program [0]. In addition, it's often considered permissible for C APIs to exhibit undefined behavior if their API contracts are violated. This means that a bug in Rust code that calls into a C API inco…

> The typical approach to using C libraries from Rust is to create a "safe wrapper" around the unsafe FFI calls that uses Rust's type system and lifetimes to enforce the safety invariants. Calling it a "safe" wrapper, when that safety is entirely dependent on (a) the correctness of the hand-written wrapper, (b) the safety of the underlying FFI code, has always been a huge stretch of terminology. It's more like a veil…

> Rust has no magical ways of turning unsafe code safe

Fully agreed on that -- the unsafe keyword means it's unsafe.

> nor is it in any way special in being able to create statically-verifiable abstractions around an unsafe core.

This isn't really true. Rust's type system has:

- Affine types

- Lifetimes

- Borrowed and exclusive references

- Thread-safety

- Explicit delineation between safe and unsafe code -- with no UB in safe code, and a (cultural) design principle that unsafe code is not allowed to make unchecked assumptions about the behavior of safe code

Most mainstream languages do not have any one of these features, let alone all of them. Thus, Rust's ability to "create statically-verifiable abstractions around an unsafe core" is in practice far more powerful than in C, C++, or Zig. You certainly have the ability to create some such abstractions in other languages, but you cannot statically verify nearly as many properties. (And of course there are languages like SPARK that can verify even more statically than Rust.)

In my experience, as a systems programmer who heavily uses Rust to interact with FFI, hardware MMIO and DMA, interrupt handling, networking code, etc., Rust's ability to safely abstract unsafe primitives is easily the most practically useful aspect of the language. It's not a silver bullet that turns incorrect code into correct code, but it is incredibly good at verifying the correctness of a large application built from small low-level primitives. If you're interfacing with buggy C code, Rust certainly isn't going to help you much -- but it does makes a huge difference in preventing "you're holding it wrong" bugs when interacting with a C API.

An unsafe block declares an axiom: you're asserting to the compiler that you've verified (statically with the type system or dynamically with runtime assertions) all preconditions necessary for some primitive to be sound (free of UB). The compiler can then use that axiom to prove the soundness of all code that interacts with that primitive. When I write a driver to perform a DMA transfer, I only have to think through all the concurrency, alignment, lifetime, moveability, caching, and cancellation requirements once, and the compiler will check them for me every time I (or anyone else) use that driver in an application.

Re: We rewrote the Ghostty GTK application

#83
post #6

> Whatever your feelings are about OOP and memory management, the reality is that if you choose GTK, you're forced into interfacing in some way with the GObject type system. You can't avoid it. In the past this has also been my assessment of GTK. It lead me to decide to take the other path, to never directly use GTK. I appreciate the value in having a unified user interface between applications, but I have always tho…

In my view the primary reason for GTK’s prominence on Linux rides on one thing primarily: it’s got C bindings , and thus it has decent bindings for just about every other language under the sun too. If you’re not trying for anything fancy, these bindings can even be auto-generated. The runner up Qt is much more tightly tied to C++ and Python to its detriment. You really need to meet devs where they’re at instead of i…

Qt licensing is annoying, GTK has its downsides.

So we are left with Electron…

Re: We rewrote the Ghostty GTK application

#85
post #79

Biggest issue I have with Ghostty is that on the mac with Nano.. you can't copy and paste multiple lines into the editor. It's something about how the terminal handles "bracketed pasting".. but yet this isn't an issue with iterm2 and term.

This could be a valid bug that you can report

Re: We rewrote the Ghostty GTK application

#86
post #83

Earlier quoted context omitted.

In my view the primary reason for GTK’s prominence on Linux rides on one thing primarily: it’s got C bindings , and thus it has decent bindings for just about every other language under the sun too. If you’re not trying for anything fancy, these bindings can even be auto-generated. The runner up Qt is much more tightly tied to C++ and Python to its detriment. You really need to meet devs where they’re at instead of i…

Qt licensing is annoying, GTK has its downsides. So we are left with Electron…

Aren't GTK and Qt (community edition) both LGPL (though different versions)?

So Electron does not have downsides? Like far worse platform integration.

Re: We rewrote the Ghostty GTK application

#87
post #79

Biggest issue I have with Ghostty is that on the mac with Nano.. you can't copy and paste multiple lines into the editor. It's something about how the terminal handles "bracketed pasting".. but yet this isn't an issue with iterm2 and term.

I've used Ghostty as my default terminal since I set up my new computer a couple of months ago. The only issue I have is the missing search which I often reach for to look through output that I didn't pipe anywhere.

Bit it's also the most mentioned issue: https://github.com/ghostty-org/ghostty/issues/189

Re: We rewrote the Ghostty GTK application

#88
post #79

Biggest issue I have with Ghostty is that on the mac with Nano.. you can't copy and paste multiple lines into the editor. It's something about how the terminal handles "bracketed pasting".. but yet this isn't an issue with iterm2 and term.

No command f is the killer for me

Re: We rewrote the Ghostty GTK application

#89
Fun fact. In Ghostty and (some) other GTK apps, if your mouse leaves the window, the first scroll click after re-entering the window is ignored. This is due to an ancient bug first identified in 2015.

https://bugzilla.gnome.org/show_bug.cgi?id=750994

There are no plans for a fix. The maintainer recommends waiting for Wayland.

Re: We rewrote the Ghostty GTK application

#90
post #74

Earlier quoted context omitted.

Can you do that on Windows/mac? Gnome devs not withstanding, you have access to the source to change it if you want or put up a PR?

You can't put up a PR if the gate keepers reject your whole design approach

As a gatekeeper in an unrelated small project, I understand gatekeepers being selective. You have a vision, design standards, quality standards. Drive-by PRs that add "just this one thing I need" features is how your well-designed, cohesive project becomes a kitchen sink of shit.
Post reply on HN