Firstly, I think I may have titled this question poorly, but I couldn't think of the right words, so please, feel free to suggest an edit and I will make it, so that the question is more educational and relevant to others.
I know that javax.Swing simply cannot be used for an Android project, and I've accepted this and learned Android XML based UI design, but just out of curiosity, I want to know exactly why.
I realize that the screen dimensions of a phone might be something Swing wouldn't handle well, but what is to stop a developer from simply importing the javax.Swing package (besides Android Studio simply not letting it happen in the first place), however deformed and hideous Swing windows might be on an Android device screen? I also realize that AWT and SWT would also have to be imported, but the same question applies to these packages as well.
I think my lack of understanding of this might really root from a lack of understanding of how the Java Virtual Machine and the Android equivalent (is Dalvik still used, or have they switched cold-turkey to ART?).
As always, any information or reading on the subject you can provide is greatly appreciated. I really want to learn more about the fundamentals of how the JVM, Dalvik, and ART work.
DVM converts bytecode every time you launch a specific app. ART converts it just once at the time of app installation. That makes CPU execution easier. Improved battery life due to faster execution.
JVM is stack based but DVM is register based which is designed to run on low memory. JVM uses java byte code and runs '. class' file having JIT (Just in Time) where DVM uses its own byte code and runs '.
Difference between ART and Dalvik Approach: ART uses AOT(Ahead Of Time) approach and compiles the whole code during the installation time but the Dalvik uses JIT(Just In Time) approach and complies only a part of the code during installation and rest of the code will be compiled dynamically.
There are at least three fundamental differences:
The latter point means that as a result, there is still no mainstream support in Android of try-with-resources which appeared in Java 5 years ago; various efforts have seen the day to support this plus Java 8's "goodies" over time, but none of them is really Java "at the core"; understand, they do not use the JVM, they do not use the Java compiler.
Recent news tells that this is bound to change in "Android N" (which will actually use OpenJDK). Which is good news. Also, as to point 1, you may recall that infamous Oracle vs Google case with regards to APIs being copyrightable... This is still not completely settled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With