3 ms·
> then my program is now running with 10 GC's each trying to optimize itself Is this true with Java? I thought it's a single runtime that manages memory in al
by jb1991 4y ago
> then my program is now running with 10 GC's each trying to optimize itself
Is this true with Java? I thought it's a single runtime that manages memory in all the code/libraries in your process.
- Jensson 4y agoFor java the virtual machine provides the GC for everything, but then you can only use JVM libraries and not libraries in other languages. The reason C and C++ libraries can easily be included in basically any other language is that they don't have a GC, so there are no such issues, just call the functions and things works fine.
- jb1991 4y ago> Major problem with GC languages is that it is horribly to link against libraries that ships with a GC. I'm curious which GC languages do this. The most popular ones that come to mind for me are anything on the JVM, JS, and Go, and I've never heard anyone point this out about them.
- Jensson 4y agoEvery language with a GC has this problem. If you want a library to be used in both Java and Python you don't write it in either Java nor Python, you write it in C++ or another language without a GC and import that to Java and Python. Trying to import a Java library in Python or vice versa is horrible, since GC's are very hard to work with from outside the language ecosystem.
- int_19h 4y agoI don't know about Java, but it's trivial to import a .NET library in Python with a high-level mapping that takes care of everything GC-related automatically: http://pythonnet.github.io/ http://pythonnet.github.io/ I don't see any reason why something like this cannot exist for Java, if it doesn't already.
- lukaslalinsky 4y agoBut this is exactly the point, it is possible, but once you import such library into Python, you are running both Python runtime and .NET runtime, both having their own GC implementations and many other processes.
- nicoburns 4y agoLibraries work fine in GC languages if they're written in that language. But you can't easily take a library written in Java and import it into your Python project (you can do it, but it's not efficient, and the more languages you include the less efficient it gets). Whereas libraries written in C/C++/Rust/etc can have binding in every language without issue. Consider libraries like zlib or curl and SQLite that are ubiquitous is across every language ecosystem. Those are the libraries that need (well, greatly benefit) from being written in a non-GC language.