This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Why there is no Os built based on java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why there is no Os built based on java" Watch "Why there is no Os built based on java" New topic
Author

Why there is no Os built based on java

raj talatam
Ranch Hand

Joined: Apr 19, 2012
Posts: 87
Hi Every one,

when i was studying B.Tech i got a doubt, when i was in my first year ,we learned C basics,
when i was in 3 rd year we learned java, They said , there are many, disadvantages with c,
for Pointers, memory leaks etc, so these are eliminated in java.

Then why every operating system is built based on C, Not in java,
By using java we can write more flexible OS right..
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 557
Java .class files run on the JVM which is dependent on / tailored to the host machine's OS. Without an existing OS, there is nothing to 'run' the JVM. Without a JVM, there is no ability to run a Java program. It's one of those layer cake diagrams that show the host OS the largest bottom layer, the next layer partially covering would be the JVM, and the topmost, smallest layer the Java application. That's a required construct for the Java language that can't be turned upside down.

And not all C problems were entirely eliminated in Java. The designers did their best to mitigate or minimize many C issues, continuing to improve the language to this day, but it's not perfect - yet.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7552
    
  18

raj talatam wrote:Then why every operating system is built based on C, Not in java,
By using java we can write more flexible OS right..

Actually, I believe there are devices - particularly small hand-held ones like phones - that pretty much tie the JVM directly to the OS, or even have the JVM burnt into a chip; but I couldn't swear to it. And in such a case it would be the JVM that is acting like an OS, not the Java language.

The fact is that the two things - an OS and Java - perform completely different functions. The business of Java is to allow us to write programs that are OS-independent; the business of an OS is...well...to be dependent - to communicate directly with the devices and memory and processors and filsystems used by a particular machine.

Like Greg says, it's a chicken and egg situation.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

raj talatam wrote:Every operating system is built based on C, Not in java,By using java we can write more flexible OS right..


I don't think this statement is true. In the past, for example, the DEC VMS operating system was written not in C but in Bliss. Multics, which was an early operating system was written in PL/1. Multics was so important in the history of computer science that Unix was named after it. Apple's OS-X is written in Objective-C, which has object-oriented characteristics. IOS is also written in Objective-C

For the past 20 years, design theory behind operating systems has moved away from flexibility in the OS itself. Rather, the OS is small and fast and robust. Everything that can be is removed from the operating system and placed into user-mode programs.

Java is great for these user mode programs. On Android, nearly all user mode programs are written in Java, or at least run on the Java JVM.
Naishadh Parmar
Ranch Hand

Joined: Jun 02, 2011
Posts: 95


Yeah you are right all OS that run on a PC are written in C. Because C works faster than Java. Nobody can doubt that

And there are mobile OS based on Java----- Blackberry OS, Android (Its core is based on C but display is based on Java, and all apps are written in Java)

And as Greg rightly pointed that Java programs need a JVM to run. This is possible on mobile phones. So mobile phones can run OS based on java
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38078
    
  22
Naishadh Parmar wrote: . . . Because C works faster than Java. Nobody can doubt that . . .
I most certainly doubt that. Java is faster than C in some instances. Much faster.

The reason for using C is that C allows one directly at access memory locations (via pointers) and probably also to use assembly language.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41177
    
  45
Naishadh Parmar wrote:And as Greg rightly pointed that Java programs need a JVM to run. This is possible on mobile phones. So mobile phones can run OS based on java

I would argue that neither the Android OS nor the JME OS is based on Java, but on native code. Only the applications are written in Java, not the OS. With the same right you could run only Java desktops apps on your PC - that doesn't make the OS Java-based, either. (And all this is disregarding that Android apps can be written in C as well as Java.)
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Naishadh Parmar wrote:Yeah you are right all OS that run on a PC are written in C. Because C works faster than Java. Nobody can doubt that


nope. OS-X is not in C.
All the rest were written in C because they started writing them, Java didn't exist.

The "c is faster than java" claim is simply not supported by facts.

That C makes it easier to get directly to registers, interrupt vectors, etc. is true. You need a language such as C, Bliss, GO, etc. that can easily handle that stuff.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2841
    
  11

C is a systems programing language, and thus well-suited for writing operating systems. Java is an applications programing language, which fixed many of the problems developers had when using C for application programing. C++ also attempted to modify C into an application programing language, but just ended up creating an ugly hybrid. C is still the undisputed king in systems programing, and regularly battles Java for the most popular development language. They have different focuses.

Naishadh Parmar
Ranch Hand

Joined: Jun 02, 2011
Posts: 95

Sorry everyone,
Thanks for enlightening me on this issue.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

No need to apologize! It was a good question and a good set of replies too.
Pratap koritala
Ranch Hand

Joined: Sep 27, 2006
Posts: 252
In Application Programming, You need to concentrate on the business logic.
Common things like, Memory References, and Memory management can be put out of developer hand.

But, On the other hand,
Operating system does lot of complex things, which are not feasible to write them in Java.
Even, Most of the Runtime's like JVM, or GC of OS X needs to be written in C.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why there is no Os built based on java
 
Similar Threads
Platform Independent
an optimistic group who stuck on VB 6.0
Platform Indepedent
I Want to Learn C As Additional Programming Language
Free JVM