3 ms·
why not just use C++ or something and never deallocate memory then?
by anthonypasq 6y ago
why not just use C++ or something and never deallocate memory then?
- layer8 6y agoMalloc is usually slower than GC-based allocation (which basically just increments a pointer). Of course, one can emulate this via custom allocators in C++. My guess is that Java development is just easier and quicker, and the JIT may even result in more effective optimizations than AOT compilation.
- mathieubordere 6y agoin C++ they could also try using Profile-guided optimization to optimize hot code paths.
- amelius 6y agoIn C++ you can link with your own version of malloc (one which just returns the next consecutive block, and can be implemented simply by adding the allocated size to a pointer).
- oppositelock 6y agoYou generally choose the language which has the libraries and ecosystem which solves your problem. For instance, you'd be silly to use anything but Java to work with Hadoop. This is the pragmatic choice.
- ptx 6y agoBut as soon as you make use of almost any library from the ecosystem, you get allocations. Doesn't that defeat the purpose? Why not isolate the Java-using part in a separate process from the non-allocating fast part?