Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #14747

Re: How different is obj c from c++?

From woodbrian77@gmail.com
Newsgroups comp.lang.c++
Subject Re: How different is obj c from c++?
Date 2012-03-04 14:36 -0800
Organization http://groups.google.com
Message-ID <24211118.688.1330900581793.JavaMail.geo-discussion-forums@ynca15> (permalink)
References <ji37ma$fdn$1@dont-email.me> <4f46213b$0$4388$7b1e8fa0@news.nbl.fi>

Show all headers | View raw


On Thursday, February 23, 2012 5:21:31 AM UTC-6, Juha Nieminen wrote:

>   That article concentrates mostly on minutia and skips the most *important*
> differences between the two languages.
> 
>   Where Objective-C shines:
> 
>   - Objective-C has full runtime introspection and reflection.
> For example, you can take an anonymous object (ie. an object from
> which you know *absolutely nothing*, ie. you don't have any kind of
> class declaration) and check if it, for example, has a method with
> a certain signature, and then call that method if that's so. (C++
> has basically zero support for this.) You can likewise determine at
> runtime if an object is of a certain type or derived from it (similar
> to C++'s dynamic_cast), is exactly of a certain type, implements a
> certain interface, or contains a certain member variable.
> 
>   - As a consequence of the above, you can call a method (well,
> technically speaking "send a message") whose signature has been
> created at runtime (ie. was not determined at compile time).
> (In principle it could be possible, for example, to have a class
> definition as a text file which is parsed and interpreted at runtime.)
> Yet calling Objective-C methods is suprisingly efficient (constructing
> a selector eg. from a string is not efficient, but once you have the
> selector, sending it to an object is surprisingly efficient).
> According to my tests calling an Objective-C method is only about
> 6 times slower than calling a raw C function, which is impressive
> considering the amount of dynamicity involved.
> 
>   - Likewise because of the above you can create an object of the same
> type as another object, without having to know what that type actually
> is (iow. even if you have a completely anonymous object). In C++ you have
> to know an object's exact type in order to create another one of the same.
> 

They should change the name to Foggy or Hazy.  Am glad you mention 
the performance cost for this.

Brian
Ebenezer Enterprises
http://webEbenezer.net

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How different is obj c from c++? Lynn McGuire <lmc@winsim.com> - 2012-02-22 11:12 -0600
  Re: How different is obj c from c++? BGB <cr88192@hotmail.com> - 2012-02-22 15:10 -0700
    Re: How different is obj c from c++? Lynn McGuire <lmc@winsim.com> - 2012-02-22 16:18 -0600
  Re: How different is obj c from c++? Juha Nieminen <nospam@thanks.invalid> - 2012-02-23 11:21 +0000
    Re: How different is obj c from c++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-02-23 13:35 +0000
    Re: How different is obj c from c++? Tobias Müller <troplin@bluewin.ch> - 2012-02-23 19:26 +0000
      Re: How different is obj c from c++? Juha Nieminen <nospam@thanks.invalid> - 2012-02-24 07:22 +0000
    Re: How different is obj c from c++? Peter Remmers <p.remmers@expires-2011-04-30.arcornews.de> - 2012-02-23 22:19 +0100
      Re: How different is obj c from c++? Juha Nieminen <nospam@thanks.invalid> - 2012-02-24 07:30 +0000
    Re: How different is obj c from c++? woodbrian77@gmail.com - 2012-03-04 14:36 -0800
    Re: How different is obj c from c++? Lynn McGuire <lmc@winsim.com> - 2012-03-04 17:38 -0600
      Re: How different is obj c from c++? Juha Nieminen <nospam@thanks.invalid> - 2012-03-05 08:40 +0000
  Re: How different is obj c from c++? Stuart Redmann <DerTopper@web.de> - 2012-02-28 12:37 -0800
    Re: How different is obj c from c++? Juha Nieminen <nospam@thanks.invalid> - 2012-02-29 07:54 +0000
      Re: How different is obj c from c++? Stuart Redmann <DerTopper@web.de> - 2012-02-29 01:09 -0800
      Re: How different is obj c from c++? Peter Remmers <p.remmers@expires-2011-04-30.arcornews.de> - 2012-02-29 20:17 +0100
      Re: How different is obj c from c++? William Ahern <william@wilbur.25thandClement.com> - 2012-02-29 14:54 -0800
        Re: How different is obj c from c++? BGB <cr88192@hotmail.com> - 2012-02-29 23:33 -0700
        Re: How different is obj c from c++? Juha Nieminen <nospam@thanks.invalid> - 2012-03-01 06:51 +0000

csiph-web