For kernel/OS is C still it? [closed]

2019-01-31 13:24发布

I like operating systems and would eventually like to become a OS developer mostly working on kernels. In the future will C still be the language of choice and what else should I be trying to learn?

17条回答
闹够了就滚
2楼-- · 2019-01-31 14:02

I think its a pretty safe bet that serious (non experimental) OS development will remain in C (and assembly) for the forseeable future.

The proof I submit is Ada. It can get as bare-metal as C, provides better control over data placement, and has safer default behavior for just about everything (eg: array bounds checking). From the point of view of an OS developer, it is either equal or superior to C in any technical parameter you can think up. It has been available for over 20 years now (ok...reasonably-priced for perhaps only 15).

So if people were looking for a technically superior language to C, you should see OSes all over the place written in Ada instead right? What I actually see is one serious OS implemented in Ada. It is no longer supported in favor of a reimplementation in C.

The barriers to other languages in OS development are not and never have been technical. I don't see C's non-technical benifits going away any time soon, and nobody is ever going to overcome them by simply designing a better language.

查看更多
聊天终结者
3楼-- · 2019-01-31 14:02

You should definitely be fluent in C.

As others have pointed out, there is no reason that an operating system has to be written in C, and there is a lot to be gained by using more sophisticated languages. But if you're going to work on operating systems in the real world (i.e., not in academia or a research lab) there are a couple of realities that you have to live with:

  1. Existing operating systems are huge, often many millions of lines of code, and are written in C or C-derivatives, such as Objective-C or C++.
  2. New operating systems take hundreds of engineer-years (and many calendar years) to reach and match the functionality and robustness of existing operating systems.

As a result, it's hard for me to see how and when the world will move away from C-based operating system kernels. Yes, it's technically possible. But the cost may be too high. If anything, the trend seems to be toward consolidation on a small number of OS families---Windows, Linux, and BSD---all C-based.

It would be interesting to know what research has been done, or what tools and techniques might be available to evolve an existing code-base (such as Linux) to a better language. I think this would be a much more viable approach than getting the world to adopt a completely new OS.

查看更多
一夜七次
4楼-- · 2019-01-31 14:03

C is pretty much it, with a fair amount of assembler. Important topics for OS kernel work include:

  • Principles of caching and cache management
  • Virtual memory, TLB management
  • CPU and system architecture
  • Storage hierarchies
  • Concurrent programming techniques (mutual exclusion, locking, ...)
  • Algorithms and data structures
查看更多
ゆ 、 Hurt°
5楼-- · 2019-01-31 14:07

Most definitely! You should also learn at least one assembly language/hardware architecture.

查看更多
啃猪蹄的小仙女
6楼-- · 2019-01-31 14:08

Cody didn't want to be bothered answering this, so I'm passing this on on his behalf. :-P For some examples of OSs written in managed languages, as opposed to C or assembly, look at:

Of course, Cody also didn't want to mention this:

查看更多
放荡不羁爱自由
7楼-- · 2019-01-31 14:08

Actualy, there is quite a bit of room in the core of a modern OS for C++ code. I just looked and the Win7 core kernel tree has quite a bit of C++ code. Note that many sub-systems remain in simple C. There are a few reasons for this

  1. C is the original language of the NT based OS
  2. C is very, very well understood by key people
  3. Well written C can be the most straight forward code to debug - especialy in kernel mode.

That being said, many teams and people have found well written C++ to be an effective tool for core OS work.

There is nothing about C++ that prevents it from being used to write core resource management code like a scheduler, memory manger, I/O subsystem, graphics sub-system, etc. etc.

As others have pointed out - any kernel work will always require some bit of assembly language.

查看更多
登录 后发表回答