Re: Newer features in Objective C

David Chisnall <[email protected]> Mon, 13 Feb 2023 10:32:17 +0000
Newsgroups gmane.comp.lib.gnustep.devel
Message-ID <[email protected]>
On 13/02/2023 00:52, Gregory Casamento wrote:
> Richard,
> 
> On Wed, Feb 8, 2023 at 09:57 Richard Stallman <[email protected] 
> <mailto:[email protected]>> wrote:
> 
>     [[[ To any NSA and FBI agents reading my email: please consider    ]]]
>     [[[ whether defending the US Constitution against all enemies,     ]]]
>     [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> 
>     GNU Objective C supports the features that Objective C had in 1989.
>     It would be nice to add the newer Objective C features.
>     Is anyone interested in doing that?
>     Please write to me personally if you sare intested in working on this.

This is not true.  Nicola Pero added declared properties a while ago, 
and exceptions were already there.  GCC is more or less feature-complete 
with respect to Objective-C circa 2005.  Apple subsequently invested 
quite a few person-years of engineering effort on adding more modern 
features, the largest of which is ARC.  Subscripting is a fairly simple 
transform, which would probably be quite easy to add to GCC.  Some of 
the other things, such as direct methods, require some careful design 
work (the interaction between +initialize and direct methods is annoying 
and I haven't yet come up with an ABI that would cause them to be a 
performance win).

> I, personally, have the knowledge, but not the time.  I think that is 
> the situation with a number of us, but I certainly don’t speak for us 
> all.  We had hoped that someone in the existing GCC community might be 
> willing to take this on if it’s to be done on a volunteer basis.

I have tried to persuade GCC folks to do this a few times, but there are 
a few problems:

  - The current Objective-C code in GCC is *awful*.  I started working 
on Objective-C support in clang because it was less work to add 
Objective-C codegen to clang *from scratch* than it was to add fairly 
simple features that it was missing at the time (declared properties) to 
GCC.  If anything, that code has become even harder to work with in the 
intervening years.

  - The license for GCC means that none of the companies that might have 
funded this work 10 years ago were willing to touch it.  This has not 
improved.

> It’s my belief that this is a pretty large effort.  It will likely be 
> multiple weeks or months of effort for one person to do as it involves 
> adding a number of missing features.  In your email you say that GCC 
> supports the features from 1989… that’s true but there are also SOME 2.0 
> features that have been implemented but it is not complete so we have, 
> in effect, Objective C 1.5. :)

That is *incredibly* optimistic.  Adding ARC support requires some very 
subtle work related to lifetimes and has a lot of interactions with 
other features (e.g. C++ copy constructors).  I would put the estimate 
in person-years, not less.

> I am wondering if it might be necessary for the FSF to hire someone to 
> do this outside of the community (or within if that’s an option).
> 
> I am not sure what the way forward on this is at this point.

I see two viable options:

  - Publicly acknowledge that GCC has not supported Objective-C for 15+ 
years, remove Objective-C support from the next release of GCC, and let 
GNUstep focus on working with compilers that do support the language.

  - Ensure that there is a pot of at least half a million dollars 
available to properly fund the work on GCC and contract an experienced 
developer to work on it full time for the next two years (or a company 
with a team of developers for a shorter period) and then be on retainer 
to fix the bugs going forward.

If the FSF has half a million to spend on Objective-C support in GCC 
then that money could be *far* better spent on improving other bits of 
GNUstep.

David