> On 7 Sep 2016, at 22:11, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>> On Sep 7, 2016, at 10:03 AM, Alastair Houghton 
>> <alast...@alastairs-place.net> wrote:
>> 
>> All of it can.  Objective-C is just C with some syntactic sugar on top.  
> 
> There’s a large amount of semantic sugar too, i.e. the runtime libraries. (If 
> you think the runtime part must be trivial, go read some of Mike Ash’s posts 
> about the implementation of objc_msgsend. That’s some of the most insanely 
> optimized code I’ve ever seen.)

Mike’s site is generally a good read for that kind of thing.  For those who 
don’t know:

  https://mikeash.com/

Incidentally, on the how-fast-is-objc_msgSend(), according to Mike’s latest Mac 
figures, it costs on average less than two C++ virtual method calls, and indeed 
less than division.  See

https://mikeash.com/pyblog/friday-qa-2016-04-15-performance-comparisons-of-common-operations-2016-edition.html

>> Really.  There’s nothing magic going on.  (In fact, the original compilers 
>> were really just preprocessors that churned out C code.)
> 
> You can say this about nearly any compiler, though.

Sort of, yes, but in the case of Objective-C I think there was a conscious 
intention to keep the Objective part separate from the C part.  Put another 
way, you could make Objective versions of most other languages, if you wanted, 
by making similar syntactic additions to them to the ones made for Objective-C, 
and that looks to me to be a deliberate design decision.  That’s not quite the 
same as C++ or Go, which were always intended to be complete languages of their 
own.

Anyway, the point I was trying to make (to Andreas) was that he shouldn’t be 
scared of using Objective-C because it’s going to do all kinds of magic in his 
program that he doesn’t understand.

> But yes, you can use the Obj-C runtime API from C to do pretty much anything 
> you can do in Obj-C, like calling methods and implementing classes. It’s just 
> much, much messier, error-prone, and difficult to read compared to writing 
> the damn code in Obj-C.

Absolutely.  IMO Andreas really *should* just use Objective-C for the 
Mac-specific bits of code.

> There’s no pride in refusing to switch languages. I abjured C++ a long time 
> ago, but guess what, my current project is 99% C++ because that language best 
> meets the performance and portability requirements.

Same here, as it happens.  C++11/14 is *much* better than the previous 
iteration, though it’s still lacking in some areas.

> Next time maybe I’ll be using Swift, or Rust, or Pony. C is an ancient, 
> primitive language and it’s not a good career move to refuse to move past it 
> :)

Agreed.  I’d love to be using Swift right now, actually, but I have portability 
concerns it doesn’t address and the language itself is still not stable.  Both 
will resolve themselves.  Rust and Pony look interesting also.

Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to