|
|
Warp wrote:
> There aren't many programming languages out there which would allow the
> same kind of "controlled compiler abuse" as C, which is precisely why it's
> so popular to write kernels and device drivers.
True, but there are a number that do. :-) Most people don't need controlled
abuse.
> but right now I can't say what other languages have been used to write
> kernels.
Well, Ada is high on the list, as is FORTH. Algol was used for the B-series
from Burroughs. That's why I mentioned them.
> Sometimes you just have to. No programming language can account for every
> single feature a kernel needs. Sometimes you just *must* bypass the standard
> language and poke the hardware directly.
Sure. But, for example, take a look at the list of things that Ada defines
how to do that C doesn't that would be useful for kernels:
Interrupt hooking, interrupt prioritization, interrupt disabling while
running a higher-priority interrupt. Packed structures where you can define
what and where every bit goes. Switching stacks (as in, context switching).
Atomically writing to memory-mapped hardware. Test-and-set. Dynamically
loading code and then executing it. Mapping data structures to particular
addresses. Well-defined language structures for inline assembler. Plus
everything C++ does (including interfacing to other calling conventions)
except maybe turing complete templates. :-)
Oh, and I think it handles segmented memory, but I might be mistaken there.
Sure, if you need to invoke some magic opcode to blink the front panel
lights, it's going to be really hard to make that portable. But you can do a
lot better than C does. Of course, Ada has another 25 years of experience
on C, so it's not really a fair comparison.
I really think C got off the ground just by being used for the first
portable kernel. The same as FORTRAN still being tops in numeric analysis
because it had the first portable numeric analysis libraries.
> The only other alternative would be to write the kernel in assembly, which
> would be enormously less portable and less manageable than C.
As I said, lots of kernels are written in FORTH (for small machines) or Ada
(for dangerous machines).
--
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
|
|