From nobody Fri Sep 13 08:12:51 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X4n9f4rxgz5WL3t for ; Fri, 13 Sep 2024 08:12:54 +0000 (UTC) (envelope-from yuri@freebsd.org) Received: from shell1.rawbw.com (shell1.rawbw.com [198.144.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id 4X4n9f26xmz4ZyT; Fri, 13 Sep 2024 08:12:54 +0000 (UTC) (envelope-from yuri@freebsd.org) Authentication-Results: mx1.freebsd.org; none Received: from [192.168.5.3] (c-98-42-44-116.hsd1.ca.comcast.net [98.42.44.116]) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 48D8Cr26019313 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 13 Sep 2024 01:12:53 -0700 (PDT) (envelope-from yuri@freebsd.org) X-Authentication-Warning: shell1.rawbw.com: Host c-98-42-44-116.hsd1.ca.comcast.net [98.42.44.116] claimed to be [192.168.5.3] Message-ID: <14f3272c-e677-4e16-886a-28ab24631373@freebsd.org> Date: Fri, 13 Sep 2024 01:12:51 -0700 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: The Case for Rust (in any system) To: Alan Somers Cc: FreeBSD Hackers References: <0c2493a5-4b1b-4d88-b44a-c725c957ecdc@FreeBSD.org> Content-Language: en-US From: Yuri In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:7961, ipnet:198.144.192.0/23, country:US] X-Rspamd-Queue-Id: 4X4n9f26xmz4ZyT 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