4 ms·
Rust is based on LLVM just like Swift, Pony, Crystal, etc to compile to native code. Java uses bytecode which will need to translate to machine code in JVM. No
by proyb2 9y ago
Rust is based on LLVM just like Swift, Pony, Crystal, etc to compile to native code. Java uses bytecode which will need to translate to machine code in JVM.
Node.js, Java, Go use Garbage Collection for use case where programmers do not have to manage memory.
- dronemallone 9y agoYou could use LLVM to compile any language to LLVM IR, and then to machine code using a backend. Does that mean every language has the same properties as Rust? If Node/Java/Go use GC (or VMs), then aren't they more safe than Rust?
- proyb2 9y ago> You could use LLVM to compile any language to LLVM IR, and then to machine code using a backend. Does that mean every language has the same properties as Rust? Nope, it's largely depend on the language design. > If Node/Java/Go use GC (or VMs), then aren't they more safe than Rust? Yes and No, memory allocation is one of the issue in GC. Go is generally more safe on networking but not security where Rust can manage it securely. This is a good read on Java vs Rust: https://llogiq.github.io/2016/02/28/java-rust.html https://llogiq.github.io/2016/02/28/java-rust.html https://news.ycombinator.com/item?id=14173716 https://news.ycombinator.com/item?id=14173716 https://github.com/stouset/secrets/tree/stack-secrets https://github.com/stouset/secrets/tree/stack-secrets In fact, we don't have to bother much with GC because it's depend on programmers and job availability. GC was created based on the idea that manage memory is hard for large scale project. It work well for Azul Systems, and they have recently advertised for LLVM engineer to bring more performance where JVM could not.
- rurban 9y agoParts are completely untrue. The JVM has the advantage to selectively jit-compile hot or small functions, whilst Rust has to compile all at once. Rust binaries are thus big, whilst you don't ship JVM binaries, you ship small bytecode. Go has the advantage of memory safety (via GC), plus better concurrency safety, which is lacking in Rust. There are concurrency safe languages, but not mentioned in this thread.
- steveklabnik 9y agoGo, in my understanding, is not memory safe even with its gc, and also doesn't have "concurrency safety" because of this. That's why https://golang.org/doc/articles/race_detector.html https://golang.org/doc/articles/race_detector.html exists. Rust however prevents these kinds of errors at compile time. Which things were you thinking of that Rust was lacking here?
- rurban 9y agoThe go race detector is still miles better than enforcing manual mutexes and locking in concurrent Rust code. Much better would be a proper type system to get rid of those at compile-time of course. Look at pony. And a better memory-safety system than RC.
- steveklabnik 9y agoYou don't always need those; it depends on what you're doing. And furthermore, that _is_ the compile time system that enforces things. Go's race detector can only prove the presence of things, not their absense. As for Pony, > Pony-ORCA, yes the killer whale, is based on ideas from ownership and deferred, distributed, weighted reference counting. That's it's GC.
- proyb2 9y agoWhat you mentioned JIT is exactly my thought when IBM explained why they like about Swift over Java in JVM. More technical explanation: https://www.ibm.com/support/knowledgecenter/SSYKE2_7.0.0/com.ibm.java.win.70.doc/diag/understanding/jit_overview.html https://www.ibm.com/support/knowledgecenter/SSYKE2_7.0.0/com... "In practice, methods are not compiled the first time they are called. For each method, the JVM maintains a call count, which is incremented every time the method is called. The JVM interprets a method until its call count exceeds a JIT compilation threshold. Therefore, often-used methods are compiled soon after the JVM has started, and less-used methods are compiled much later, or not at all. The JIT compilation threshold helps the JVM start quickly and still have improved performance. The threshold has been carefully selected to obtain an optimal balance between startup times and long term performance." > Go has the advantage of memory safety (via GC), plus better concurrency safety, which is lacking in Rust. Are there any examples you could list? One of Go GC issue is based on this stouset's discussion https://news.ycombinator.com/item?id=14174500 https://news.ycombinator.com/item?id=14174500