Amiga.org

Operating System Specific Discussions => AROS Research Operating System => Topic started by: falemagn on November 25, 2003, 10:10:11 AM

Title: Native Objective-C compiler available
Post by: falemagn on November 25, 2003, 10:10:11 AM
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 (http://www.aros.org/downloads/gcc-objc-3.3.1-aros.tar.bz2)

Just unpack it in the same directory where you unpacked the gcc/g++/binutils archive, and then you're ready to start compiling Objective-C stuff.

Enjoy :-)
Title: Re: Native Objective-C compiler available
Post by: bloodline on November 25, 2003, 10:13:45 AM
Maybe this is a weird question... But what is Objective-C? :-D
Title: Re: Native Objective-C compiler available
Post by: falemagn on November 25, 2003, 10:21:12 AM
Quote
Maybe this is a weird question... But what is Objective-C?


Ehm... a programming language?! :-)

Look here (http://www.cs.indiana.edu/classes/c304/) for more info.
Title: Re: Native Objective-C compiler available
Post by: crystall on November 25, 2003, 10:27:30 AM
It's an object-oriented programming language based on C which was developed by NEXT and was widely used in NEXTSTEP. Now it is a popular language on NEXTSTEP derivatives/clones like OpenStep or MacOS X. Personally I find it a much cleaner OO extension to C than C++.
Title: Re: Native Objective-C compiler available
Post by: bloodline on November 25, 2003, 10:33:46 AM
Quote

crystall wrote:
It's an object-oriented programming language based on C which was developed by NEXT and was widely used in NEXTSTEP. Now it is a popular language on NEXTSTEP derivatives/clones like OpenStep or MacOS X. Personally I find it a much cleaner OO extension to C than C++.


Oh? I must have a look...


Cheers for the link Fabio ;-)

Title: Re: Native Objective-C compiler available
Post by: crystall on November 25, 2003, 12:10:18 PM
You can find a fairly good guide on Apple's developer site at this link: Objective-C (http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ObjC.pdf)
Title: Re: Native Objective-C compiler available
Post by: bloodline on November 25, 2003, 12:36:03 PM
Quote

crystall wrote:
You can find a fairly good guide on Apple's developer site at this link: Objective-C (http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ObjC.pdf)


I hae only just got to grips with C++.. Object-C makes my head spin  :crazy:
Title: Re: Native Objective-C compiler available
Post by: minator on November 25, 2003, 02:34:41 PM
Quote
I hae only just got to grips with C++.. Object-C makes my head spin  


Objective-C is meant to be very nice, never used it myself but I've never heard any complaints about it.

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

IIRC The syntax is a lot closer to Java.
Title: Re: Native Objective-C compiler available
Post by: falemagn on November 25, 2003, 02:58:33 PM
Quote
Objective-C is meant to be very nice, never used it myself but I've never heard any complaints about it.


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.

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! :-)

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


Well, C++ isn't perfect, but it has its enormous advantages over ObjC.

Quote
IIRC The syntax is a lot closer to Java.


Not really, Java's syntax is practically the same as C++'s one.
Title: Re: Native Objective-C compiler available
Post by: Karlos 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 :-)
Title: Re: Native Objective-C compiler available
Post by: crystall on November 26, 2003, 12:56:22 AM
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.

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++) 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.
Title: Re: Native Objective-C compiler available
Post by: crystall on November 26, 2003, 01:06:15 AM
Quote
C++ Rocks. etc...

What you say is certainly true, C++ sports a lot of features which other languages miss and you list them completely. Some are nice, the first time I tried operator overloading I fell in love with it. The problem is that when you start working on other people's code you realize why Java, Objective-C and other OO languages have been invented: the syntax is a mess. Operator overloading is cool, but if you don't know exatly what the programmer meant for a particular operator it can be awkward to use. Dynamic and static calls are the same, you cannot notice a difference between the two from the syntax and a dynamic call can be very slow. Multiple inheritance is nice as long as you know exactly what's going on in your code. If you don't because you are extending classes written by others it can reserve you some really bad surprises. On top of that references don't make any sense to me, they look like they have been introduced just for solving problems of the language (like the copy constructor).
 The only thing which still makes me use the language for some purposes is template programming which is a really nifty feat. I hope that it'll be introduced in Java 1.5.
Title: Re: Native Objective-C compiler available
Post by: Karlos 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.
Title: Re: Native Objective-C compiler available
Post by: Karlos 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.
Title: Re: Native Objective-C compiler available
Post by: falemagn on 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?
Title: Re: Native Objective-C compiler available
Post by: Rodney 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 :)
Title: Re: Native Objective-C compiler available
Post by: Karlos 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.
Title: Re: Native Objective-C compiler available
Post by: crystall 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 :)
Title: Re: Native Objective-C compiler available
Post by: Karlos 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.
Title: Re: Native Objective-C compiler available
Post by: Cymric 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 (http://burks.brighton.ac.uk/burks/pcinfo/progdocs/cppcrit/#s3), 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.

Title: Re: Native Objective-C compiler available
Post by: Karlos 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.
Title: Re: Native Objective-C compiler available
Post by: nyteschayde 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 (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?
Title: Re: Native Objective-C compiler available
Post by: bloodline 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 :)