From: "J.A. Magallón" <jamagallon@ono.com>
To: "Loïc Grenié" <loic.grenie@gmail.com>
Cc: Ben.Crowhurst@stellatravel.co.uk, linux-kernel@vger.kernel.org
Subject: Re: Kernel Development & Objective-C
Date: Sat, 1 Dec 2007 00:19:50 +0100 [thread overview]
Message-ID: <20071201001950.11100a32@werewolf> (raw)
In-Reply-To: <9b06e8d20711300229r1ed570bfi9ecbb6466fd0a0ab@mail.gmail.com>
On Fri, 30 Nov 2007 11:29:55 +0100, "Loïc Grenié" <loic.grenie@gmail.com> wrote:
> 2007/11/29, Ben Crowhurst <Ben.Crowhurst@stellatravel.co.uk>:
> > Has Objective-C ever been considered for kernel development?
> >
> > regards,
> > BPC
>
Well, I really would like to learn some things here, could we
keep this off-topic thread alive just a bit, please ?
(I know, I'm going to gain a troll's fame because I can't avoid this
discussions, its one of my secret vices...)
> No, it has not. Any language that looks remotely like an OO language
> has not ever been considered for (Linux) kernel development and for
> most, if not all, other operating systems kernels.
>
I think BeOS was C++ and OSX is C+ObjectiveC (and runs on an iPhone).
Original MacOS (fron 6 to 9) was Pascal (and a mac SE was very near
to embedded hardware :) ).
I do not advocate to rewrite Linux in C++, but don't say a kernel written
in C++ can not be efficient.
> Various problems occur in an object oriented language. One of them
> is garbage collection: it provokes asynchronous delays and, during
> an interrupt or a system call for a real time task, the kernel cannot
> wait.
C++ (and for what I read on other answer, nor ObjectiveC) has no garbage
collection. It does not anything you did not it to do. It just allows
you to change this
struct buffer *x;
x = kmalloc(...)
x->sz = 128
x->buff = kmalloc(...)
...
kfree(x->buff)
kfree(x)
to
struct buffer *x;
x = new buffer(128); (that does itself allocates x->buff,
because _you_ programmed it,
so you poor programmer don't forget)
...
delete x; (that also was programmed to deallocate
x->buff itself, sou you have one less
memory leak to worry about)
> Another is memory overhead: all the magic that OO languages
> provide take space in memory and Linux kernel is used in embedded
> systems with very tight memory requirements.
>
An vtable in C++ takes exactly the same space that the function
table pointer present in every driver nowadays... and probably
the virtual method call that C++ does itself with
thing->do_something(with,this)
like
push thing
push with
push this
call THING_vtable+indexof(do_something) // constants at compile time
is much more efficient that what gcc can mangle to do with
thing->do_something(with,this,thing)
push with
push this
push thing
get thing+offsetof(do_something) // not constant at compile time
dereference it
call it
(that is, get a generic field on a structure and use it as jump address)
In short, the kernel is object oriented, implements OO programming by
hand, but the compiler lacks the knowledge that it is object oriented
programming so it could do some optimizations.
> Lots of people will think of better reasons why ObjC is not used...
People usually complains about RTTI or exceptions, but benefits versus
memory space should be seriously considered (sure there is something
in current drivers to ask 'are you a SATA or an IDE disk?').
--
J.A. Magallon <jamagallon()ono!com> \ Software is like sex:
\ It's better when it's free
Mandriva Linux release 2008.1 (Cooker) for i586
Linux 2.6.23-jam03 (gcc 4.2.2 (4.2.2-1mdv2008.1)) SMP Sat Nov
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
next prev parent reply other threads:[~2007-11-30 23:20 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 12:14 Kernel Development & Objective-C Ben Crowhurst
2007-11-30 10:02 ` Xavier Bestel
2007-11-30 10:09 ` KOSAKI Motohiro
2007-11-30 10:20 ` Xavier Bestel
2007-11-30 10:54 ` Jan Engelhardt
2007-11-30 14:21 ` David Newall
2007-11-30 23:31 ` Bill Davidsen
2007-11-30 23:40 ` Alan Cox
2007-12-01 0:05 ` Arnaldo Carvalho de Melo
2007-12-01 18:27 ` Bill Davidsen
2007-12-01 18:18 ` Alan Cox
2007-12-03 1:23 ` Bill Davidsen
2007-11-30 22:52 ` J.A. Magallón
2007-11-30 10:29 ` Loïc Grenié
2007-11-30 11:16 ` Ben Crowhurst
2007-11-30 11:36 ` Karol Swietlicki
2007-11-30 14:37 ` Lennart Sorensen
2007-12-08 8:54 ` Rogelio M. Serrano Jr.
2007-11-30 23:19 ` J.A. Magallón [this message]
2007-11-30 23:53 ` Nicholas Miell
2007-12-01 0:31 ` Al Viro
2007-12-01 0:34 ` Al Viro
2007-12-01 1:09 ` J.A. Magallón
2007-12-01 19:55 ` Avi Kivity
2007-12-04 17:54 ` Lennart Sorensen
2007-12-04 21:10 ` Avi Kivity
2007-12-04 21:24 ` J.A. Magallón
2007-11-30 11:37 ` Matti Aarnio
2007-11-30 14:34 ` Lennart Sorensen
2007-11-30 15:26 ` Kyle Moffett
2007-11-30 18:40 ` H. Peter Anvin
2007-11-30 19:35 ` Kyle Moffett
2007-12-01 20:03 ` Avi Kivity
2007-12-02 19:01 ` Andi Kleen
2007-12-03 5:12 ` Avi Kivity
2007-12-03 9:50 ` Andi Kleen
2007-12-03 11:46 ` Avi Kivity
2007-12-03 11:50 ` Andi Kleen
2007-12-03 21:13 ` Willy Tarreau
2007-12-03 21:39 ` J.A. Magallón
2007-12-03 21:57 ` Alan Cox
2007-12-04 21:47 ` J.A. Magallón
2007-12-04 22:20 ` Diego Calleja
2007-12-05 10:59 ` Giacomo A. Catenazzi
2007-12-04 21:07 ` Avi Kivity
2007-12-04 22:43 ` Willy Tarreau
2007-12-05 17:05 ` Micro vs macro optimizations (was: Re: Kernel Development & Objective-C) Avi Kivity
2007-12-03 12:35 ` Kernel Development & Objective-C Gilboa Davara
2007-12-03 12:44 ` Gilboa Davara
2007-12-03 16:28 ` Casey Schaufler
2007-12-04 17:50 ` Lennart Sorensen
2007-12-05 10:31 ` Gilboa Davara
2007-12-01 19:59 ` Avi Kivity
2007-12-02 19:44 ` Jörn Engel
2007-12-03 16:53 ` Lennart Sorensen
2007-11-30 15:00 ` Chris Snook
2007-12-01 9:50 ` David Newall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071201001950.11100a32@werewolf \
--to=jamagallon@ono.com \
--cc=Ben.Crowhurst@stellatravel.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=loic.grenie@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox