Thread: Java vs C to make an OS

  1. #1
    Registered User
    Join Date
    May 2007
    Location
    Tustin, CA
    Posts
    1

    Java vs C to make an OS

    Sorry if this is the wrong section. I'm new here and did not see a topic for Misc programming topics and its not in the FAQ one. Its either specifically this language or specifically not programming at all along with no Java sections. I picked C since thats the OS language I am assuming. Unix and Windows is C I believe and not C++. Thats not what I am asking though.

    I'm a beginner programmer. I'm learning C for a few reasons including its the OS language. One of my teachers at college thinks Java is the worlds best language and can do anything. I dont remember how it came up but someone said that Java can not make an OS. He said otherwise and because no one could specifically say why Java cant do that, he wins the argument. I really need to know why :P

    Can someone enlighten me on this?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Welcome, we actually use the Tech board for such questions, so this thread has been moved.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Java "can" make an O/S that would run off of a VM of sorts. Does that mean it's appropriate?

    You came to a C board, so the answer will probably be no.

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    As MacGyver said you'd need a VM. Java is interpreted by a VM, and you couldn't write the VM in Java 'cause you'd need a VM to interperate your VM.

    SunOS (Solaris) is mostly in Java, except the kernel. However the Kernel is the biggest component of the OS. So you could write an OS in Java, just not entirely in Java.

    I myself am not a fan of Java, and your teachers comment is rather narrow minded. Creating an OS that is run through a VM is stupid and slow.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    An OS is responsible for handling low-level hardware interfaces. Java doesn't provide any means for low-level access to hardware. Calling anything written in Java an Operating System is like calling Windows Explorer an Operating System.

    Besides, Java necessitates the presence of virtual machine. The OS is responsible for loading and providing memory for the virtual machine. If the OS is written in Java, you end up with a very nasty bootstrap problem.
    Callou collei we'll code the way
    Of prime numbers and pings!

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    Quote Originally Posted by zacs7 View Post
    SunOS (Solaris) is mostly in Java, except the kernel. However the Kernel is the biggest component of the OS. So you could write an OS in Java, just not entirely in Java.
    Sun developed both Solaris and Java, but Solaris is definitely not written in Java in any way.
    Callou collei we'll code the way
    Of prime numbers and pings!

  7. #7
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by QuestionC View Post
    Sun developed both Solaris and Java, but Solaris is definitely not written in Java in any way.
    I believe he's referring to the Java Desktop System, though, whatever he meant he clarified he was not talking about the kernel.

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You can't write a complete OS in C, much less Java. I shudder to think how slow it would be if it were coded in Java.

    If you want information on programming operating systems I suggest the book MMURTL. It is very heavy on assembly language (but OS programming necessitates being heavy on asm) so you may want to brush up on that or learn it. I don't have a link for the book but perhaps Fordy might.

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    The Solaris front-end (Java Desktop System) is written entirely in Java. As I said, the kernel is not.

  10. #10
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    An OS is a mixture of C and C++ as MacGyver stated on a thread a while back. With some assembley thrown in the pot too.
    Double Helix STL

  11. #11
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Quote Originally Posted by zacs7
    As MacGyver said you'd need a VM. Java is interpreted by a VM, and you couldn't write the VM in Java 'cause you'd need a VM to interperate your VM.
    Unless of course the VM is the actual hardware. http://www.soc.tuwien.ac.at/courses/jvmhw

    Also someone is already trying a Java OS. http://cjos.sourceforge.net/archive/

  12. #12
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by swgh View Post
    An OS is a mixture of C and C++ as MacGyver stated on a thread a while back. With some assembley thrown in the pot too.
    I don't remember saying that, but sure.

    Quote Originally Posted by Frobozz View Post
    Unless of course the VM is the actual hardware. http://www.soc.tuwien.ac.at/courses/jvmhw

    Also someone is already trying a Java OS. http://cjos.sourceforge.net/archive/
    I suppose the debate would then be about the performance of the VM-turned-hardware.

  13. #13
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Another book I'd recommend is "Operating Systems: Internals and Design Principles". Although it has nearly no code, it takes a very in-depth look Linux, Solaris and Windows and discusses things every OS has to do.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  14. #14
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Also someone is already trying a Java OS. http://cjos.sourceforge.net/archive/
    FOOLS!, They belong in the same group of people whom are porting the idea of a 'registry' to Linux, and porting VisualBasic to Linux.

    You really have to weigh the benifits of Java, Java is portable thats really its only upside. Now a portable OS? Eh???

  15. #15
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    One of my teachers at college thinks Java is the worlds best language and can do anything. I dont remember how it came up but someone said that Java can not make an OS. He said otherwise and because no one could specifically say why Java cant do that, he wins the argument.
    It is not much of an argument though: it is just opinion that Java is the world's best language. If the argument is that this is because it can "do anything", then a counterexample easier than trying to prove that an OS cannot be written in Java is to point out that assembly language, C, C++, etc, can also "do anything". In the end, use the best tool for the job if you can, rather than always try to use the "world's best programming language" even when it (whatever it is) is not the best tool for the job.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Java for real-time applications
    By zacs7 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 08-26-2008, 06:34 AM
  2. Mats, the java answers
    By Jaqui in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-22-2008, 02:12 AM
  3. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  4. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  5. What to make?
    By Caldus in forum C++ Programming
    Replies: 4
    Last Post: 04-06-2005, 01:12 PM