OS (kernel) programmed in Java or in C [closed] - java

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm going to start building operating system and I don't know which programming language to choose for kernel. My favorite language is Java but I know that all major operating systems (Windows, Linux, Mac OS) is programmed in C, moreover Java requires virtual machine. Does it would be much harder to program than Java-based OS than C-based OS? What are the advantages and disadvantages of each of these languages?

http://wiki.osdev.org is an extremely useful site on that matter. It tells you how to build your toolchains, which language options that are available, and has some great example code.
Yvan

I would humbly suggest that you truly learn a programming language before trying to build an operating system, after which you would realize in which languages you can or cannot write kernels in yourself.
Programming languages such as Java simply does not offer the low-level routines necessary to create an os. You can implement your OS in c or c++. Unless you master bootstrapping code (read assembler) and a programming language such as c, it would be a good idea to reconsider a perhaps easier task.
You could however emulate an OS by running it as a program in another OS, in which case you may experiment with any language of your choise.

Does it would be much harder to program than Java-based OS than C-based OS?
How would you write the hardware-level programming to handle interrupts in Java?

There seem to be several Java-based OSs already out there. I don't know a lot about OS-programming, but there seems to be quite an extensive literature (altough a lot of it in German) about a Java-based OS called JX, from the University of Erlangen: http://www4.informatik.uni-erlangen.de/Projects/JX/publications.html
Maybe there is something there to help.
Writing a C-based OS should be the easiest, though, simply due to there being so much more information about it.

You won't be able to program an OS kernel in Java unless you have access to a compiler that will compile Java into machine language. Java requires a virtual machine which interprets the byte code and executes native instructions (that rely on the kernel). You must be able to interact directly with the hardware in order to program an OS which is something you simply can't do with Java. Your only option, really, is C mixed with assembly.

The JVM provides an awful lot of OS-like capabilities, and it can't be written in Java -- so either way, you're going to end up writing an awful lot of the code in C (or something that can produce code that doesn't require a virtual machine).

Related

C++11(native code) vs Java(bytecode) [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Lately I've been thinking about the difference about native and bytecode.
I did some research and all information I've read was about C++ code compiled into native code vs Java code compiled into bytecode(runs on JVM which takes advantage of multi-core processors). The conclusion was that applications written in Java run faster.
Does C++11 change this?
Does applications written in C++11(since adds threads) run faster than Java ones?
The conclusion was that applications written in Java run faster.
That's a big leap to come to. There are so many factors which contribute to the performance of a system that it's very hard to say one approach will always be better or even faster than another.
C++ has always been able to use threads, it just didn't have as much detail on how they could be used. I don't believe C++11 is about performance but standardising things like memory models.
IMHO Given any amount of time and expert developers, a C++ program will always be faster than a Java program. However, given a limited amount of time and developers of mixed ability you are more likely to get something working and performing well in Java. Your mileage will vary. ;)
Making my answer clearer...
Does C++11 change this?
No. I don't agree it is the situation nor does it change it.
Does applications written in C++11(since adds threads) run faster than Java ones
Yes, but not always, Just like earlier versions.
Neither C++ nor Java automatically split your program into multiple threads. The closest you can get to automatic parallelization in modern languages is to use parallel collections. There are libraries to do that in C++ but there is better support for that kind of stuff in more functional languages e.g. Haskell, Scala, Clojure.
Another way to get automatic parallelization is to use an actor library and write your entire program with actors. Erlang was the first language with full support for that but the Akka framework for Scala/Java is also very good.
I would just say All Your Java Bases Are Belong To C++.. The JVM itself is written in C/C++. C/C++ run at native speeds on the bare-metal of the machine, while bytecodes are interpreted by a C/C++ code(that's running on top of the metal). One byte-code instruction could translate to about 5-10 asm instructions(or more). Hence speed of execution of C/C++ is considered faster than Java's. Ofcourse, if Java's runtime were thrown onto the metal and we had bytecode interpreted at machine speed, then it would be a fair comparison.
That said, see an example in the book called "Programming Pearls" where the author runs an interpreted BASIC program on a Radioshack personal computer, which with sufficient optimizations, runs faster than it does on a super computer. Which means, speed of execution of your program depends on your algorithms and coding/optimization practices.

Portable Runtimes? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Intro
One of the coolest things about Java is that the JRE has a very small footprint as well as being highly portable, so I can run my application on nearly any platform with ease, and without having to integrate into the operating system linked libraries or C:\Windows\System etc - that is, the JRE can be run from within a folder.
.NET struggles in this regard - especially with size. Mono is becoming an ever popular choice but there seems to be too many dependencies that the Operating System needs to have.
Question
Are their any other RUNTIMES/languages (Perl, Ruby) that have this similar functionality that I mentioned above?
Again (1) Portability (2) Multiple OS support (AIX, Solaris, Linux) (3) Size for re-distribution over a network (4) Easy to Install and Deploy.
AIM
I'm looking for a light-weight run time or language that can be deployed on a server as easily as the JRE is.
For example: If I had to use Python, that would require added libraries to be installed on OS etc. Perl would be a good example, found on most Linux but endless hassle of for version and getting a third-party library.
ANSWER!!!!
This was CLOSED because it was thought to not be RELEVANT.
But FYI for those who this may help; outside of JRE, LUA is probably the most portable not requiring dependencies and compiles or system integration.
Ruby is not quite there, although it's default on most Linux (not on BSD)
BSD comes with Lua though :)
Lastly, Jruby is not practical, as it may use the JRE (20MB) and then JRuby itself (16MB).
Some thoughts for someone considering a deploy across multifarious "OS's" and being portable enough to distribute without consuming excessive bandwidth.
Thanks
JVM and .NET are only virtual machines, that interpret bytecode. There are a lot of language on top of them.
JVM
Java
Groovy
Scala
JRuby
Jython
JavaScript (Rhino)
Clojure
etc.
.NET
C#
VB.NET
Nemerle
J#
Boo
IronRuby
IronPython
etc.
There are another VM and script languages that can be run across the platform, i.e. Parrot that is Perl 6 VM or Lua that is X-platform script language (i.e. WoW use it). There are also project like LLVM (Low Level Virtual Machine) but this is still a little bit platform dependent.

lazarus or Java [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I have a Delphi background, also C++ background. But last several years, I involved in web projects, and worked primarily with PHP. Now I am looking for a platform to develop simple desktop applications (interacts with server). I was thinking of Java as I am used with Eclipse IDE, and have C++ background. But I see Lazarus became a mature environment. its applications even work on Java Virtual Machine. In the past I have seen that some Amateur looking technologies have became popular than professional ones like PHP, Flash even Object Pascal. So should I choose Java, or lazarus for desktop application development.
If you have a C++ background, try the Nokia Qt framework which has everything you want to develop desktop application. the Qt SDK is shipped with its own IDE (which's really great) and rich APIs.
Enjoy :)
Of the two options, I would certainly choose Java (larger support base, more stable, more 3rd party libraries, etc).
You mention that you come from a C++ background. Why not just use C++ (theoretically easier than picking up a new language).
If Lazarus runs on the JVM, it should have access to the same libraries as every other JVM language, so you'd be learning swing, etc.
If you are going to do desktop apps and you want a decent GUI toolkit you really have two choices as far as I know, either go with a JVM language or .net
If you go with a JVM, why in specific Lazurus? There are dozens (well technically hundreds--possibly thousands) of JVM languages to choose from. Go with anything stable that helps you get the job done.
Hmm, that is UNLESS you don't work alone. If you work with others, I suggest Java (or C#) period (Maybe Scala). Otherwise you will have a heck of a time hiring and training.
There are also probably C++ GUI frameworks, even cross-platform sometimes but none will be as rich as everything that is available on the JVM or .net platforms.

why java number one? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
Why is Java the most used programming language ? Why are the most programmers jobs for Java ?
Don't get me wrong here ? I like Java and I work in Java ? I don't have anything against it ?
Also, I'm trying to learn some other stuff out of the OOP box, like Clojure with its functional programming.
But, I'm wondering, why is Java number one ? I mean, dynamic languages (Ruby, Python, Php, JavaScript) people says that static types languages (Java, C/C++, C#) people envy them for their productivity ? They say they get the job done faster...
Ok then, if dynamic languages are more productive, how come Java stands where it stands ?
It was backed by a major commercial company Sun -- which other business value when decided on adopting such things.
It continued in the syntactic tradition of C++ -- already a widely used language at the time. In many ways, it was sold as a far improved C++.
It came with batteries included -- the framework.
Superb marketing effort of write once / run everywhere (platform independence).
The fear of Microsoft's dominance at the time forced a lot of companies to collaborate in the Java endeavor, notably IBM.
I don't think other languages on your list had these qualities (even if I fall into the dynamic/productivity camp). Arguably Python filled some of those niches at the time.
Typically it's easier for people to conceptualize in imperative languages with garbage collection (C#, Java)
Spolsky considers Java to be an easy language, he has a famous post on it.
Java is well-defined and thus easier for formal analysis efforts
Java runs on most modern platforms without massive grief
Java is "enterprisey", by which I mean it seems to be heavily adopted and developed by large corporations, which, due to sort of a best-practice risk-minimization approach, means other large corporations will also use it.
Java is taught in many universities.
Just off the top of my head...
Huge potential user base.
Large set of libraries.
Established community.
Fast VM.
Platform independent.
It's free.
It's been around for ages.
Some of the factors that have given Java its popularity are:
Its Maturity
Easiness to learn
Great API
Also, due to its philosophy of "Write Once Run Everywhere", Java programs are extremely portable and the Java platform itself is quite mature, in terms of the kind of applications that can be developed with it; not to mention the plethora of new languages that are being developed to run on the JVM.
Remember, most used, doesn't mean better; for many purposes you'll find that Java simple falls short of a viable solution.

Usefulness of JNI [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I've been a java developer for a couple years and have heard that you can do some pretty useful and powerful things with JNI. I don't know if I just haven't needed to use it or if it isn't terribly relevant to me; but I have not had to touch it at all.
I am wondering what the usefulness of this aspect of Java is. Examples would be great.
It is very useful. I can see 2 primary reasons to use JNI (there are likely more).
Performance. If you have a piece of code in which the Java Runtime for whatever reason can't cut it performance wise. You can implement that function in native code and call it from Java. This allows you to hand tune the implementation if you really need to. This is likely the least common reason though, Java usually performs just fine.
Access to OS Specific APIs. This one is a biggie. I've had a case where I needed to do something in Java but also needed access to something that Java simply could not provide. In my case it was UNIX domain sockets. Since (as you can tell by the name) they are UNIX specific, there is no standard Java way to use them. So I made a class that acted like a wrapper around them in C and accessed it with JNI. viola, problem solved.
I have written an extensive JNI layer for the iSeries to access DB2, user queues, data queues and a few other OS/400 specifics. Much of our system on the iSeries would have been impossible without JNI. So, yes, JNI has it's place, and when you need it, you really need it.
It's relatively difficult (next to pure Java), but powerful and not horrible.
Also, whenever I am looking at some JNI code, I also consider using JNA.
I can think of a few uses off the top of my head:
integration with existing low-level
(C/C++) APIs that do not have a Java
counterpart
integrating with aspects
of the system that are not exposed
through available Java APIs (direct
hardware access, etc.)
Some might say it can be useful for creating highly-optimized sections of code however with modern JVMs you're getting pretty fast and the complications of using JNI would probably outweigh any performance benefit you might see.
There are a few uses for binding to FFMPeg for C-decoding of (damn near any) video/audio format.
There's also JNA, which makes it like you are using the library itself. This is "easier" from the standpoint that it passes everything to the Java developer to manage, and harder in the sense that you have to figure out the structure mapping and do a lot of grunt work to get all the pointers, etc, to pass correctly.
We had an requirement to wrap a new UI around a legacy C application running on Suse Linux. JNI was the perfect tool for the Job.
In general I think JNI is a contradiction to the Java notion of Write Once, Run Anywhere. However there are use cases where JNI can be useful.

Categories

Resources