Thread: Java vs C to make an OS

  1. #16
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Perhaps then the definition of "the world's best programming language" is, "The best language for the job"

  2. #17
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Is this like asking a golfer which golf club is best?

  3. #18
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Windows xp was written in C++. *cheers* Answer your question?
    Java is to high-level to write a good os with anyhow.

  4. #19
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    You could write an OS in Java essentially in the same manner Singularity was wrote using C# (information here.) Of course, you're not going to write your OS in one single language by any means: otherwise, pretty much every major operating system would violate this rule, so that's kind of a bad way to define an operating system if you're thinking of it in that way.


    Java is not inherently tied to the JVM either: that's just an implementation of Java. You can compile Java to native code (see: GCJ,) and you can link it into a simple flat binary; it is by no means impossible (impractical? I dare say maybe.) It's been a while since I've been interested in real operating system design/implementation. I wouldn't say Java is the best choice, but it's not an impossible choice.
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  5. #20
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    To go off topic at a sig,

    Quote Originally Posted by Mad_guy
    Code:
    -- haskell
    import Control.Monad.State
    s :: StateT Int IO ()
    s    = do
      n <- get
      liftIO $ putStrLn ("hello "++ show n ++"!")
      unless (n >= 10) $ do {
           put (n+1); s;
      }
      return ()
    main = evalStateT s 1
    I must say, that's disgusting. What's wrong with
    Code:
    s :: StateT Int IO ()
    s = sequence_ . replicate 10 $ do
          n <- get
          liftIO $ putStrLn ("hello " ++ show n ++ "!")
          put (n+1)
    But no, seriously, what do you have against
    Code:
    main = mapM_ (putStrLn . ("hello " ++) . (++ "!")) [1..10]
    You're making me cry :-(
    Last edited by Rashakil Fol; 05-17-2007 at 10:22 PM.
    There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary.

  6. #21
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    Certainly it is possible in Java, but in my opinion it is the worst choice possible.

    Most OS's will use a heavy amount of Assembly at the extreme lower levels, and then the bulk of the OS itself will be in C, with lots of C++ once you start getting into the higher levels.

    To even consider the option of Java makes me shudder...
    My Website

    "Circular logic is good because it is."

  7. #22
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Windows XP is not written in C++ and for the most part, newsflash here, the versions of Windows since 95 have not changed all that much under the hood.

    The core kernel code was ported to pure 32-bit code and uses protected mode but the API has really not changed much. It has acquired a significant amount of 'bloat' since those early days and I'm not sure if that's better or worse.

  8. #23
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Actually approx 70&#37;+ of the NT4/XP kernel is in C++. The front end to XP is in C++. Have a look at the link in my sig...

    Windows XP is not written in C++ and for the most part, newsflash here, the versions of Windows since 95 have not changed all that much under the hood.
    There's been 3 kernels up until and including Vista, the 9x kernel, NT kernel and Vista Kernel. Other than the introduction of a few "features" like .NET and the like, I agree Windows hasn't changed that much over the past 12 or so years.
    Last edited by zacs7; 05-18-2007 at 06:17 AM.

  9. #24
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    So, Bubba what you are saying is when M$ created Vista, they hardly touched the core program at all? All they did was change a few files and add some new flashy extras, This is just a guess, so please dont kill me over this assumptsion, im no where near as cluded up as you are about the tech side of Windows
    Double Helix STL

  10. #25
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    And the NT kernel is a complete rewrite of the old DOS-wrapper kernel of the 9x series. It's got very little in common under the hood with Win95. It's the exposed API that's largely the same.
    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

  11. #26
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    if you want proof that XP is largely written in C++, just look at the Windows 2000 source leak.

  12. #27
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    CornedBee is correct. The generally exposed API to the system's application is largely the same, but NT is an extremely different architecture from Windows 95. If you were still running on the 9x series kernel, you'd know it. NT is architecturally very different and it is much more robust all around. These changes are largely not exposed to user-mode however, which is why a large portion of apps written for the 9x series were easily portable to 2k/XP. If the kernel's were "pretty much the same," you wouldn't need two different releases of tools such as, say, Process Explorer. You wouldn't need two releases of one driver for both systems.
    The kernel is different. I've done plenty of work pertaining to low-level windows internals, primarily in the NT realm, but just looking at the evidence it's easy to conclude that things have changed in relation to the kernel since windows 95.

    if you want proof that XP is largely written in C++, just look at the Windows 2000 source leak.
    If that's in reference to being a complete rewrite, it's orthogonal to the point anyway.

    Quote Originally Posted by Rashakil Fol View Post
    You're making me cry :-(
    You make me cry with your haskell skills. :( (edit: changed)
    Last edited by Mad_guy; 05-20-2007 at 11:34 AM.
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  13. #28
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Making a kernel which runs on a run-time environment? Does someone try to make me laugh?
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  14. #29
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    Quote Originally Posted by maxorator View Post
    Making a kernel which runs on a run-time environment? Does someone try to make me laugh?
    No, you just can't read:

    You can compile Java to native code (see: GCJ,) and you can link it into a simple flat binary
    Granted, you may have to have special versions of your libraries, but generally you'll have to bootstrap parts of your libraries regardless of the language anyway if you're going to write an OS.
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  15. #30
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    Regardless of what JVM you are using, and regardless of what platform you are developing for, Java does not let you have hands on access to memory in any way.

    Therefore, even if you compiled Java code to a flat binary, instead of interpreted byte code, the fact is that at the code level, when you wrote it, you still didn't have that hands on access to memory.

    So, in order to write any type of OS in Java, there would have to be a specialized library written which allows you to access those protected things that Java normally keeps from you.
    My Website

    "Circular logic is good because it is."

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