From owner-freebsd-current@FreeBSD.ORG Sun Feb 15 18:53:41 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94DD11065673 for ; Sun, 15 Feb 2009 18:53:41 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id C10A88FC1D for ; Sun, 15 Feb 2009 18:53:40 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from porto.topspin.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id UAA21633; Sun, 15 Feb 2009 20:53:36 +0200 (EET) (envelope-from avg@icyb.net.ua) Received: from localhost.topspin.kiev.ua ([127.0.0.1] helo=edge.pp.kiev.ua) by porto.topspin.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1LYm7U-0003BX-4j; Sun, 15 Feb 2009 20:53:36 +0200 Message-ID: <499864AD.8070105@icyb.net.ua> Date: Sun, 15 Feb 2009 20:53:33 +0200 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.19 (X11/20090114) MIME-Version: 1.0 To: Marcel Moolenaar References: <4995BB1B.7060201@icyb.net.ua> <20090213231513.GA20223@duncan.reilly.home> <4997F105.5020409@icyb.net.ua> <499811DF.6030905@incunabulum.net> <20090215151318.0d17bfb9@ernst.jennejohn.org> <499835BE.3000705@gmx.de> <8EF8771C-76D8-4556-96B2-B97B35573CBD@mac.com> In-Reply-To: <8EF8771C-76D8-4556-96B2-B97B35573CBD@mac.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: Re: weeding out c++ keywords from sys/sys X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Feb 2009 18:53:41 -0000 on 15/02/2009 19:50 Marcel Moolenaar said the following: > > On Feb 15, 2009, at 7:33 AM, Christoph Mallon wrote: >> More robust error handling and less tedious resouce management >> directly come to mind: >> Just look at normal C functions which allocate resources and have >> multiple points which can fail. They are the usual mess of if()s, goto >> error and lots of cleanup code. Further all this code looks pretty >> much the same in several modules. In C++ you write the resource >> handling code once (constructors/destructors) and then you cannot >> forget to clean up, because thanks to scoping and defined life ranges >> it happens automatically. > > While on the surface this looks better, under the hood > it's just the same. Worse in most likelihood, because > with C the programmer writes the logic that is known to > be needed (assuming no bugs). With C++ it's the compiler > that generates code that handles all possible scenarios, > and goes beyond what is strictly needed -- as such the > cost tends to be higher, even when there are no errors > or exceptions. Then maybe we should stick to assembly? Just thinking about how I have two use two operators "/", "%" where I can do with only one x86 assembly instruction makes me mad - not. I.e. this is not to say that I am against assembly - there are many places in our kernel that would be plain impossible to code with C. And not to say that I am against C. This is only to say that there are certain things that are much easier, and safer too, to code in C++ that in C. And that might be in kernel too. > I'm not saying this is a problem. All I'm saying is that > you move responsibility from the programmer to the compiler > and in general this comes at a (runtime_ cost. One we may > very well accept, mind you... > -- Andriy Gapon