|
|
Warp wrote:
> Because C allows many types of low-level optimization that are very
> difficult, if not even outright impossible, in higher-level languages.
> For example, you know how a C struct will map onto memory locations,
> on every possible platform which your kernel can be compiled for.
Not in a portable way. You don't know what kinds of padding happen, or what
order the integers are in.
> You know
> exactly what assigning one struct instance to another entails as machine
> code.
That's true of lots of low-level languages too. FORTH and Ada both spring to
mind, for example. Lots of languages of the same ilk have instructions for
laying out structures at a per-byte level. (Erlang? Modula-whatever?)
> If you need a pointer which should point to a raw memory address,
> you can create one.
Not in C. Only in some language that looks like C but invoked undefined
behavior.
> You can be sure that something like garbage collection
> will *not* suddenly and unexpectedly kick in during a highly-critical
> operation.
True, but there are lots of languages I consider better than C (as in, more
powerful) that don't have GC. Anything with managed memory is going to be a
mess for writing kernel code in, I'll grant you. :-) At least for a general
kernel where you can't control what else runs.
> If needed, you can even write inline-asm for things which cannot
> be done in C directly (eg. write or read from ports, issue some exotic CPU
> commands such as disabling interrupts, etc).
But not in C. That's kind of my point. There's whole bunches of stuff that
happen in kernels that C just doesn't define, just like this.
> And of course C allows for programmatical optimizations which can often
> be difficult in higher-level languages. Memory usage optimization would be
> the main example.
I'm not sure what that means. If I have an array of 12-bit values in C,
that's a PITA to implement compared to a lot of other languages (including C++).
--
Darren New, San Diego CA, USA (PST)
"We'd like you to back-port all the changes in 2.0
back to version 1.0."
"We've done that already. We call it 2.0."
Post a reply to this message
|
|