3 ms·
What's wrong with Python, Java, C#, etc? Conversely, while better at avoiding footguns than C, Zig doesn't provide quite the same memory safety - although to be
by guitarbill 3y ago
What's wrong with Python, Java, C#, etc? Conversely, while better at avoiding footguns than C, Zig doesn't provide quite the same memory safety - although to be fair, better is still worth it.
- jandrewrogers 3y agoSecurity is not the only dimension that matters, resource efficiency and scalability matter too. A big driver in the use of C++ is that it is more efficient than Python, Java, etc by an integer factor in real workloads. No one wants to increase data center sizes by 4x (or more) to run the same workload. Being that wasteful isn't environmentally friendly.
- musicale 3y ago> No one wants to increase data center sizes by 4x (or more) to run the same workload 1000 C++ servers vs. 100,000 Python servers is a big reason to avoid Python.
- BaculumMeumEst 3y agoSome performance critical software cannot afford garbage collection.
- pasc1878 3y agoWhich is why Apple put GC in Objective C and then removed to and Swift does reference counting. To keep iPhone apps responsive, they saw problems with apps using GC.
- pjmlp 3y agoNot at all. They removed tracing GC from Objective-C, because it was a failure when dealing with C semantics. Automating retain/release calls was a much easier and safer approach, hence plan B. In any case, reference counting is a GC algorithm.
- musicale 3y agoI am certain that one of the reasons Swift uses reference counting is to achieve more predictable performance and to avoid the GC pauses that plague Java etc. Another may be that it simplifies the runtime for system code such as kernels and device drivers.
- astrange 3y agoIt's not just that, reference counting is friendlier to non-uniform memory access, which is what you have on a system with swap and/or memory compression. In compacting GC, the compacting part can help here, but the GC part doesn't. But people do use GC on their phones, insofar as they like to use web browsers.
- pjmlp 3y agoSwift uses reference counting, because it interoperates with the Objective-C runtime, duh. .NET interop with COM is a good example of how mixing a tracing GC with a reference counted runtime requires an higher engineering budget that Swift team most likely wasn't willing to spend resources on. It has been proven multiple times that reference counting is slower and has performance issues when dealing with large graphs, and also stop-the-world issues when cascade deletions occur. If only pro-RC folks would bother to read CS papers and benchmarks.
- frou_dh 3y agoMore like peak memory use is higher with GC than RC and they wanted to avoid having to put twice the RAM in iPhones.