Welcome, Guest. Please login or register.

Author Topic: Native Objective-C compiler available  (Read 3949 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show all replies
Re: Native Objective-C compiler available
« on: November 25, 2003, 09:18:25 PM »
Quote

minator wrote:

I've never heard anything but complaints about C++!


Well, now you will hear differently...

C++ Rocks. It is the Uber systen level programming language, offering all things to all people. Most of the complaints I hear are down to the use of bad or outdated implementations or from people stuck into a totally entrenched way of thinking when it comes to programming paragdims (tosa ksereis tosa les ;-))

Don't care for OOP? Well, C++ compiles all good C clean code. You can make incremental improvements to old C code without totally changing it to OOP, take advantage of stricter type checking, better dynamic allocation etc. etc.

Love OOP? C++ offers the most flexible inheritance methods, far more potent than Java's miserable excuse for inheritance. You can use true multiple inheritance, you can ensure a given class is only inherited once in a heirarchy etc.

Only java programmers and heavily inbred people see singular inheritance as good genetics.

Want to use operator syntax in your class definitions? Not a problem. Try that in proper java...

Dont like inheritance as a primary means of extending properties? Bugger it, you can do compositional structuring too if thats what you prefer. Its easy to do runtime class composition using composition patterns.

Love dynamic type checking? Thats what RTTI is for.

Like garbage collection? Smart pointer libraries exist that can delete objects no longer referenced for people too scared to look after resources themselves.

Don't like automated garbage collection? Me neither as a rule (handy sometimes though) . Real wo/men of genius write proper virtual destructors and delete what the dont need when it is time to do so.

Too lazy to write classes for different implementations of a concept? Use templates and let the compiler create the various class dependent implementations of a template for you.

Don't like the templates generated for particular classes? Write specializations for those.

Theres countless other things I can't be bothered to mention. C++ gives C runtime efficiency (for well written code) and gives the best OOP flexibility of any language.

Bjaarne Straustrup, we salute you :-)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show all replies
Re: Native Objective-C compiler available
« Reply #1 on: November 26, 2003, 01:06:27 AM »
No amount of medhod address cacheing is ever going to be as fast as a normal C++ virtual function call unless the first entry in the cache is the one you need.

On any decent C++ implementation a virtual call is simply fetching a function address from a table referenced by the object you are invoking the method on.

That is at most two, statically indexed pointer dereferece steps.

The only time it is genuinely slow is if it causes some OS mechanism to kick in, such as a VM page miss or something.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show all replies
Re: Native Objective-C compiler available
« Reply #2 on: November 26, 2003, 01:13:18 AM »
@Crystal

I am not disputing that C++ has lots of gripes and confusing code can be written when its feature set is misued.

I am just attempting to present C++ in a more positive bias - I always hear people griping about the same old things, not one of which is really the languages fault.

If a programmer decides ot overload operator+ to do a multiplication for a class, is that the languages fault or the programmers?

Is a bad inheritance tree the languages fault, or again the programmers?

I dont find C++ syntax that bad, but agree it is odd in places.

I do find however, that java etc simply restrict the options which punishes good developers to keep the bad ones in line.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show all replies
Re: Native Objective-C compiler available
« Reply #3 on: November 26, 2003, 03:08:52 AM »
The niftiest thing in java for me is the way it handles threads.

A simple Thread class / Runnable interface pair itself is no big deal at all in C++ provided you know your target OS.

However, java's inbuilt support goes further than that. Access specifiers such as synchronized etc. are damn cool.

I also like the 'final' qualifier. For objects the 'constant after first assigned at runtime' is pretty neat, and for methods as an override inhibitor its quite cool too.

One thing I would like to see in any of these languages is an access specifier that makes member objects of a class 'read only' to the outside world, but behaves as read/write within the class itself. So much better than writing getSomething() methods for everything, dontcha think?

I did once play around with a template for this idea but it's not quite possible in the way I envisaged.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show all replies
Re: Native Objective-C compiler available
« Reply #4 on: November 27, 2003, 06:02:49 PM »
Maybe I misunderstood you, but you can have functions that arent part of a class call other classes' methods in plenty of legitimate OOP uses.

Consider, in C++, something like

Vector3D operator*(Vector3D& v, TransformMatrix& m);

Such a function cannot be a member of either class, but need to invoke methods of both.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show all replies
Re: Native Objective-C compiler available
« Reply #5 on: November 28, 2003, 02:34:50 AM »
@Cymric

As I already pointed out, I keep seeing the same old gripes about C++, Of those, 99% are down to things which are ultimately the programmers fault and not the languages.

C++ remains the most powerful and flexible language for writing code, IMHO. Just because you can mix paragdims doesn't make it something to be shied away from. C++ has never, ever pretended to be a pure OOP language, so slamming it for not being pure OOP is unfair.

About the flexibility issue. None of the features I mentioned are really brekaing the OOP rules, aside from compiling some old C code in C++.

Having functions not associated with classes isnt even breaking good OOP as long as you know when to use such things - see my earlier post about the operator overload for multiplying two different classes (a vector3d and matrix).

Operator overloading, multiple inheritence etc are not bad OOP. Using them badly, is bad OOP. emoving them altogether is just annoying and frustrating.

Bad misuse of a language is not the languages fault, but the programmers. I can write some absolutely awful java code too if I wanted to.

Just because they took out features to make it 'stricter' and more 'idiot proof' doesnt mean that it is a better language. it is just a simpler one.


PS : Oh yeah - compositional structuring. It's an alternative way of sharing properties between classes other than by inheritence. Instead of inheriting a class, you embed a reference (a pointer usually) to an object of the class who's properties you want to use.

Within your class you define methods (genrally simple inlines) that simply invoke the corresponding methods of the object you embedded.

Design patterns such as the 'delegation' etc. tend to use this.

Since the reference you embed can be (and usually is, since this is the intent of this design pattern) to a polymorphic class, what you basically get is basically a class that can be ultimately defined at runtime.

Commonly used for GUI style stuff.

-edit-

I should point out that compositional structuring probably isn't the correct definition for this paragdim (I can't remember the actual name but it was something like that), but what you actually create is a composite in the conventional OO sense of the word.
int p; // A