News for hackers. Stuff that matters.
Re:Swift 3.0 Unsafe World by pjmlp on Tuesday September 27, 2016 @10:52AM (#12589998)
Completely wrong.

GC was dropped from Objective-C, because Apple did not manage to make it work safely with C semantics.

Objective-C developers weren't able to mix Frameworks compiled with and without GC, there were lots of corner cases and forum discussions regarding GC runtime crashes were quite common.

Apple's decision in such scenario was to take the alternative route to make the compiler do what the Cocoa manual reference counting patterns already required.

Nothing to do with being faster and more memory efficient, rather having something in Objective-C that would work at all.

However this urban myth keeps being repeated.

Re:Swift 3.0 Unsafe World by ridiculous_fish on Tuesday September 27, 2016 @12:36PM (#12590885)
Saying that GC "didn't work at all" isn't right: it did work and it shipped. Xcode dogfooded GC, and Xcode is not a small app.

There were definitely pain points, including C interop. But these could have been worked through. Apple is good at these sorts of transitions - think x86 or 64 bit, which had the same issues (can't mix 32 bit and 64 bit frameworks, etc).

Probably if Apple had not started making mobile devices, ObjC would have retained GC. But mobile devices had performance requirements that GCs struggle to meet. It's too broad to say that ARC is "faster and more memory efficient"; rather it's more efficient in the ways that are important to Apple. For example, avoiding pause times is more important than total allocation throughput (have to avoid dropped frames). Memory high-water-mark is more important than fragmentation. etc. Servers are the reverse.

Note that GC has been painful on all mobile platforms, not just iOS. That's why Microsoft has taken a step back from GC (WinRT uses ARC). And in Android, GC is one of the most common drivers of performance issues, and avoiding GCs is a key optimization technique. The compiler even warns on allocations inside functions like onDraw().

Re:Swift 3.0 Unsafe World by pjmlp on Tuesday September 27, 2016 @12:51PM (#12591002)
Microsoft has not taken a step back from GC, rather WinRT is built using COM, which requires RC to make C++ happy.

Android GC has been quite behind the state of the art from what production embedded JVMs like Aonix and Websphere Real Time are capable of. Actually Dalvik was left in limbo for quite awhile before they eventually came up with ART.

So it is easy to just generalize GC vs RC without regarding what algorithms are actually being used, and the qut of said implementations.

There are military weapons control systems and factory robots using real time GC implementations of Java in hardware much more constrainted than a smartphone.

Re:Swift 3.0 Unsafe World by ridiculous_fish on Tuesday September 27, 2016 @01:27PM (#12591321)
Microsoft built their next-generation platform around RC instead of GC, despite their enormous investment in .NET, and years spent pushing it. That's clearly taking a step back.

It may be the embedded world has very advanced GCs that would perform well on modern mobile platforms, and just nobody has gotten around to integrating them yet. I don't know! But embedded devices with predictable workload that you can model and test are quite a different beast from a general-purpose computer, so that remains to be proven.

Re:Swift 3.0 Unsafe World by pjmlp on Tuesday September 27, 2016 @03:21PM (#12592271)
The problem in GC vs RC and decisions taken by companies, is that many times the decisions are political and not technical.

The outcome of Singularity and Midori is a proof of it, in spite of the outcomes prooven by their research, the projects were killed by management.

At least they allowed some of the tech to be repurposed for .NET Native.

Re:Swift 3.0 Unsafe World by gakada on Tuesday September 27, 2016 @12:26PM (#12590809)
Basically in the unrealistic situation of a closed system, GC can be faster. But it makes FFI significantly harder (e.g. V8 API)
Re:Swift 3.0 Unsafe World by pjmlp on Tuesday September 27, 2016 @12:44PM (#12590952)
Not necessarily, in many GC enabled systems programming languages you can also allocate outside GC heap.
Re:Swift 3.0 Unsafe World by Joky on Tuesday September 27, 2016 @12:19PM (#12590744)
It's OK to point something as "Completely wrong" and as a "Urban myth", but a source is appreciated.
Re:Swift 3.0 Unsafe World by pjmlp on Tuesday September 27, 2016 @12:42PM (#12590933)
The source are the Apple developer forums and WWDC sessions.
Re:Swift 3.0 Unsafe World by coldtea on Wednesday September 28, 2016 @05:40AM (#12596454)
How about Chris Lattner, who implemented that in Obj-C and then Swift?

>>Has a GC been considered at all? >GC [also] has several huge* disadvantages that are usually glossed over: while it is true that modern GC's can provide high performance, they can only do that when they are granted much more memory than the process is actually using. Generally, unless you give the GC 3-4x more memory than is needed, you’ll get thrashing and incredibly poor performance. Additionally, since the sweep pass touches almost all RAM in the process, they tend to be very power inefficient (leading to reduced battery life). I’m personally not interested in requiring a model that requires us to throw away a ton of perfectly good RAM to get an “simpler" programming model - particularly on that adds so many tradeoffs.*

So it's hardly "completely wrong", especially for iOS.