Would it be useful if TeaVM could run as a VM in the browser? #836
Replies: 2 comments
-
It would be possible if TeaVM could compile itself. In theory, there's nothing impossible, but in practice TeaVM uses a lot of Java class library that it still does not emulate. So the solution either to write these emulation or to refactor TeaVM itself to use only classes emulated by TeaVM. However, both tasks are huge (but I believe, the second one is a bit easier). Actually, I did some part of this task when I managed to run Java compiler right in the browser together with TeaVM, but then I just used dirty hacks to make it work (without things that just weren't supported). Additionally, TeaVM is pluggable and some parts of TeaVM code can be run at compile time in JVM (see metaprogramming API), so in this case it would be just impossible to use these APIs. TeaVM as a compiler needs a lots of downloads: class library classes, timezone database, CLDR, unicode data. So to only translate single jar file would result in huge downloads. Also, TeaVM running in a browser is much slower than TeaVM running in real JVM, so it will require eternity to wait until TeaVM does its job. I don't think it's really development mode solution, current one looks good to me. |
Beta Was this translation helpful? Give feedback.
-
Those are all good points I hadn't thought of. I remember the compiler example - it was very cool (though probably mostly to software nerds). That is probably what made me think this idea might be deceptively easy. :-) |
Beta Was this translation helpful? Give feedback.
-
This isn't a feature request, just curious whether this is feasible and/or useful:
Could TeaVM be enhanced to run in a webpage straight from a jar instead of having a compile step? I know this would result in a larger download (no dead code removal) and longer startup time (for initial JIT bytecode -> JS), but the simplicity of setup might be interesting for certain cases. And it might be an interesting development mode feature.
My favorite feature of TeaVM is how impossibly small my app downloads are - but I have wondered about this.
Beta Was this translation helpful? Give feedback.
All reactions