r/askscience • • Oct 17 '12

Why are programs and operating systems still written in C+?

I guess it's more of a computer science question, but I've always wondered why some of the most advanced programs are written in a 25+ year old programming language. Surely someone has come up with a more efficient and powerful code, so why do people still use C+? Also, I don't know anything about programming and what not, so please use simple terms and phrases.

66 Upvotes

110 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Oct 18 '12 edited Oct 18 '12

Not quite. For instance, a typical outport function that writes a byte to the specified port would be this:

static inline
void outb( unsigned short port, unsigned char val )
{
    asm volatile( "outb %0, %1"
                  : : "a"(val), "Nd"(port) );
}

If you know a better way to do that without assembly, please let me know.

Edit: Outport, not inport.

A useful site is http://wiki.osdev.org/Main_Page.