Date: Fri, 13 Sep 2024 01:12:51 -0700 From: Yuri <yuri@freebsd.org> To: Alan Somers <asomers@freebsd.org> Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: The Case for Rust (in any system) Message-ID: <14f3272c-e677-4e16-886a-28ab24631373@freebsd.org> In-Reply-To: <CAOtMX2i0ANKaYmXskrhqd6b0B0=jMQYmOwonwE8ciJthLJe3Aw@mail.gmail.com> References: <CAOtMX2iCNX5OkdeghnbmcMrO0UYWwm4zfxFSZGznOznu%2Bmh5rA@mail.gmail.com> <0c2493a5-4b1b-4d88-b44a-c725c957ecdc@FreeBSD.org> <CAOtMX2i0ANKaYmXskrhqd6b0B0=jMQYmOwonwE8ciJthLJe3Aw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Alan, On 9/12/24 14:52, Alan Somers wrote: > Thank you! This is some of the best criticism I've seen so far. Thanks! > No doubt Yuri already knows the following, but I'll explain it for > other readers' sake. I too have used to use exceptions in C++, Java, > Python, and Ruby. The problem with exceptions is that you can never > know what errors your function might have to deal with. You can add > error handling for every exception type that you know about, but > there's nothing to prevent some lower-level library function from > throwing an entirely new exception that you've never heard of. When > that happens, your program will crash with "uncaught exception". The > problem is worst in Python, but it affects C++, too. C++'s solution to > that problem was checked exceptions. A function would document in its > signature all of the exception types that it might throw, and the > compilation will fail if the code attempts to throw any new ones. That > way, consumers could be confident that they could handle all possible > errors. The problem with this approach is that lower-level libraries > frequently added new exception types, with the result that their > consumers' builds would frequently fail. That's why C++11 deprecated > checked exceptions. Unknown exception types are actually not a problem in practice, as long as all exception types inherit from std::exception. Then you just catch that type as a fallback for all known exception types. > Like Yuri I've used Ratatui in Rust. But unlike Yuri I haven't > written any TUIs in C or C++. For my education, could you point me to > some examples? Something that FTXUI is particularly good at? There are several FTXUI based projects among ports: misc/json-tui, devel/git-tui, misc/rgb-tui. Many other examples are listed here: https://github.com/ArthurSonzogni/FTXUI?tab=readme-ov-file#project-using-ftxui Cheers, Yuri
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14f3272c-e677-4e16-886a-28ab24631373>