soffes / HotKey

Simple global shortcuts in macOS
MIT License
921 stars 82 forks source link

Update Readme to mention HotKey instance must not be de-allocated #27

Closed ospfranco closed 3 years ago

oliverepper commented 4 years ago

There’s no garbage collection in Swift. It will be removed from the heap because of the automatic reference counting.

ospfranco commented 4 years ago

@oliverepper Garbage collection is just a generic term to any mechanism that automatically de-allocates items from memory, reference counting (AFAIK) is just one of the many ways to achieve this, so in fact Swift IS garbage collected, am I wrong?

ospfranco commented 4 years ago

@oliverepper wikipedia seems to agree with me (check the reference counting part) https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)

oliverepper commented 4 years ago

Yes. You might be right. Haven't thought about it that way. My guess is that you're right and GC is in fact a generic term. I see it used for something opposed to ARC often, though. Maybe some compiler/language-guy can jump in here?

P.S.: Even the Wikipedia article you linked states the difference between GC and ARC in the Objective-C section.

P.P.S.: After further reading I guess there's a distinction to be made between GC (which happens at runtime, extra thread) and ARC (which happens with the help of the compiler, inserts release-statements). So I guess you cannot say that Swift is a garbage-collected language.

ospfranco commented 4 years ago

Screenshot 2020-05-18 at 10 15 12

it doesn't matter if it is done on compile time or on runtime, if you don't manually de-allocate memory it is garbage collection

oliverepper commented 4 years ago

Would be nice if you linked to that instead of a screenshot. Can you do that? I think there's a distinction to be made between what is generally perceived as GC (even if technically wrong) and ARC where the programmer is involved in memory management at least with preventing retain cycles.

In the context of your pull-request I don't think that this discussion is even necessary.

ospfranco commented 4 years ago

Alright, I can see that I'm going against the marketing here, I'm sure a computer scientist would agree that ARC is just another way of GC, in any case, I will modify the wording a bit to please the gods