Why jvm is written in c++, any specific reason.? [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I know that JVM is written in c++ but my primary question is java being good language probably better than c and c++, what is the necessity of writing it in c++. Any specific reason? just to want to know it might help others while facing interview at least. please dont debate as this forum doesnt support. Please give me solid reasons. thank you.

Java code needs the JVM to execute. However C++ is compiled into machine code, so it is executed more or less by the hardware.
Thus you can see that to write the JVM using java, would mean that you need a JVM to run the JVM... hence not possible..
This is the same with most if not all interpreted languages. They are written in C / C++. Typically C since that was more stable when the language was taking shape (e.g perl), and also because it is seen as being more light weight and faster (?) than C++.

When going from the design of a language X to the implementation, one thing is sure : you don't have access to language X tools because they don't exists yet. You need to use language Y.Now once you have language X running you can say you completely switch implementation from Y to X. But there is a cost : You are written a new software which should behave exactly like an old one. If the benefits outweighs the costs, then it can be a viable option.

Related

Techniques for converting OO C++ to Java (No conversion tools) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have looked around, and there are no solid guidelines to converting Object Orientated C++ to Java. Most are references to conversion tools.
My question is what are the steps one should take to not get overwhelmed and lost, especially for heavily OO projects.
For example, given one method that accomplishes a task. That method is called, which is dependent on several other cpp, and those helper methods are also dependent on other cpp files, and so on. How should this be addressed?
What are techniques that can be used to break it down, while properly combining .hpp and .cpp?
I understand JNI can be used, however, it is desired to have only Java code, unless something can literally only be done in C++
Tips, suggestions, and ideas will be much appreciated.
PLEASE do NOT mark this as a DUPLICATE, there are only questions posted in respect to specific code, or using conversion tools, not for general techniques.
Also, if this is a terrible question, let me know, I'll take it down, no need to thumb it down. Thank you.

Should I make web services for in Java or PHP? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a question:
I'm rying to make web services for Android but I don't know which language (PHP or Java) I should write on according to the ability of scaling the website for different devices.
One of the primary structural differences between PHP and Java is the
difference between strongly- and weakly-typed languages. Java is a
strongly-typed language, meaning it requires explicit statements of
intent to function and that it is backed by a compiler. At the highest
level, you can think of this as meaning it has strict expectations on
how you express inputs and outputs. If these exact expectations are
not met, the compiler will fail and the program will not work until
errors are resolved.
PHP, in contrast, is weakly typed, essentially meaning it is more
flexible and reliant on “common sense programming” in how a task is
accomplished. While this may sound more attractive because it
requires less formal knowledge, some contend that it complicates
certain tasks, particularly in object oriented programming, with its
lack of standards.
Choose according to your needs
Everything depends on what you want to do on this website.
But here is a Link of a blog that discusses which is better:
PHP vs JAVA

Java: How do I get values from the other programs? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
To make the question more understandable, there is a software called CheatEngine, and basically what it does is, it collects all the bytes of the software that you're trying to work with and you can select any of those and change the value.
For example you want to change the score of any game. You can search for the value of the current score, and change it to what ever you would like.
Now the question is, is it possible to create something like that using java, that would take all the data from the memory, that the software you're trying to "hack" in to, uses?
Let me know which sources should I look up for.
P.S. If the post got grammar mistakes, I am sorry. I am from Russia and I am not the best in English language.
Java is very restricted in direct memory access (for a good reason), so it is very unlikely this can be done with Java. The JNI can perform (managed or unsafe) OS operations, so you could try calling any C function that returns the data at a given memory location, but I suppose you would be better off with using C in the first place (not Java), then.
By language definition java runs in a sandbox in the JVM. So it is impossible to access other places in the memory outside of it. Also Java cannot access specific positions in the memory, there are no pointers.
As I know you java doesn't provide support to access the memory directly. If you still wanna access the memory you have to use JNI. But then that is not a good option either.
So I think best way is to give up on Java for your purpose and try to use C or C++. C#.NET would be a possible too.
P.S
As #PhilipWhitehouse suggest may be there is a way with sun.misc.Unsafe package. Try to read on http://mishadoff.com/blog/java-magic-part-4-sun-dot-misc-dot-unsafe/

Multithreading implementation - pro and cons between java and C [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a task to extend an implementation of an ongoing project written in C that is already working well, so that it will be multi-threaded.
I have many years of experience with Java, but very limited for C. So basically I have some options like the following:
Rewrite all of the code to Java and later implement multi-threading in Java
Implement multi-threading in Java by calling some methods from C library through JNI
Learn C and continue the task in C.
By considering that the multi-threaded version does not have to get the latest update from the C library, and probably later I might need to put these code in some big data framework like Hadoop.
In order to find out which option could be better for me, I would need comments about the following questions based on what you have already experienced before.
How smooth it will be to call a C function from Java and if there is any significant limitation?
What are the pro and cons of implementing multi-threading in C?
And also which option that you think is better?
I would go on 3. Multithreading relies on few basic concepts of mutex and semaphores, both in the POSIX standard, and I would recommend you learning them. The C concepts are really basic, the most difficult thing you have to learn will probably be pointers so nothing hard. Having coded multithread projects both in Java and in C I would recommend C (having an hard Java background it's difficult to say for me! ) to learn an important part of POSIX standard (used in Unix too), not to depend on extern libraries and virtual machines. If you want to do it in Java, I would exclude solution 2 and make a standalone Java project, it has appropriate libraries to support multithreading.

Limitations (drawbacks) of java programming language? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am a beginner in java programming language, I have recently studied basic concepts of java programming language. I just want to know, What are the limitations of Java programming language in terms of memory management and other run time related issues.
Thanks in advance.
Java is OO programming language. Within that realm, considering static typing, there aren't much limitations. Java works well. At present JVM does not do tail call optimization, which can be considered a limitation. But that is limitation of the JVM, not the language. With Java 8 there are closures, and anonymous functions. The syntax is a bit ugly, but it's kind of ok. So we can't complain there. However, when comparing to functional languages (thinking Haskell), I miss array comprehensions, lazy evaluation the most.
The way in which Java approaches concurrency is using threads with shared data. We know that shared data can make parallel programming difficult. If Java has build in mechanisms for message passing like ZMQ or green threads (like Kilim) with no shared data, it would be cooler. But earlier on during the design phase they choose green threads, but later on moved to native ones for performance gains. Concurrency using STM (Software Transactional Memory) would be make great addition to java.utils.concurrent library. These aren't limitations per se, they can be added at a later point in time, using JSRs. But at present we do not have such mechanism.

Categories