From owner-freebsd-hackers@FreeBSD.ORG Tue Jul 11 15:22:47 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF3FE16A4DD for ; Tue, 11 Jul 2006 15:22:47 +0000 (UTC) (envelope-from joerg@britannica.bec.de) Received: from hydra.bec.de (www.ostsee-abc.de [62.206.222.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A74043D64 for ; Tue, 11 Jul 2006 15:22:47 +0000 (GMT) (envelope-from joerg@britannica.bec.de) Received: from britannica.bec.de (storm.stura.uni-rostock.de [139.30.252.72]) by hydra.bec.de (Postfix) with ESMTP id 4CC6235707 for ; Tue, 11 Jul 2006 17:22:43 +0200 (CEST) Received: by britannica.bec.de (Postfix, from userid 1000) id 223976CFD6; Tue, 11 Jul 2006 17:22:31 +0200 (CEST) Date: Tue, 11 Jul 2006 17:22:31 +0200 From: Joerg Sonnenberger To: freebsd-hackers@freebsd.org Message-ID: <20060711152231.GB1487@britannica.bec.de> Mail-Followup-To: freebsd-hackers@freebsd.org References: <84dead720607092015q7f1701abse143f3855c2aa95a@mail.gmail.com> <1152540567.99616@origin.intron.ac> <44B2AE69.4080703@elischer.org> <44B2D2DF.2000401@sh.cvut.cz> <86sll8zl9x.fsf@xps.des.no> <86fyh8zgw8.fsf@xps.des.no> <868xn0z8w9.fsf@xps.des.no> <1152629241.24779@origin.intron.ac> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1152629241.24779@origin.intron.ac> User-Agent: Mutt/1.5.11 Subject: Re: kern/99979: Get Ready for Kernel Module in C++ X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jul 2006 15:22:48 -0000 On Tue, Jul 11, 2006 at 10:45:52PM +0800, mag@intron.ac wrote: > Just as you said, C++ is more complicated than C. However, without > C++ exception and other advanced features, it hasn't brought much > complexity to C++ runtime library. Early C++ compiler even translates > C++ code into C code before real compilation. RTTI, allocation, exceptions and static allocators all add complexity for the runtime library. If you really want to use C++ for a kernel, you must likely want to use all of them as well. > For example, I think C++ exception handling is really poorly suited for > low-level code. Bullshit. With a proper implementation exceptions add no overhead as long an exception is not thrown in terms of speed. It does matter somewhat in terms of code (or better: data) size, but the very same information is useful to generate much better tracebacks as well. RTTI is highly useful for debugging and semi-optional consistent checks, which should not be neglected either. I don't care about the abuse of explicitly comparing object types etc., but the ability to decide what exactly a certain object is. > But the "object model" is still obscure to understand no matter how many > people all over the world master C++. What's more, can the "object model" > function really as OpenDarwin's IOKit class model? > (http://developer.apple.com/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/HelperClassesChart/chapter_12_section_1.html) The kobj implementation has the same feature set as a lightweight C++, e.g. inheritance and virtual functions. That's basically what IOKit is using as well. It is not obscure, just a Domain Specific Language. > Now, OpenDarwin has owned a C++-based kernel object model. But why > cannot FreeBSD? Because the kernel is C and not many points to incrementally add C++ have been made, which makes it a worthwhile goal. And if you want to complain about redundancy in drivers, carefully look for differences which often far outweight the common functionality. Joerg