Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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…



Java 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.


I 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.


Yes, C# is the best language to write a phone OS in if you want to go out of business.


Other languages need special hardware to beat C#, so I guess the language wasn't the issue.

https://github.com/ixy-languages/ixy-languages

https://blog.metaobject.com/2020/11/m1-memory-and-performanc...


There is no "special refcounting hardware" in the M1, it has exactly what I said it has above this. Alas, nobody trusts me…




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: