Advice on OS Language please...
-
- Posts: 4
- Joined: Wed Mar 11, 2009 1:29 am
Advice on OS Language please...
hiya,
I'm new here and i've been browsing the forums. I always thought thay OS's were written in C or C++, but from what i've seen, many people use assembly language.
Should i learn this language, then make my OS in it (In about 2 years )
Thanks,
Magicstuff.
EDIT: or do i need to know C++ and Assembly??
Thanks.
I'm new here and i've been browsing the forums. I always thought thay OS's were written in C or C++, but from what i've seen, many people use assembly language.
Should i learn this language, then make my OS in it (In about 2 years )
Thanks,
Magicstuff.
EDIT: or do i need to know C++ and Assembly??
Thanks.
-
- Posts: 4
- Joined: Wed Mar 11, 2009 1:29 am
Re: Advice on OS Language please...
wait, so asm is assembly?
Hmmm.....
Looks like i've got some research to do!
Thanks.
Hmmm.....
Looks like i've got some research to do!
Thanks.
Re: Advice on OS Language please...
I think every language could be used to write OS,
you can use your favourite language(ASM/C/C++/Perl/PHP etc).
I think your OS is only just for fun, it's hard to let market accept your OS as a product .
so, don't care more, write write and write..
you can use your favourite language(ASM/C/C++/Perl/PHP etc).
I think your OS is only just for fun, it's hard to let market accept your OS as a product .
so, don't care more, write write and write..
Just For Fun
- Steve the Pirate
- Member
- Posts: 152
- Joined: Fri Dec 15, 2006 7:01 am
- Location: Brisbane, Australia
- Contact:
Re: Advice on OS Language please...
You need to know a fair bit of Assembly, as there are a lot of things you can't do without it (such as loading the GDT and IDT, setting registers to enable paging, move stacks etc.). On top of that, if you want to use a higher level language (most people do) you should have a very good understanding (and lots of experience) in either C, C++ or possibly Pascal.
Re: Advice on OS Language please...
Yes, "Assembly" and "ASM" mean the same thing. Basic knowledge is a must, because some things cannot be done without knowledge of ASM: Bootloaders, interrupt service routines, low-level memory management are examples for this. Beware: ASM source syntax is depending on the assembler tool used. There is a group of assemblers that is quite similar to each others, and a couple of very different others (GAS, most prominently). I'll leave the details to the ASM gurus of this board.
Then you need in-depth knowledge of the high level language of your choice. You don't have to know more than one, but that one you must have detailed knowledge of, especially the runtime support requirements (something you don't get in touch with when coding "normal" applications). The one best documented, with the lowest runtime requirements, is C. C++ without exceptions and RTTI comes a close second, the rest are more complex.
Edit: And while there will always be someone telling you that you can write in any language you like, de facto there is a limited number of languages suited to the task. Yes, you can build a bicycle with square wheels, and it will even give a smooth ride - if you build the right roads...
Then you need in-depth knowledge of the high level language of your choice. You don't have to know more than one, but that one you must have detailed knowledge of, especially the runtime support requirements (something you don't get in touch with when coding "normal" applications). The one best documented, with the lowest runtime requirements, is C. C++ without exceptions and RTTI comes a close second, the rest are more complex.
Edit: And while there will always be someone telling you that you can write in any language you like, de facto there is a limited number of languages suited to the task. Yes, you can build a bicycle with square wheels, and it will even give a smooth ride - if you build the right roads...
Every good solution is obvious once you've found it.
-
- Posts: 4
- Joined: Wed Mar 11, 2009 1:29 am
Re: Advice on OS Language please...
david wrote:I think every language could be used to write OS,
you can use your favourite language(ASM/C/C++/Perl/PHP etc).
I think your OS is only just for fun, it's hard to let market accept your OS as a product .
so, don't care more, write write and write..
Wait a minute, you say i can write an OS in PHP??????!!!!?
I have about 2 years experience of PHP so it would be my primary language.
Although i am guessing that the booter etc, would have to be assembly...
Re: Advice on OS Language please...
You can drive a screw with a hammer, if you take the hammer to a grinder first and shape some part of it into something resembling a screwdriver.
Every good solution is obvious once you've found it.
- Steve the Pirate
- Member
- Posts: 152
- Joined: Fri Dec 15, 2006 7:01 am
- Location: Brisbane, Australia
- Contact:
Re: Advice on OS Language please...
PHP is a scripting language, not a programming language - there's no way you could write an operating system in it, since it needs an interpreter. You can't really (easily) do it with languages that need virtual machines and/or just-in-time compilation, like Java and C#.magicstuff wrote:Wait a minute, you say i can write an OS in PHP??????!!!!?
I have about 2 years experience of PHP so it would be my primary language.
Anyway, all of this is in the wiki - look at the Getting Started and Beginner Mistakes pages.
Yes, although I think someone has done it in C, but it still needed a lot of inline assemblymagicstuff wrote:Although i am guessing that the booter etc, would have to be assembly...
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Advice on OS Language please...
You have about three kinds of languages
The first set is those who map directly to something the processor understands, and are complete enough that it does not need anything in another language to write a full-fledged OS. That holds for assembly, and if you allow inline assembly, that includes C, C++ and pascal.
The second set are those who compile to native code, but need support of another language (part of the first set) to get complete coverage. That includes things like FreeBasic, but Haskell fits that as well (albeit at a much higher level). That causes several dependencies within the kernel that can blow you out, especially when they turn out to bi circular.
The third set does not compile to native code, so you need to write a compiler/interpreter/VM to even run that code. That means you get to write yourself another project before you can even start on the real OS. Those things include C#, Java, PHP, and everything else that's scripted and doesn't have a native compiler.
The first set is those who map directly to something the processor understands, and are complete enough that it does not need anything in another language to write a full-fledged OS. That holds for assembly, and if you allow inline assembly, that includes C, C++ and pascal.
The second set are those who compile to native code, but need support of another language (part of the first set) to get complete coverage. That includes things like FreeBasic, but Haskell fits that as well (albeit at a much higher level). That causes several dependencies within the kernel that can blow you out, especially when they turn out to bi circular.
The third set does not compile to native code, so you need to write a compiler/interpreter/VM to even run that code. That means you get to write yourself another project before you can even start on the real OS. Those things include C#, Java, PHP, and everything else that's scripted and doesn't have a native compiler.
Re: Advice on OS Language please...
It may be a whole extra step to write an operating system in Java, but this also seems to be the direction many developers are going for writing portable operating systems, like on phones and handheld devices. Interpretted languages are not slower if they byte code is designed well
- Steve the Pirate
- Member
- Posts: 152
- Joined: Fri Dec 15, 2006 7:01 am
- Location: Brisbane, Australia
- Contact:
Re: Advice on OS Language please...
A whole extra step... like writing the Java interpreter (which is technically the kernel, not the java that runs on it) for every platform the system runs on?yemista wrote:It may be a whole extra step to write an operating system in Java, but this also seems to be the direction many developers are going for writing portable operating systems, like on phones and handheld devices. Interpretted languages are not slower if they byte code is designed well
Re: Advice on OS Language please...
Basically, yes. Of course, you could write the interpreter in C or C++ and therefore retain a level of portability.Steve the Pirate wrote:A whole extra step... like writing the Java interpreter (which is technically the kernel, not the java that runs on it) for every platform the system runs on?
The main exception to this would be a CPU that runs Java bytecode directly.
Cheers,
Adam
Re: Advice on OS Language please...
Yes precisley. Im not meaning to say this is a good idea for OS development because Im pretty sure most people here are developing OS's to learn about writing the OS as opposed to writing Java interpreters, but it certainly is a possibility for anyone who might have the know how or drive to do it. I think the Android has been designed this way, and it looks like this is the route future development will take and it should not be dismissed as a way to do it. The kernel itself is written in Java and has access through the hardware from an API that must also be written, but the interpreter itself just makes sure to compile the source in a way that is most efficient for the hardwareSteve the Pirate wrote:A whole extra step... like writing the Java interpreter (which is technically the kernel, not the java that runs on it) for every platform the system runs on?yemista wrote:It may be a whole extra step to write an operating system in Java, but this also seems to be the direction many developers are going for writing portable operating systems, like on phones and handheld devices. Interpretted languages are not slower if they byte code is designed well
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Advice on OS Language please...
Ahhhh, but can pointers and I/O ports be accessed in PHP? (never learnt the language more than a few simple bits of the syntax.)berkus wrote:Just to add a note about php requiring interpreter - there's llvm-based roadsend php compiler, but you will most probably require a lot of runtime support (the higher the language level - the more runtime support it requires, usually).
Re: Advice on OS Language please...
I dont think any general purpose HLL would support I/O ports nativity do to it being dependent on the architecture and platform. (C relies on asm to use port I/O) I dont know about PHPs usage on pointers though.Ahhhh, but can pointers and I/O ports be accessed in PHP? (never learnt the language more than a few simple bits of the syntax.)
Any language(s) can be used so long as the tool environment can produce supervisor-mode code that is supported by your hardware environment. In the case of PC's, technically, the only code that must be written in asm is the MBR and bootstrap code. Everything else can be written in a HLL if you wanted.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}