Is C a good OS-Developing language?
Is C a good OS-Developing language?
Hey guys, I'm new here, this post is probably a load of crap to most of you, but anyway:
I know C is a low level language, i am currently learning some of it, but is it a very good language for making things like kernels and Operating Systems? I understand most of this prograaming language stuff, when it comes to theory I pick it up quickly, but when it comes to actually writing code, I don't perform as well. but none-the-less...
I notice you guys use Assembly and machine code a fair bit in making these OSs, Do you use that with other low level programming languages?
And Qemu, is that like a simulator? I'm just curious cause making my own OS or programming language is something that I wanna get done in my life(im 15 atm btw )...
I am kinda noob, and ive been watching this site for a pretty long time lol.
Thanks to anyone who can help me understand some of these questions.
BTW, this site is so fking awesome....just thought i'd put that out there
I know C is a low level language, i am currently learning some of it, but is it a very good language for making things like kernels and Operating Systems? I understand most of this prograaming language stuff, when it comes to theory I pick it up quickly, but when it comes to actually writing code, I don't perform as well. but none-the-less...
I notice you guys use Assembly and machine code a fair bit in making these OSs, Do you use that with other low level programming languages?
And Qemu, is that like a simulator? I'm just curious cause making my own OS or programming language is something that I wanna get done in my life(im 15 atm btw )...
I am kinda noob, and ive been watching this site for a pretty long time lol.
Thanks to anyone who can help me understand some of these questions.
BTW, this site is so fking awesome....just thought i'd put that out there
Re: Is C a good OS-Developing language?
Hi,
For all languages (except assembly), there's a few special instructions that a kernel needs to use that no higher-level language supports. This means that some assembly language is unavoidable. Assembly language is harder to get right and harder to maintain, so I wouldn't recommend using assembly language by itself (e.g. better to do everything you can in C, and only use assembly for the tiny pieces that no high level language can do).
Cheers,
Brendan
C is probably the best language for things like kernels: lots of people are familiar with C, there's lots of example code in C (including Linux, FreeBSD, etc), there's several good free C compilers (that you could port to your own OS one day), it's low-level enough to do almost everything and it's high-level enough that you don't end up spending all day twiddling bits.DJAlexem wrote:I know C is a low level language, i am currently learning some of it, but is it a very good language for making things like kernels and Operating Systems?
For all languages (except assembly), there's a few special instructions that a kernel needs to use that no higher-level language supports. This means that some assembly language is unavoidable. Assembly language is harder to get right and harder to maintain, so I wouldn't recommend using assembly language by itself (e.g. better to do everything you can in C, and only use assembly for the tiny pieces that no high level language can do).
Learning the theory isn't too hard. Gaining experience takes practice. That's another good thing about C (and C++) - people can and do use it for writing applications; and you can get a lot of experience writing applications in C, where there's lots of debugging tools, etc to make it easier. This is probably important, because OSs are complex, and it would be much harder to write an OS when you don't have much experience with the languages you're using (much better to get experience writing applications for Linux or something; and then start your OS when you've got experience).DJAlexem wrote: I understand most of this prograaming language stuff, when it comes to theory I pick it up quickly, but when it comes to actually writing code, I don't perform as well. but none-the-less...
Most people use C (with a little bit of assembly) for kernels. Some people use C++ (with a little bit of assembly), some use assembly alone. A few rare people use other languages (Pascal, C#, D, something they invented themselves, etc).DJAlexem wrote:I notice you guys use Assembly and machine code a fair bit in making these OSs, Do you use that with other low level programming languages?
Qemu is a virtual machine - a normal application that emulates a computer, that people use for testing their OSs to avoid rebooting a real computer a lot (it saves time). It also means if you mess something up you don't have to worry about trashing your (real) hard drive. The other reason to use virtual machines is that it's easy to have bugs that work on some computers and fail on other computers; so to increase the chance of finding those bugs you want to test on lots and lots of different computers. Virtual machines (Qemu, Bochs, VirtualBox, VirtualPC, VMware, etc) are a cheap way of increasing the number of "computers" you can test on (and increasing your chances of finding bugs).DJAlexem wrote:And Qemu, is that like a simulator? I'm just curious cause making my own OS or programming language is something that I wanna get done in my life(im 15 atm btw )...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Is C a good OS-Developing language?
wow, thx for the very indepth answer Brendan
This is extremely helpful, and amazingly understandable.... xD
So it looks like ill be sticking to C, I like it too....unlike a lot of those higher level languages, lol.
once again, thank you brendan for the time and effort!
Anyone else got any tips or answers to help me with C?
This is extremely helpful, and amazingly understandable.... xD
So it looks like ill be sticking to C, I like it too....unlike a lot of those higher level languages, lol.
once again, thank you brendan for the time and effort!
Anyone else got any tips or answers to help me with C?
Re: Is C a good OS-Developing language?
Id actually recommend learning how ASM works, because C is very closely related. It'll help you understand some computing principles.
mike brown
mike brown
Re: Is C a good OS-Developing language?
LOL, ASM is my initials
Alexander
S*m*e*
M*P*e*s*n
yeh, i blank my own name >.>
anyway, ill look into it tomoz, thanks Mike!
EDIT: holy crap assembly is complicated... its just memory and extremely low lvl handling O_O
Alexander
S*m*e*
M*P*e*s*n
yeh, i blank my own name >.>
anyway, ill look into it tomoz, thanks Mike!
EDIT: holy crap assembly is complicated... its just memory and extremely low lvl handling O_O
-
- Member
- Posts: 68
- Joined: Thu May 28, 2009 11:46 pm
Re: Is C a good OS-Developing language?
C was initially made for developing the Unix kernel... so yeah, C is one of the best languages for writing kernels.
Assembly is more complicated, and less portable... but it's very important to know when writing a kernel...
Debugging is a nightmare without knowing assembly, and some things you cannot do without it.
Assembly is more complicated, and less portable... but it's very important to know when writing a kernel...
Debugging is a nightmare without knowing assembly, and some things you cannot do without it.
Tibi,
Currently working on the Lux Operating System
Currently working on the Lux Operating System
Re: Is C a good OS-Developing language?
Alexander Samuel McPherson?Alexander
S*m*e*
M*P*e*s*n
Exactly, I think that to be able to write a kernel well, you should code in C but often think in assembly. C is just high level enough to be useful and portable, but low level enough to not forget what's really happening behind the scenes. So far as I'm concerned, it's the goldilocks spot of low-level programming.Assembly is more complicated, and less portable... but it's very important to know when writing a kernel...
Valix is an experiment in an interpreted userspace with object-oriented and functional design patterns. Developers needed! Join #valix on irc.freenode.net
Re: Is C a good OS-Developing language?
LOL, thats a cookie for xvedejas! you guessed my name!
so you can do most of the stuff you can do in assembly by using C alone? is it THAT low level?
plus, does anyone know where i can find very good online C tutorials, the one i wa currently following only had 14 episodes, so now im stuck xD
I mean a very very good tut...
thx again guys, this is really opening my eyes...
so you can do most of the stuff you can do in assembly by using C alone? is it THAT low level?
plus, does anyone know where i can find very good online C tutorials, the one i wa currently following only had 14 episodes, so now im stuck xD
I mean a very very good tut...
thx again guys, this is really opening my eyes...
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: Is C a good OS-Developing language?
No, you're the king of obfuscation and he's just a clever savant.DJAlexem wrote:LOL, thats a cookie for xvedejas! you guessed my name!
Re: Is C a good OS-Developing language?
Hi,
As chibicitiberiu says, you will need assembly for debugging, particularly as that's what the emulators output when showing you the current instruction at eip...
I've provided this link before and I'll provide it again - if you are going to practice any assembly hand-coding, this article is excellent: http://www.swansontec.com/sregisters.html.
Cheers,
Adam
Although it looks it to start with, Assembly isn't actually that complicated. It may be more difficult to write maintainable code, but each line of assembly code actually does something extremely simple. It's all a matter of what you are familiar with. Have a look at OS Dever. There are a couple of really simple floppy bootloader examples on there (starting with a jmp $ infinite loop) that I think are an excellent way to get the gist of how it works.DJAlexem wrote:EDIT: holy crap assembly is complicated... its just memory and extremely low lvl handling O_O
As chibicitiberiu says, you will need assembly for debugging, particularly as that's what the emulators output when showing you the current instruction at eip...
I've provided this link before and I'll provide it again - if you are going to practice any assembly hand-coding, this article is excellent: http://www.swansontec.com/sregisters.html.
Cheers,
Adam
Re: Is C a good OS-Developing language?
hmm, these are really good, thank you adam
But i come across another problem D: ...
I can't find a windows version of qemu, just linux ones, i also cant find a way of compiling C files into O files, eg:
kernel.c --> kernel.o
I got a compiler for .asm to .o, so no worries there.
But i need to find a good emulator, just a simple one, that works for windows, I fail at trying to find one.... I also has virtualbox, but it wasnt what i thought it would be xD
so checklist:
-> .c to .o compiler
-> virtual machine emulator for windows that is easy to use
Thx again guys!
and thx again adam for the assembly tutorials!
-Alexem
But i come across another problem D: ...
I can't find a windows version of qemu, just linux ones, i also cant find a way of compiling C files into O files, eg:
kernel.c --> kernel.o
I got a compiler for .asm to .o, so no worries there.
But i need to find a good emulator, just a simple one, that works for windows, I fail at trying to find one.... I also has virtualbox, but it wasnt what i thought it would be xD
so checklist:
-> .c to .o compiler
-> virtual machine emulator for windows that is easy to use
Thx again guys!
and thx again adam for the assembly tutorials!
-Alexem
Re: Is C a good OS-Developing language?
Hi
Google is your friend. But don't rely on one emulator. Also use Bochs and some virtual machines like VPC, Virtualbox and not forgetting real hardware tests too!
Cheers,
Adam
Google is your friend. But don't rely on one emulator. Also use Bochs and some virtual machines like VPC, Virtualbox and not forgetting real hardware tests too!
Cheers,
Adam
Re: Is C a good OS-Developing language?
LOL, dad would kill me if i tried to boot my own operating system onto the PC... -.-'AJ wrote:not forgetting real hardware tests too!
OK, ill try bochs, and the GCC thing, im was just having trouble finding a working windows one compatible with vista...
thx!
Re: Is C a good OS-Developing language?
Brynet-Inc wrote:No, you're the king of obfuscation and he's just a clever savant.
I had a feeling..
Re: Is C a good OS-Developing language?
Hi,
Cheers,
Adam
I use Bochs, Qemu, VPC and VirtualBox. All of which ran on my old Vista machine and still run on my Windows 7 machine (when I get time to use them...). As far as the "GCC thing", both the Windows operating systems I regularly use happily run Cygwin with GCC Cross Compilers.DJAlexem wrote:OK, ill try bochs, and the GCC thing, im was just having trouble finding a working windows one compatible with vista...
Cheers,
Adam