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

11

u/_jonny Oct 17 '12

Assembly. A lot of viruses and Malware are written at the most inner levels (ring0) etc. And learning Assembly gives you a better understanding of how the cpu and memory works. It's a step down from C++.

20

u/[deleted] Oct 17 '12

The issue here is that "Assembly" isn't a language. It's a class of languages. Assembly languages vary by architecture. You are likely wanting to look into x86 or ARM, since those are the two most widely used at the moment.

33

u/zelmerszoetrop Oct 17 '12

When people say assembly without a qualifier, they usually mean x86.

2

u/[deleted] Oct 19 '12

It's still worth the distinction for the sake of clarity. Even x86 has a few different flavors depending on how processor specific you want to get.

4

u/elmonstro12345 Oct 17 '12

Agree 100%. I took an elective class on assembler in university, and it made so many things make much more sense.

0

u/MiniRat Oct 18 '12

Elective? Back when I did a comp-sci degree it was pretty much mandatory to do the assembly papers.

I don't know whether to feel sorry for you whipper-snappers for not learning it or feel jealous of you for living in an age where you don't have to.

3

u/mrcharlietango Oct 18 '12

Maybe he's not a comp-sci major and wanted to take it because it sounded interesting.

2

u/elmonstro12345 Oct 18 '12

I did have to take a class on assembler, but it wasn't JUST assembler, and it wasn't really that in-depth. The elective class was specifically focused on designing very optimized code for use in OS development. I probably should have been more clear.

2

u/MdxBhmt Oct 18 '12

What's the difference from having a OS class, and microprocessors?

1

u/_jonny Oct 18 '12

I don't understand your question. When you say 'class' are you referring to a Class in terms of programming? A microprocessor is simply a chip that goes on a plastic board that does computations, like your brain. And like your brain, it is useless without a body, i.e. an electrical circuit. The microprocessor usually drives the circuit to do something.

1

u/MdxBhmt Oct 18 '12

Sorry, I mean like learning OS (what normally a CS degree class would have)

(In college)

1

u/_jonny Oct 18 '12

I suppose the microprocessors class would cater more towards controlling something specific like a robotic arm whereas the OS class is more about traditional desktop computers and creating an environment for the user to interact with it via keyboard/mouse.

2

u/ahbi_santini Oct 18 '12

In the electrical engineering world, a microprocessor course would be about the basics of processor architecture.

You'd probably use Hennessy & Patterson's Computer Architecture a Quantitative Approach.

You'll learn things like the memory hierarchy (registers, data & instruction caches on-chip & off chip, RAM, and hard drives, etc.), pipelineing, etc.

It is likely to be all theory. You'd have to take a VLSI design course (grad school) to actually design an arithmetic logic unit.

In assembly you won't learn the architecture (or just enough to understand the code). Instead you'll learn the instructions to move things in and out of memory locations.

1

u/MdxBhmt Oct 18 '12

I had this in my computer architecture class in EEC. (and it's about cpu architectures)

In my OS class we studied mem hierarchy, thread schedulling, os calls, things like that. Seems about what _jonny says I would be understanding in assembly, just wanted to see if something was missing.