3 ms·
It compiles the Java but what about the big VM needed? Found my answer: Note! When you compile a program using RoboVM it will translate not only the main class
by ape4 13y ago
It compiles the Java but what about the big VM needed?
Found my answer:
Note! When you compile a program using RoboVM it will translate not only the main class into native code but also the transitive dependencies of that main class. So the first time you compile a program for a particular CPU and OS RoboVM also compiles many of the standard runtime classes such as java.lang.Object, java.lang.String, etc. A simple class like HelloWorld references about 1500 classes directly or indirectly. RoboVM keeps a cache of compiled classes and only recompiles a class when it or any of its direct dependencies have changed.
Wow
- booop 13y agoThis is exciting. But wouldn't this result in very large final binary sizes?
- pjmlp 13y agoYes and no. This can happen even in languages like C when you do static linking. The solution is to have the linker remove all code that is not being called. The consequence of it, it that you are restricted in doing reflection, for example. Some Java native compilers allow you to provide a list of methods to leave alone, to avoid them being removed from the final executable.
- wiradikusuma 13y agoShould be able to use ProGuard, a code obfusticator+trimmer for Java. http://proguard.sourceforge.net/ http://proguard.sourceforge.net/ Although, from my experience doing Android with Scala, the process is slow.
- cheapsteak 13y ago"Read a few links on HN" slow, or "time to make some coffee" slow?
- tluyben2 13y agoYou only need it a few times when getting ready for distribution.
- tluyben2 13y agoWhat is large? Also, looking at software history, it will actually be cool in a few years to make binaries as large as possible. Files with random crap in them should be normal by then to show that you are the best value for money!
- pjmlp 13y agoWhy is this so special? This is basic compiler design 101. The Java VM is just a possible implementation for the Java language. The fact that many mix "Java the language", with "Java the Virtual Machine", is a consequence of the lack of knowledge in compiler design that seems so common nowadays.
- jerluc 13y agoThough I'd generally agree with your last statement (and relish in the amazement on one's face when I show them disassembled JVM bytecode for the first time), I'd have to say that this is still quite a "special" feat whether you've written a virtual machine/compiler/interpreter before or not. I haven't had enough time with the source as of yet, but I'd wager to say that there is most likely a lot more going on than just caching already-cross-compiled classes or basic opcode mappings. Not to forget that this project looks to be quite literally implementing from the JVM spec (a la Apache Harmony).