3 ms·
> What are the options for sharing an object between threads then? It works fine, it’s just not done that often. (Specifically contended refcount changing isn’
by astrange 6y ago
> What are the options for sharing an object between threads then?
It works fine, it’s just not done that often. (Specifically contended refcount changing isn’t done, which is why having fast uncontended atomic helps.) Transferring between threads happens and just works.
ObjC has explicit weak pointers and ways to move destructors to another thread and it all works. Though you could use C# or JavaScript in your app, many people do.
Actually, PHP and Python do use refcounting internally, I think PHP only GCs on exits from functions…
- kaba0 6y agoI don’t get your point. Of course refcounting is a possible and working solution, but it’s not an accident that Java, JS, and C#, languages with the best GCs, doesn’t use it.
- astrange 6y agoYes, C# is the best language to write a phone OS in if you want to go out of business.
- pjmlp 6y agoOther languages need special hardware to beat C#, so I guess the language wasn't the issue. https://github.com/ixy-languages/ixy-languages https://github.com/ixy-languages/ixy-languages https://blog.metaobject.com/2020/11/m1-memory-and-performance.html https://blog.metaobject.com/2020/11/m1-memory-and-performanc...
- astrange 5y agoThere is no "special refcounting hardware" in the M1, it has exactly what I said it has above this. Alas, nobody trusts me…
- pjmlp 6y agoJava and .NET also have weak references. Also C# can do everything that Objective-C is capable of, provided one actually knows how to use the language. CPython uses a mix of refcounting with a cycle collector tracing GC, other Python implementations use tracing GCs. The language does not specify GC semantics and counting on them is a recipe to break code when moving across implementations.