From: Bill Cunningham on
One reason why I am so attracted to C and not just markup languages
scripts and java is that C is for designing OS's. What exactley is it about
C that makes it good to right operating systems?

Bill


From: Beej Jorgensen on
Bill Cunningham <nospam(a)nspam.invalid> wrote:
> One reason why I am so attracted to C and not just markup languages
>scripts and java is that C is for designing OS's. What exactley is it about
>C that makes it good to right operating systems?

http://en.wikipedia.org/wiki/C_(programming_language)#Uses

http://answers.yahoo.com/question/index?qid=20071224070810AAUrfuP

HTH,
-Beej

From: Pascal J. Bourguignon on
"Bill Cunningham" <nospam(a)nspam.invalid> writes:

> One reason why I am so attracted to C and not just markup languages
> scripts and java is that C is for designing OS's. What exactly is it about
> C that makes it good to write operating systems?

Nothing. Well, historical accident.
Well, apart from the fact that it was developed to write unix.

First, you should keep in mind that operating systems have been
written in a lot of other programming languages, either assembler or
high level programming languages. C is not the best system
programming language, far from it.

It just happened as an accident of history, that at a certain time in
the end of the sixties and beginning of the seventies, appeared cheap
and limited computers. Memory and processor speed was reduced on
these "mini" computers, but it allowed them to be of a price more
accessible.

Therefore, while on the big and expensive computers, people had
started to write operating systems in high level programming languages
(eg. Multics in PL/1), on the PDP/10 Thompson, Richie and Kerningham
had, there wasn't enough resources to run a high level programming
language compiler. So they started to write unix in assembler. Of
course, it is not very funny to write a lot of code in assembler, so
they designed an assembler of slightly higher level, called B, and
then made it evolve to C, as they got more powerful computers, such as
the PDP/11.

Nowadays, computers are millions of times more powerful (both in
memory, processing speed and communication speed (Internet)), so that
the requirement for a small OS is totally obsolete (for both
workstations and embedded computers such as in GSM phones, even the
processors in your phone is millions of times more powerful than the
computers on which unix was developed!).



Now the general belief is that C is good for OS because it has bit
manipulation instructions, and allows you to access the hardware
registers of the computer.

But other programming languages have good bit manipulation primitives
too, and the C language doesn't allow you actually to access hardware
registers. If you read closely the C standard, you'll see that
there's no standard way to access random memory addresses, or for
example ix86 I/O port (using the INP and OUT instructions). It's even
much less possible in C to access the status register, whose
manipulation is essential when you write an operating system.

For all these low level processor and hardware accesses, you have to
use assembler, even when you're programing the rest in C, like in most
other programming languages. Even something as fundamental as the
system calls, just cannot be programmed in C, you have to write the
syscalls in assembler, because they are not a normal "jump subroutine"
instruction.


Therefore C offers no advantage to other high level programming
language for operating system programming. (Actually, C offers no
advantage whatsoever, it's just an error. See
http://www.netjeff.com/humor/item.cgi?file=c.hoax.txt ;-))


If you want to write an operating system, I'd advise Common Lisp,
Scheme, Modula-3, Oberon, Haskell, or design your own high level
programming language like BitC (http://www.bitc-lang.org/) in the
CoyotOS project (http://www.coyotos.org).

--
__Pascal Bourguignon__
From: bartc on

"Pascal J. Bourguignon" <pjb(a)informatimago.com> wrote in message
news:878wdgiedq.fsf(a)galatea.local...
> "Bill Cunningham" <nospam(a)nspam.invalid> writes:
>
>> One reason why I am so attracted to C and not just markup languages
>> scripts and java is that C is for designing OS's. What exactly is it
>> about
>> C that makes it good to write operating systems?
>
> Nothing. Well, historical accident.
> Well, apart from the fact that it was developed to write unix.
....
> Therefore, while on the big and expensive computers, people had
> started to write operating systems in high level programming languages
> (eg. Multics in PL/1), on the PDP/10 Thompson, Richie and Kerningham
> had, there wasn't enough resources to run a high level programming
> language compiler.

I know little about this history, but I do know the PDP10 was rather more
powerful than that, unless someone forgot to add some memory. I think it was
a different PDP.

> Nowadays, computers are millions of times more powerful (both in
> memory, processing speed and communication speed (Internet)), so that
> the requirement for a small OS is totally obsolete (for both
> workstations and embedded computers such as in GSM phones, even the
> processors in your phone is millions of times more powerful than the
> computers on which unix was developed!).

That might be true, but I remember having some trouble connecting my phone
to a few hundred timesharing terminals, magtape units and lineprinter (in
fact it has enough trouble just turning on, taking a couple of minutes to do
so).

> If you want to write an operating system, I'd advise Common Lisp,
> Scheme, Modula-3, Oberon, Haskell, or design your own high level
> programming language like BitC (http://www.bitc-lang.org/)

"The BitC bootstrap compiler compiles to portable ANSI C code." Seems like
you can't get away from C really.

--
Bartc

From: Pascal J. Bourguignon on
"bartc" <bartc(a)freeuk.com> writes:

> "Pascal J. Bourguignon" <pjb(a)informatimago.com> wrote in message
> news:878wdgiedq.fsf(a)galatea.local...
>> "Bill Cunningham" <nospam(a)nspam.invalid> writes:
>>
>>> One reason why I am so attracted to C and not just markup languages
>>> scripts and java is that C is for designing OS's. What exactly is
>>> it about
>>> C that makes it good to write operating systems?
>>
>> Nothing. Well, historical accident.
>> Well, apart from the fact that it was developed to write unix.
> ...
>> Therefore, while on the big and expensive computers, people had
>> started to write operating systems in high level programming languages
>> (eg. Multics in PL/1), on the PDP/10 Thompson, Richie and Kerningham
>> had, there wasn't enough resources to run a high level programming
>> language compiler.
>
> I know little about this history, but I do know the PDP10 was rather
> more powerful than that, unless someone forgot to add some memory. I
> think it was a different PDP.

Ah, right! It was a PDP-7. Sorry for the confusion.


>> Nowadays, computers are millions of times more powerful (both in
>> memory, processing speed and communication speed (Internet)), so that
>> the requirement for a small OS is totally obsolete (for both
>> workstations and embedded computers such as in GSM phones, even the
>> processors in your phone is millions of times more powerful than the
>> computers on which unix was developed!).
>
> That might be true, but I remember having some trouble connecting my
> phone to a few hundred timesharing terminals, magtape units and
> lineprinter (in fact it has enough trouble just turning on, taking a
> couple of minutes to do so).

It's a question of software, not of hardware. If your phone doesn't
have wifi, you could use bluetooth at 140 KB/s to connect to a
terminal dispatcher and implement a time-sharing system in its 512 MB
of RAM and 400 MHz of processor to deal with user requests on
thousands of terminals. These users, as long as they'd be cryogenized
in the 60's would be bewildered by the power of that time sharing
computer system, providing then each with more RAM than they had hard
disk space, and more flash disk space (32 GB/1000 = 320 MB each) then
they'd ever seen in their previous life.

Of course, we don't do that because we could for a hundredth of the
price of the terminals, dispatcher and software, give each of them one
same phone or a sublaptop computer.

Nonetheless, these computers are more powerful.


>> If you want to write an operating system, I'd advise Common Lisp,
>> Scheme, Modula-3, Oberon, Haskell, or design your own high level
>> programming language like BitC (http://www.bitc-lang.org/)
>
> "The BitC bootstrap compiler compiles to portable ANSI C code." Seems
> like you can't get away from C really.

It's an implementation choice that is rather irrelevant. C is used
for what it is: a portable assembler.

--
__Pascal Bourguignon__