28 ms·
Way over my head here , but can someone perhaps explain the value and/or use-case of running c within a jvm?
by realitysballs 4y ago
Way over my head here , but can someone perhaps explain the value and/or use-case of running c within a jvm?
- dan-robertson 4y agoThe equivalent of link time optimisation with Java, perhaps?
- rvieira 4y agoI could be wrong, but can't Truffle languages freely interoperate within the JVM? (https://www.graalvm.org/22.0/reference-manual/polyglot-programming/ https://www.graalvm.org/22.0/reference-manual/polyglot-progr...)
- aardvark179 4y agoSo, many dynamic languages have a C API that allows you to write methods in C, and for those methods to do things to objects of the higher level language. This is normally a big optimisation boundary because you have to assume any value could have been altered during a C call. However if you run your C extensions through the same framework as you implement your hogh level language then you can remove that optimisation boundary entirely.
- Tiddles-the2nd 4y agoAs an interpreter, it could be very powerful for development, prototyping, and developing POCs.
- EmilyHughes 4y agoMostly migration of legacy programs probably, so companies can say they ported their stuff to java. It's stupid but companies do it.
- pawelmurias 4y agoWhy is just running say your Ruby existing program on Truffle with a big performance gain stupid? A lot of the languages use C extensions and running them on the JVM is faster then using the FFI to call them from the JVM.
- kgeist 4y agoIt's easier to gradually refactor a legacy program to a different language using the Strangler pattern when they run on the same runtime and there's easy and performant interoperation between old and new code. I wouldn't call it stupid.
- EmilyHughes 4y agoyeah but in most cases it's better to just rewrite everything fresh. it's more of quick fix to me.
- kgeist 4y agoWe are actively in the process of rewriting a legacy system using the Strangler pattern, 50 devs and 2 years later it's still less than 50% because business wants new features as well, they can't afford waiting 1-2 years with no business value added in the meantime.
- pantulis 4y agoRewriting everything fresh is not always an option in terms of cost and opportunity.
- kaba0 4y agoI believe it’s more about truffle’s llvm interpreter (which is perhaps the successor of this project), but one motivation is that many scripting languages (python, ruby) use C (and fortran) libraries extensively through FFI. Truffle can give these scripting languages a huge boost in performance (TrufflyRuby is 3x faster than the second fastest implementation), but the JVM “doesn’t like to” rely on FFI all that much - and also, truffle is polyglot with the ability to optimize between different languages. So by creating an LLVM interpreter, ruby or python calling into that can be also optimized by e.g. inlining, in certain cases bettering the performance compared to native FFI. Other than becoming truly cross-platform, running on top of a singular runtime gives it the ability to observe these parts as well (which in itself a huge advantage because the JVM has some killer observability tools), so for example project loom might be applicable to a python script using C libs for IO, putting the whole on a virtual thread and making its blocking calls unblocking magically.
- captaincaveman 4y agoBenefit of the JVM without the bloat of the Java language. I suspect particularly for resource constraint systems, RAM in particular. Not particularly convinced myself!
- pjmlp 4y agoGraal is a JVM implemented in Java....