Welcome, Guest. Please login or register.

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

Description:

0 Members and 1 Guest are viewing this topic.

Offline falemagnTopic starter

  • Sr. Member
  • ****
  • Join Date: May 2002
  • Posts: 269
    • Show only replies by falemagn
    • http://www.aros.org/
Re: Native Objective-C compiler available
« Reply #14 from previous page: November 26, 2003, 01:23:59 AM »
Quote

crystall wrote:
Quote
Ok, here's one: it's slow. ObjC has dynamic typechecking and methods invocation is achieved via something akin AmigaOS' BOOPSI dispatchers, with the exception that ObjC dispatching can be a lot slower due to the fact that the "methodid" is the hash value of the method name, and computing hash values is slow.


This depends heavily on implementation, dynamic method calls in C++ can be just as slow. AFAIK Apple's implementation of Objective-C is very fast, basically the system keeps a cache of dynamic method calls to avoid to recalculate each and every time hash values, it works pretty well.


Yes, well, a simple caching mechanism is the least I'd expect from any objc runtime implementation, and it's the same technique implemented by gcc's runtime, however a method invocation is still about 3 times slower, in the average case, than a C++ virtual call (I'm citing some benchmarks I read about some time ago on the net).

In any case, where speed is not everything, I agree ObjC has its usage. It could be used for GUI stuff, for instance, and there the dynamic method dispatching and typecheckign can have its usages as well.

Quote

Quote
Add to that the strange syntax, completely foreign to the C syntax, it uses for classes interfaces/implementations and methods invocation, and you get another complaint. Whooo, we've got already two of them!


Yeah, that can be a problem, Obj-C syntax was borrowed from smalltalk so you can like it or hate it. Personally, having used BOOPSI a lot (which is quite influenced by smalltalk IMHO) I find it nice. Apart from class/methods definition (which are different from plain C even in C++)

Well, you simply need to put the class' name before the method's name. Not really that big difference.

Quote
the only addition to the language is the method call which is much different from a C function call and thus makes it pretty clear where you are using dynamic calls and where you're not.


But how do you know whether a simple function call doesn't make use, in turn, of a dynamic call?
 

Offline Rodney

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show only replies by Rodney
    • http://donthaveone.com/
Re: Native Objective-C compiler available
« Reply #15 on: November 26, 2003, 02:44:21 AM »
Quote

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.


I was never a big fan of java untill i used it. As a language it hink its pretty nifty, but i think once you compile you'r apps you've got performance to worry about in a big way.

I remember no one could get me to understand OOP and then i read one paragraph of learn C++ in 24 hours. I believe it was chapter 7 and it basicly related a class to a struct.

I think i may still prefer C++, although i believe i know less aobut it, even havign coded far more C++ than Java. But the one think i like about C++ and C obviously is pointers... I was porting a C application ones to Java, i first made it OO and did a few other things and since Java didnt really support pointer, i turned my pointers into one dimensional arrays :)

hehe... stupid java

EDIT - Oh yer, operator overloading :) gime some of that!!


Thats right, i cant contribute anything towards this topic :)
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Native Objective-C compiler available
« Reply #16 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 crystall

  • Newbie
  • *
  • Join Date: Nov 2003
  • Posts: 32
    • Show only replies by crystall
Re: Native Objective-C compiler available
« Reply #17 on: November 27, 2003, 05:06:21 PM »
Quote
But how do you know whether a simple function call doesn't make use, in turn, of a dynamic call?


You cannot obviously but Obj-C is usually used to build up OO application / frameworks using C at the lower levels so it is highly unlikely to have a function call a method. It kind of reverses the whole OO paradigm :)
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Native Objective-C compiler available
« Reply #18 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 Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show only replies by Cymric
Re: Native Objective-C compiler available
« Reply #19 on: November 28, 2003, 01:28:16 AM »
Quote
Karlos wrote:
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 ;-))

Ooooo... Bold statement, there. While I agree to a certain extent with you, and also realise that you wrote the text to promote rather than criticise C++, I cannot resist adding a few 'ifs and buts' for the sake of objectivism. (Is that a proper word?)

Quote
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.

This is just 'syntactic candy' which most good C-compilers already offer as an extension to standard ANSI-C. Useful, but on the other hand your programs will not compile using a regular C compiler anymore since the features they rely on are different in C and C++. Bottom line: If your program is in C, don't use a C++-compiler to compile it.

Quote
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.

C++'s object model is probably so succesful because it is so weak and allows the programmer to do everything. It's probably like C being not much more than assembly with a readable, if somewhat cryptic syntax. The discussion regarding single and multiple inheritance has passed beyond the qualification 'Holy War'. My opinion? Stick to single inheritance for as long as you can. Why? Simpler inheritance, cleaner OO model, and less chance of you shooting yourself in the foot as the amount of classes and objects begins to grow. In defense of multiple inheritance, I will say that I think the language should support it. Java's way, however elegant, requires the programmer to duplicate code unnecessarily, which is not a Good Thing.

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

Operator syntax is a nightmare if you didn't write the code you're supposed to be extending/maintaining/whatever. It's a feature which I think was added 'because we can': in most cases it is completely equivalent to using a normal, standard, human-readable function name. Sort-of-like C's ?: operator. To add insult to injury, most overloadable operators do not make intuitive sense with custom objects. Obfuscation at its worst.

Quote
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.

Eh?? Compositional structuring? What's that?

Quote
Love dynamic type checking? Thats what RTTI is for.

Indeed it is. But it isn't limited to C++. Any language with reflective capabilities can do this.

Quote
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.

Erm... Real wo/men probably do not need to work with other people's libraries as they write their own all the time, right? There are times when it is next to impossible to do manual memory management in an OO environment without causing memory leaks or major performance loss. In simple applications, DIY is probably more efficient, true. In big programs, use GC. It'll save hair and money. (Since you don't have to buy aspirin :-).) Speaking of GC, the technique has evolved over time. Collectors are now quite efficient; there really is no need to shy away from a proper GC implementation. Even for a tiny little program.

Quote
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.

Yep, nice feature. Until you encounter type promotion rules to figure out what instance of your template is called. Which is not fun, since noone can remember C++'s type promotion rules. Many implementations of templates are buggy and not very efficient too, so I'm not really sure whether templates are a Good Thing in practice.

Quote
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.

While I have little experience with coding in C++, I don't think that last statement is correct.  Unless you mean 'flexibility' by allowing every strict OO rule to be bypassed and excepted. Take this link, for example. You may find it interesting to see where exactly C++ is doing things which are strange and odd to say the least. (And that the little-known Eiffel is better at handling OO than is C++.)

 Of course I pretended to be the devil's advocate. There's plenty of examples where C++ delivers solid performance through elegant code. However, there is also plenty of opportunity to give in to 'The Dark Side of the Force', and you can legitimately wonder whether that is the language's or the programmer's fault. In the end, I feel that if you know about and accept the pitfalls, you can easily avoid them, and make sure you emerge relatively unscathed in case you have to walk into one.

Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Native Objective-C compiler available
« Reply #20 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
 

Offline nyteschayde

  • VIP / Donor - Lifetime Member
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 643
    • Show only replies by nyteschayde
    • http://www.nyteshade.com
Re: Native Objective-C compiler available
« Reply #21 on: November 12, 2013, 10:33:24 PM »
Quote from: falemagn;67265
It compiled out of the box, and appears to function properly, although I didn't have that many ObjC programs to test it with, so beware and pay the usual attention you pay with beta software.

If you're interested, you can find it here: http://www.aros.org/downloads/gcc-objc-3.3.1-aros.tar.bz2


I'd like to get ObjC working on my Amiga. This link is also no longer valid. Any ideas?
Senior MTS Software Engineer with PayPal
Amigas: A1200T 060/603e PPC • A1200T 060 • A4000D 040 • A3000 (x2) • A2000 Vamp/V2 • A1200 (x4) • A1000 (x3) • A600 Vamp/V1 • A500
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Native Objective-C compiler available
« Reply #22 on: November 13, 2013, 08:31:36 AM »
Quote from: nyteschayde;752607
I'd like to get ObjC working on my Amiga. This link is also no longer valid. Any ideas?
AFAIK the latest gcc for 68k Amigas should support Obj-C, but you will need to install a runtime :)