3 ms·
Does languages don’t belong together. Java and C# sure. They use sophisticated garbage collectors and target intermediate code. Nim, Crystal and Swift all comp
by socialdemocrat 6y ago
Does languages don’t belong together. Java and C# sure. They use sophisticated garbage collectors and target intermediate code.
Nim, Crystal and Swift all compile to native code and is designed for that.
Swift is not a GC language in the normal sense since it uses automatic reference counting. That is fully deterministic and with low latency. There is no stop the world to collect garbage like with Java and C#.
Swift is akin to C++ code with smart pointers.
- bitmapbrother 6y agoIsn't reference counting a form of garbage collection, though? If you want performance then Objective C and Swift aren't the languages you should be using. There's a reason why Apple recommends C/C++ if you need your code to run as fast as possible and also the reason why the high majority of professional games are written in C++ with either a thin Objective C / Swift wrapper. Also, you can compile both Java and Kotlin to native images with Graal. https://www.graalvm.org/examples/java-kotlin-aot/ https://www.graalvm.org/examples/java-kotlin-aot/
- the_duke 6y agoYou can group languages in different ways. VM vs native is one way, but you can also go by the level of abstraction they provide, which very much puts them in the same category. Also, this debate comes up every time, but ARC is widely classified as a form of garbage collection, just not a tracing one. It is transparent and automatic to the user. (Well, apart from cycles)
- viktorcode 6y agoI disagree with that classification, as there's no "garbage" state for references as they are destroyed immediately. All garbage collecting languages on the other hand have period of time where the references are intact but marked as garbage. FWIW Chris Lattner, the language creator, put Swift into a non-GC camp.
- pjmlp 6y agoBecause he needs to sell it, and Apple developers got a bad taste of Objective-C GC implementation that never worked out properly. Widely acknowledged CS books see it differently, https://gchandbook.org/ https://gchandbook.org/
- pulse7 6y agoEven in Swift the references are not "destroyed immediately" but because of various performance optimizations this "garbage state removal" is deferred - for example to the end of scope... The truth is, that they >>don't want to call it GC<< for marketing and other reasons... One could implement ARC with cycle collector for Java as well - and it would be just another form of GC... it would use less memory (because garbage would be released faster), but it would be slower...
- mega-tux 6y agoNim is also working on ARC https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc...
- pjmlp 6y agoC and C++ also target intermediate code, LLVM, GIMPLE, TIMI, TenDRA,... Java and C# also targeet native code, .NET Native, CoreRT, IL2CPP, Mono AOT, SubstrateVM, GCJ, ExcelsiorJET, OpenJ9, PTC, Aicas,... Languages and implementations are orthogonal.