public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakob Oestergaard <jakob@unthought.net>
To: Martin Brulisauer <martin@uceb.org>
Cc: Joshua MacDonald <jmacd@namesys.com>,
	neilb@cse.unsw.edu.au, linux-kernel@vger.kernel.org
Subject: Re: type safe lists (was Re: PATCH: type safe(r) list_entry repacement: generic_out_cast)
Date: Wed, 24 Jul 2002 13:58:50 +0200	[thread overview]
Message-ID: <20020724115850.GS11081@unthought.net> (raw)
In-Reply-To: <3D3EA294.30758.3567B82@localhost>

On Wed, Jul 24, 2002 at 12:50:28PM +0200, Martin Brulisauer wrote:
...
> So it is.
> 
> At kernel level nothing will stop me to halt() the cpu, if I realy want 
> to. It is important to understand that tools (and all compilers are
> just tools) will not enable me to write correct code. 

That is a lame argument.

We've just seen that very competent people can make really silly
mistakes because of generic code without type safety.

*IF* the code had type safety, such silly mistakes would be caught at
compile time.

Now there are arguments for and against implementations such as the type
safe list implementation.  But an argument against type-safety is
rediculous.  If the language does not allow for type safety in any
convenient manner, so be it, but type-safety really is useful for
avoiding silly mistakes, and this should be exploited whenever the
language (and clever *use* of the language) allows for it.

> > 
> > I can say a lot of good and bad things about C++, but at least it lets you do
> > this kind of thing with type safety and without ugly macros.
> > 
> Yes. That's absolutely true for C++. But the kernel is implemented 
> in C and C is "only" kind of a high-level-assembler language. It is

No, C has types.  It is not just portable assembly.

Why do you think it allows for typed pointers and not just void* or
even long?

> ment to be open - on purpose. There exist other languages that 
> have these kinds of concepts you bring in (I would not use C++ as 
> the best example - take OBERON/MODULA or EIFFEL). But these 
> languages are not made to implement an operating system 
> (remember the reason K&R have specified and implemented C?).

Wrong.  Look at Atheos for an example.  There is *nothing* you can do in
C that you cannot do in C++ with equal or better performance (there is C
code that is not valid C++, but it's small semantic details and scope
rules, re-writing is simple).

But this is of course irrelevant, as there are other good reasons for
not rewriting the kernel in any other language.

> 
> What I realy dislike is the approach to bring in any OO concepts 
> into the C language the linux kernel bases on. Keep the code as 
> simple and homogenous as possible (or try to rewrite it in OO).

Who is talking about OO ???

What Joshua presented is a C implementation of a list using
parameterized types using macros (instead of templates as could have
been used in C++).  Parameterized types has nothing what so ever in any
way to do with OO  (it goes well with some OO concepts, but that's an
entirely different story).

> 
> The way I see this discussion is: Every software problem has it's 
> proper language to be solved in. And for this, Linus decided it to be 
> C.

Yes. And I think that was a very clever decision - even if there had
been proper C++ compilers at the time (which there wan't, because the
language wasn't even standardized until 1998).

But did Linus decide to use "crappy C" or "error-prone C", or is there
some chance that the most generic code could perhaps be implemented in
"robust C" ?

Macros are not a pretty solution, but it is as I see it the only way to
achieve type safety in generic code.  If someone else out there has
other suggestions, please let me know - I actually like to be proven
wrong (because that means I learn something new).

I'd take macro-hell in generic code over void* hell in every single
list-using part of the kernel any day.

-- 
................................................................
:   jakob@unthought.net   : And I see the elder races,         :
:.........................: putrid forms of man                :
:   Jakob Østergaard      : See him rise and claim the earth,  :
:        OZ9ABN           : his downfall is at hand.           :
:.........................:............{Konkhra}...............:

  reply	other threads:[~2002-07-24 11:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-23 11:28 PATCH: type safe(r) list_entry repacement: generic_out_cast Neil Brown
2002-07-23 11:47 ` Jakob Oestergaard
2002-07-23 22:07   ` type safe lists (was Re: PATCH: type safe(r) list_entry repacement: generic_out_cast) Joshua MacDonald
2002-07-24  7:39     ` Martin Brulisauer
2002-07-24  8:24       ` Anton Altaparmakov
2002-07-24  9:56       ` Joshua MacDonald
2002-07-24 10:50         ` Martin Brulisauer
2002-07-24 11:58           ` Jakob Oestergaard [this message]
2002-07-24 16:49             ` John Alvord
2002-07-25  5:29       ` Greg KH
2002-07-25  6:20         ` Roland Dreier
2002-09-04 13:48         ` Alexander Kellett
2002-09-04 14:27           ` DervishD
2002-07-24 12:22     ` Jakob Oestergaard
2002-07-24 12:40       ` Joshua MacDonald
2002-07-24 15:15         ` Hans Reiser
2002-07-23 12:42 ` PATCH: type safe(r) list_entry repacement: generic_out_cast Brian Gerst
2002-07-23 16:29 ` Linus Torvalds
2002-07-24  5:25   ` Thunder from the hill
2002-07-23 16:36 ` Christoph Hellwig
2002-07-23 22:58 ` Kevin O'Connor
2002-07-24 12:38 ` PATCH - mark 2: type safe(r) list_entry repacement: container_of Neil Brown
     [not found] <20020723114703.GM11081@unthought.net.suse.lists.linux.kernel>
     [not found] ` <3D3E75E9.28151.2A7FBB2@localhost.suse.lists.linux.kernel>
2002-07-24 13:23   ` type safe lists (was Re: PATCH: type safe(r) list_entry repacement: generic_out_cast) Andi Kleen
2002-07-24 21:00     ` Linus Torvalds
2002-07-24 23:39       ` Jamie Lokier

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=20020724115850.GS11081@unthought.net \
    --to=jakob@unthought.net \
    --cc=jmacd@namesys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@uceb.org \
    --cc=neilb@cse.unsw.edu.au \
    /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