Page 1 of 1
how can I write Kernel?
Posted: Wed Aug 27, 2014 3:54 am
by Tanzadeh
can I use C# or java for write kernel if I can't how can I use C.
I have one C program can I boot it with grub
Code: Select all
#include <stdio.h>
int main(){
printf("Welcome to IROS");
char *a;
for(;;){
gets(a);
printf("text typed:");
puts(a);
}
}
what about golang can I make Kernel with golang
if my sentences are bad Excuse me I'm not very good in English my Language is persian. and I'm just 13.
Re: how can I write Kernel?
Posted: Wed Aug 27, 2014 4:19 am
by zhiayang
http://forum.osdev.org/viewtopic.php?f=1&t=16944
Beginner Mistakes
Required Knowledge
This essentially a post saying
"how to osdev plz halp"
It appears [com]buster is online so I'll leave it to him if he bothers to leave a more eloquent reply.
I'll try and be at least a little accommodating.
1. People have written OSes in C# before. It is not easy.
2. People have written OSes in Java before. It is not easy.
3. I don't know if people have written OSes in Go before, but looking at (1) and (2), it is probably not easy.
4. Your C program doesn't even work properly.
Re: how can I write Kernel?
Posted: Wed Aug 27, 2014 6:27 am
by Combuster
Knowing English is one important thing you should try working on, and the other is to make it a habit for yourself to both look around (it's quite obvious you neglected the forum rules, or you didn't understand them) and to look things up before you ask a question.
Tanzadeh (corrected) wrote:Can I use C# or Java to write a kernel?
There's quite some literature on
Languages. For most people, the answer to this question is basically "no".
if I can't, how can I use C?
See the
Tutorials
If I have this C program, can I boot it with grub?
No, the reason being that you include stdio, which depends on an existing OS's features.
What about Golang? Can I write a Kernel using golang
See your first question. It's likely more difficult than C, but much easier than bytecode languages.
My apologies for any writing errors. I'm not very good at English, My first Language is Persian, and I'm only 13 years old.
It's far from hopeless, but I fixed it for you anyway.

Re: how can I write Kernel?
Posted: Wed Aug 27, 2014 7:21 am
by Tanzadeh
Combuster wrote:Knowing English is one important thing you should try working on, and the other is to make it a habit for yourself to both look around (it's quite obvious you neglected the forum rules, or you didn't understand them) and to look things up before you ask a question.
Tanzadeh (corrected) wrote:Can I use C# or Java to write a kernel?
There's quite some literature on
Languages. For most people, the answer to this question is basically "no".
if I can't, how can I use C?
See the
Tutorials
If I have this C program, can I boot it with grub?
No, the reason being that you include stdio, which depends on an existing OS's features.
What about Golang? Can I write a Kernel using golang
See your first question. It's likely more difficult than C, but much easier than bytecode languages.
My apologies for any writing errors. I'm not very good at English, My first Language is Persian, and I'm only 13 years old.
It's far from hopeless, but I fixed it for you anyway.

Tank's for help
Re: how can I write Kernel?
Posted: Wed Aug 27, 2014 8:49 am
by SpyderTL
Tanzadeh wrote:Tank's for help
Thanks for the help.

Re: how can I write Kernel?
Posted: Wed Aug 27, 2014 9:05 am
by SpyderTL
Tanzadeh wrote:can I use C# or java for write kernel.
As requimrar said, the answer is "no". You cannot write a kernel in C# or Java, and run them on real hardware. But what you can do with C# and/or Java is write a Compiler.
Once you've done that, then you will be able to use any language you want -- C#, Java, or even make up your own language. This is essentially the approach that I took. I wrote a simple Compiler in C# that reads XML files and writes out byte code that can be copied to a CD and run on real hardware.
There are several other projects on this site that have taken a similar approach. You may want to take a look at jEmbryOS, which has a Java compiler and a Java runtime, which are both written in Java.
Of course, writing a compiler requires a lot of time and effort before you can even start working on your kernel, so you will need to decide whether it is worth the extra effort, or if it would just be easier to learn Assembly and C.
If you want to see how I'm compiling XML using C#, my code is available at
http://ozone.codeplex.com.