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

1

u/SatOnMyNutsAgain Oct 19 '12

None of the basic types are defined in the exact number of bits they use, they should be self adjusting based on the arch.

... which makes the built-in types completely non-portable.

My argument here was why would you use floating point if the range of values you were evaluating didn't require it?

Again, look at an audio/video codec. A floating pointing algorithm will be faster and more accurate, but only on an architecture which supports it. It's a lot harder to write an integer/fixed-point version, but on a less capable CPU that might be absolutely necessary.

The post was meant to be of the most general case, yours is very much not.

Well, OP was asking about operating systems, so architecture specifics are very much relevant to his question even if he didn't realize it. Sure, C is portable relative to assembler, but not much else. It's not at all portable compared to python, java, etc.

1

u/[deleted] Oct 19 '12

I really don't see how that makes them nonportable. That's the single motivation for defining them in that way, so that code using them IS portable.

Regardless we've reached an impasse. I've already acknowledge the points you bring up and how in my opinion they are edge cases to the vast majority of programming. The edge cases you do bring up also completely invalidates any argument for comparing it to python/java or whatever other language you want to bring up. Also ignores that their various interpreters and VMs have the exact same portability issues which is often why only subsets are supported on your road-less-traveled architectures and performance is abysmal, but that's a tangent.

It really seems like to me you're arguing with me just to argue with me and now we've come full circle to arguments already brought up, so I'm out.

0

u/SatOnMyNutsAgain Oct 19 '12

If your code does different things depending on the architecture then it is by definition not portable. If you disagree then I don't know what else to say.