public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Objective-C vs. gcj (was: Re: Newbie questions)
  2000-04-01  0:00   ` Objective-C vs. gcj (was: Re: Newbie questions) Jeff Sturm
@ 2000-04-01  0:00     ` Kresten Krab Thorup
  2000-04-01  0:00       ` [OFFTOPIC] " Joerg Brunsmann
  2000-04-01  0:00     ` Per Bothner
  1 sibling, 1 reply; 10+ messages in thread
From: Kresten Krab Thorup @ 2000-04-01  0:00 UTC (permalink / raw)
  To: Jeff Sturm; +Cc: Tom Tromey, Maury Markowitz, java-discuss

Jeff Sturm <jsturm@sigma6.com> writes:

> > When you say "weak" typing, what do you mean?
> 
> He means Objective-C doesn't do any compile-time binding or even
> checking of method invocations.  Every instance variable can be declared
> as "id" which is equivalent to Java's java.lang.Object class.  

Equivalent is not quite right.  The type `id' is a super-type for all
other types (including root classes such as Object); and indirections
(i.e., method calls) via a reference of type `id' are runtime
type-checked.  The compiler will issue warnings in some cases, i.e.,
if it has not "seen" a method declaration with the given name.

> method name is misspelled or can't be resolved at runtime for any
> reason, a runtime error is thrown and the program generally aborts
> (which I consider a drawback of the language).

Right.

> Note that the Java _language_ is strongly typed though bytecode is
> not... all names are dynamically resolved from bytecode, just as in
> Obj-C.

Java byte-code is stronly type checked.  The Verifier implements
almost the exact same semantics checks as the compiler does.

> > What is categorization?

The term `categories' stems from Smalltalk terminology.  In the file
format for `filing in' code in a ST system, there is syntax that
allows methods to be added to existing classes.  This is exactly the
functionality of categories.  In Objective C, such categories can be
loaded at runtime.

> Objective-C has a neat feature which makes it extremely simple to write
> delegate classes.  The runtime attempts to dispatch a method invocation
> to the named method, but if a method is not found it defaults to the
> "forward:" (?) method, which can be overridden to route the invocation
> to another object, or even marshal the arguments for delivery to a
> remote object.  Obj-C had a very elegant solution to distributed
> programming that way.
> 
> Similar tricks could be performed with Java reflection, I'd guess.

In Java, this is not possible; it would require a change to the
language semantics.  The new 1.3 proxy stuff does something that comes
close, though.

-- Kresten

 Kresten Krab Thorup           "I like my eggs ploded"
 Department of Computer Science, University of Aarhus
 Aabogade 34, DK-8200 Aarhus N, Denmark
 +45 8942 5665 (office), +45 2343 4626 (mobile)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Objective-C vs. gcj (was: Re: Newbie questions)
  2000-04-01  0:00   ` Objective-C vs. gcj (was: Re: Newbie questions) Jeff Sturm
  2000-04-01  0:00     ` Kresten Krab Thorup
@ 2000-04-01  0:00     ` Per Bothner
  1 sibling, 0 replies; 10+ messages in thread
From: Per Bothner @ 2000-04-01  0:00 UTC (permalink / raw)
  To: Jeff Sturm; +Cc: java-discuss

Jeff Sturm <jsturm@sigma6.com> writes:

> Back when the GCJ project first became public, I was a little curious
> why the C++ frontend was chosen for native integration, when Obj-C is
> available and much closer to Java in spirit (both languages rely heavily
> on runtime method dispatch, both have single-inheritance, etc.).  I
> strongly suspect the answer has mostly to do with the popularity of C++
> and relative obscurity of Obj-C, though there may be technical issues as
> well.

Using Obj-C never ocurred to us, and I suspect it wouldn't have made sense.
One reason is that Cygnus has never supported Obj-C in its products
(customers get it as an unsuuported freebie), or done noticable work on it,
so we didn't have in-house expertise.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Newbie questions
@ 2000-04-01  0:00 Maury Markowitz
  2000-04-01  0:00 ` Tom Tromey
  0 siblings, 1 reply; 10+ messages in thread
From: Maury Markowitz @ 2000-04-01  0:00 UTC (permalink / raw)
  To: java-discuss

Hi,

  I'm an Obj-C developer (using gcc) over on the OS-X platform and  
I'm looking for migration and exit strategies for both myself and  
other developers in our market space.  Apple's "commitment" to Obj-C  
is, well, let's call it "unclear".  I'm both a compiler tech and Java  
newbie, so I'll ask for your forgiveness in advance if some of these  
questions are complete no-brainers.

  First and foremost I'm curious about the ability for gcj's  
compiled code to be used as libraries for Obj-C code on top.  IE, if  
I were to use gcj and it's associated libs, what sort of work effort  
would it be to have them work as Obj-C libraries?  Is library format  
an issue at all? (I'm assuming not, but I'll ask to be sure) Is the  
main issue going to be supplying a selection of wrappers in the form  
of .h files?  It "feels" like there is a runtime changed needed to  
Obj-C, and I'm curious if anyone could comment on the level of change  
needed, if any?

  The other question I have relates to extensions and the legality  
thereof.  We Obj-C developers have come to love the language's  
flexibility in terms of "weak" typing and notably in the form of  
categorization.  It seems to me that if you're going to  
native-compile code anyway, extensions like this to Java would no  
longer break it's security orientation.  Would it be possible to  
create a sub-standard, say "Obj-J", that would add in these features  
without ending up on someone's (like Sun's) *&%# list?

  This isn't quite as important to me, if I could use Obj-C over  
gcj's libs this may be a non-issue anyway.  I ask simply because  
there may be uses who wish to stay completely in the Java syntax (for  
good reasons) but sill have access to some of the power of  
categorization, proxies, etc.

  BTW, kudos to all involved in this project.  This is exactly the  
sort of practical response to the Java hype that I think the market  
needs.  I'm still experimenting, but I think gcj's potential for  
mixing my compiled code against bytecode and compiled libs may be  
just the solution I'm (and I think many others) are looking for.

Maury

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Objective-C vs. gcj (was: Re: Newbie questions)
  2000-04-01  0:00 ` Tom Tromey
@ 2000-04-01  0:00   ` Jeff Sturm
  2000-04-01  0:00     ` Kresten Krab Thorup
  2000-04-01  0:00     ` Per Bothner
  0 siblings, 2 replies; 10+ messages in thread
From: Jeff Sturm @ 2000-04-01  0:00 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Maury Markowitz, java-discuss

Tom Tromey wrote:
> Maury> First and foremost I'm curious about the ability for gcj's
> Maury> compiled code to be used as libraries for Obj-C code on top.
> Maury> IE, if I were to use gcj and it's associated libs, what sort of
> Maury> work effort would it be to have them work as Obj-C libraries?
> Maury> Is library format an issue at all? (I'm assuming not, but I'll
> Maury> ask to be sure) Is the main issue going to be supplying a
> Maury> selection of wrappers in the form of .h files?  It "feels" like
> Maury> there is a runtime changed needed to Obj-C, and I'm curious if
> Maury> anyone could comment on the level of change needed, if any?

Wow.  It's been awhile since I've even heard Obj-C mentioned, let alone
done any  work with it... I'll take a stab at your questions though.

> libgcj is just a library like any other library.  It just happens to
> be implemented in a miaxture of C++ and Java.  However, it has some
> requirements that other libraries probably don't have.  For instance,
> it relies on the existence of a garbage collector (this isn't the only
> requirement, but it is one of the big ones).

But libgcj is gcj's runtime, and gcj-compiled code can't run without
it.  Similarly, the Objective-C compiler has a runtime (it is bundled
with GCC in the gcc/objc directory) and is useless without it.  It
handles all the method dispatching and dynamic binding required by the
Obj-C language.

These two libraries can probably coexist in one address space, but that
isn't very useful unless Obj-C code can call Java code, which it can't
right now.  (It could via JNI, once JNI is implemented, but that's not a
very pretty way to go about it.)

> You can use this library from C++ right now.  Using it from ObjC would
> require knowing how to make the library bootstrap (not too hard), plus
> a knowledge of how to call C++ from ObjC (we've purposely made
> compiled Java mostly compatible with compiled C++; I don't know
> anything about ObjC so I can't help you there).

Unfortunately, the Obj-C and C++ frontends don't work together.  (NeXT
had made the changes necessary to mix C++ and Obj-C, even within one
source file, but their changes never made it back into the GCC
distribution.)

Back when the GCJ project first became public, I was a little curious
why the C++ frontend was chosen for native integration, when Obj-C is
available and much closer to Java in spirit (both languages rely heavily
on runtime method dispatch, both have single-inheritance, etc.).  I
strongly suspect the answer has mostly to do with the popularity of C++
and relative obscurity of Obj-C, though there may be technical issues as
well.

> However, that doesn't mean I'm necessarily in favor of making any
> extensions to the Java language.  I'm pretty sure you'd be on your own
> in terms of implementing the changes; there are too many pieces still
> missing for us (meaning those of us at Cygnus hacking gcj, or at the
> very least just me) to do this sort of thing.  Another factor is that
> every extension makes the compiler more difficult to understand and
> modify.  I'm told the C++ compiler hackers have found random g++
> extensions to be a real pain over time, so this is something to be
> wary of.

I would personally steer clear of extending the Java frontend, for the
same reasons as Tom.  That doesn't rule out the possibility though that
some other language could share the libgcj runtime.  If the Obj-C
frontend is to have a meaningful existence in the future, it should
probably abandon its current runtime and embrace libgcj.  Most of what's
there is Java-centric, but it could likely be used for Obj-C as well. 
The Java reflection stuff that Tom just finished would certainly come in
handy.  The Object class differs somewhat from java.lang.Object, but
that could be possibly be remedied by making Object a subclass of
java.lang.Object, or maybe even introduce a new root class.

(These are just ideas off the top of my head... I won't be working on it
since I quit Objective-C programming at least 5 years ago.)

> When you say "weak" typing, what do you mean?

He means Objective-C doesn't do any compile-time binding or even
checking of method invocations.  Every instance variable can be declared
as "id" which is equivalent to Java's java.lang.Object class.  If a
method name is misspelled or can't be resolved at runtime for any
reason, a runtime error is thrown and the program generally aborts
(which I consider a drawback of the language).

Note that the Java _language_ is strongly typed though bytecode is
not... all names are dynamically resolved from bytecode, just as in
Obj-C.

Java still provides class casts, which allows you to sort of defeat the
type system, though ClassCastException is thrown on illegal casts. 
Casts tend to be widely used anyway in Java, especially with
collections, since (as in Obj-C) Java has no support for templates or
generic types.

> What is categorization?

I can't think of a good analogy... IIRC Obj-C supports extending
existing classes (adding methods, instance members, etc) using
categories.  It's not the same as inheritance, somehow.  Sort of like
peer objects, as in java.awt, only more transparent.

> When you say "proxies", what do you mean?

Objective-C has a neat feature which makes it extremely simple to write
delegate classes.  The runtime attempts to dispatch a method invocation
to the named method, but if a method is not found it defaults to the
"forward:" (?) method, which can be overridden to route the invocation
to another object, or even marshal the arguments for delivery to a
remote object.  Obj-C had a very elegant solution to distributed
programming that way.

Similar tricks could be performed with Java reflection, I'd guess.

-- 
Jeff Sturm
jsturm@sigma6.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Newbie questions
  2000-04-01  0:00 Newbie questions Maury Markowitz
@ 2000-04-01  0:00 ` Tom Tromey
  2000-04-01  0:00   ` Objective-C vs. gcj (was: Re: Newbie questions) Jeff Sturm
  0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2000-04-01  0:00 UTC (permalink / raw)
  To: Maury Markowitz; +Cc: java-discuss

>>>>> "Maury" == Maury Markowitz <maury@oaai.com> writes:

Maury> First and foremost I'm curious about the ability for gcj's
Maury> compiled code to be used as libraries for Obj-C code on top.
Maury> IE, if I were to use gcj and it's associated libs, what sort of
Maury> work effort would it be to have them work as Obj-C libraries?
Maury> Is library format an issue at all? (I'm assuming not, but I'll
Maury> ask to be sure) Is the main issue going to be supplying a
Maury> selection of wrappers in the form of .h files?  It "feels" like
Maury> there is a runtime changed needed to Obj-C, and I'm curious if
Maury> anyone could comment on the level of change needed, if any?

I'm not entirely sure I know what you are asking.

libgcj is just a library like any other library.  It just happens to
be implemented in a miaxture of C++ and Java.  However, it has some
requirements that other libraries probably don't have.  For instance,
it relies on the existence of a garbage collector (this isn't the only
requirement, but it is one of the big ones).

You can use this library from C++ right now.  Using it from ObjC would
require knowing how to make the library bootstrap (not too hard), plus
a knowledge of how to call C++ from ObjC (we've purposely made
compiled Java mostly compatible with compiled C++; I don't know
anything about ObjC so I can't help you there).

Maury> The other question I have relates to extensions and the
Maury> legality thereof.  We Obj-C developers have come to love the
Maury> language's flexibility in terms of "weak" typing and notably in
Maury> the form of categorization.  It seems to me that if you're
Maury> going to native-compile code anyway, extensions like this to
Maury> Java would no longer break it's security orientation.

I think we can do whatever we want, basically.  Of course we'd always
want to provide a way to make the compiler pedantic, just as we do
with C and C++.

However, that doesn't mean I'm necessarily in favor of making any
extensions to the Java language.  I'm pretty sure you'd be on your own
in terms of implementing the changes; there are too many pieces still
missing for us (meaning those of us at Cygnus hacking gcj, or at the
very least just me) to do this sort of thing.  Another factor is that
every extension makes the compiler more difficult to understand and
modify.  I'm told the C++ compiler hackers have found random g++
extensions to be a real pain over time, so this is something to be
wary of.

When you say "weak" typing, what do you mean?
What is categorization?
When you say "proxies", what do you mean?

Tom

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [OFFTOPIC] Objective-C vs. gcj (was: Re: Newbie questions)
  2000-04-01  0:00     ` Kresten Krab Thorup
@ 2000-04-01  0:00       ` Joerg Brunsmann
  0 siblings, 0 replies; 10+ messages in thread
From: Joerg Brunsmann @ 2000-04-01  0:00 UTC (permalink / raw)
  To: java-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]

Kresten Krab Thorup wrote:

> The term `categories' stems from Smalltalk terminology.  In the file
> format for `filing in' code in a ST system, there is syntax that
> allows methods to be added to existing classes.  This is exactly the
> functionality of categories.  

The last time I used Smalltalk-80 based systems such as VisualWorks or 
Squeak categories were a mechanism to collect classes which logically 
belong together. For example the classes 'String', 'Symbol' and 'Text'
are grouped in the category 'Collections-Texts'. Obviously you see the 
analogy to java packages. The big difference and disadvantage of 
putting a class into a Smalltalk category doesn't imply a different 
namespace. But, the latest VisualWorks implementations do have namespace
facilities. Furthermore, the initial idea behind categories was not the 
ability of grouping together during fileins. If you filein a class whose 
category doesn't exists, it will be created. Also, Smalltalk-80 based 
systems allow to group methods of classes into a unit which are called 
protocols, e.g. 'new' and 'from:' into the protocol 'instance creation'.

Jörg

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Newbie Questions
  2002-05-06 10:55   ` Clemens Eisserer
@ 2002-05-06 13:01     ` Tom Tromey
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2002-05-06 13:01 UTC (permalink / raw)
  To: Clemens Eisserer; +Cc: java

>>>>> "Clemens" == Clemens Eisserer <linuxhippy@freemail.de> writes:

Clemens> Hmm, maybe i didnt ask right... Is the code-output of gcj
Clemens> native code or is it just "tarned" as executable and
Clemens> interpreted by libgcj?  Are also all imported java-classes
Clemens> (java.io.*.....) nativly compiled or will they be "linked" by
Clemens> the libgcj and interpreted (.clss-Files).

You can compile either to bytecode or object code, it's up to you.

Tom

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Newbie Questions
  2002-05-06 10:13 Newbie Questions Clemens Eisserer
  2002-05-06 10:20 ` Tom Tromey
@ 2002-05-06 10:40 ` Jeff Sturm
  1 sibling, 0 replies; 10+ messages in thread
From: Jeff Sturm @ 2002-05-06 10:40 UTC (permalink / raw)
  To: Clemens Eisserer; +Cc: java

On Wed, 5 Jan 2000, Clemens Eisserer wrote:
> When I heard first time about gjc and libgjc a was very excited about 
> it. But I dont know what I can really do with it.

You mean "gcj" and "libgcj".

> I heard it is nearly compatible with Java-1.1.8 (without Gui-Stuff...), 

Right.  In fact much of 1.2 and later are there, but AWT is not yet
supported (volunteers to test/implement are needed).

> but can I really make native apps with it, like any C++ app.

gcj compiles to native object code, like gcc/g++.  It also produces
bytecode like javac.

> Is there nothing like a runtime, everything nativly? That would be sooo 
> cool....

Of course there is a runtime, consisting of the core java.* classes,
garbage collector and so forth.  However unlike Sun's VM, the bytecode
interpreter is optional.

> Is it possible to link static with libgjc , so that the user dont need 
> to install it.(Of cource there will be choice...)

Yes, with caveats.  Some gcj users are doing that, for the reason you
gave.  However, static builds tend to be large, because they include most
of the runtime.

> Is there a garbage-collector avaible? And how is that realized, I thing 
> there is no runtime-enviroment...

The included GC library is the Boehm-Demers-Weiser conservative collector.
(See http://www.hpl.hp.com/personal/Hans_Boehm/gc/ for details on the GC
library.)

> Will all java-classes that are included in my file (e.g. java.io.*) 
>  compiled nativly?

Yes, most of java.* is included in libgcj and compiled natively.  If you
give it a try, feel free to report problems to this list.

> Is gjc a "dead" or lacy project, or is there much traffic on it?

It's actively maintained.   All releases of the GNU Compiler Collection
(GCC) since 3.0 include gcj.  Your best bet is the 3.1 release, due out
shortly.

Jeff

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Newbie Questions
  2002-05-06 10:13 Newbie Questions Clemens Eisserer
@ 2002-05-06 10:20 ` Tom Tromey
  2002-05-06 10:55   ` Clemens Eisserer
  2002-05-06 10:40 ` Jeff Sturm
  1 sibling, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2002-05-06 10:20 UTC (permalink / raw)
  To: Clemens Eisserer; +Cc: java

>>>>> "Clemens" == Clemens Eisserer <linuxhippy@freemail.de> writes:

Clemens> I'm still a very newbie at gjc so plaese dont be angry about
Clemens> my stupid questions ;-)....

Don't worry.  But it is called "gcj".

Clemens> I heard it is nearly compatible with Java-1.1.8 (without
Clemens> Gui-Stuff...), but can I really make native apps with it,
Clemens> like any C++ app.  Is there nothing like a runtime,
Clemens> everything nativly? That would be sooo cool....

No, you still need a runtime.  The runtime contains the garbage
collector, various low-level bits, the class library, and other
things.  On many platforms it even includes a bytecode interpreter.

The difference is that our runtime is a shared library.

Clemens> Is it possible to link static with libgjc , so that the user
Clemens> dont need to install it.(Of cource there will be choice...)

Yes, though static linking isn't as well tested as dynamic linking.
You might have to do strange things to make some code work, for
instance if your code is using reflection.

Clemens> I heard that there are already some AWT-Classes. Are they
Clemens> ready to use and how does they look on linux? (I heard
Clemens> something like GTK)...

AWT exists but is not yet ready to use.  Some parts are missing.  The
native side has not been written.

Actually, to be precise, a lot of the native code does exist in
Classpath.  It uses JNI (not CNI) and has not been merged into libgcj
yet.  The current native peers use Gtk.  They are still quite buggy
and incomplete.

Clemens> Will all java-classes that are included in my file
Clemens> (e.g. java.io.*) compiled nativly?

Yes.

Clemens> Is gjc a "dead" or lacy project, or is there much traffic on it?

Read the mailing list archives or the web page.  There is a lot of
traffic.  It is probably the most active free software java project by
an order of magnitude.

Tom

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Newbie Questions
@ 2002-05-06 10:13 Clemens Eisserer
  2002-05-06 10:20 ` Tom Tromey
  2002-05-06 10:40 ` Jeff Sturm
  0 siblings, 2 replies; 10+ messages in thread
From: Clemens Eisserer @ 2002-05-06 10:13 UTC (permalink / raw)
  To: java

Hello!

I'm still a very newbie at gjc so plaese dont be angry about my stupid 
questions ;-)....

When I heard first time about gjc and libgjc a was very excited about 
it. But I dont know what I can really do with it.
I heard it is nearly compatible with Java-1.1.8 (without Gui-Stuff...), 
but can I really make native apps with it, like any C++ app.
Is there nothing like a runtime, everything nativly? That would be sooo 
cool....

Is it possible to link static with libgjc , so that the user dont need 
to install it.(Of cource there will be choice...)

Is there a garbage-collector avaible? And how is that realized, I thing 
there is no runtime-enviroment...

I heard that there are already some AWT-Classes. Are they ready to use 
and how does they look on linux? (I heard something like GTK)...

Will all java-classes that are included in my file (e.g. java.io.*) 
 compiled nativly?

Is gjc a "dead" or lacy project, or is there much traffic on it?




Thank you very much for answering my questions and sorry for my bad 
english ;-).....

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-05-06 20:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-01  0:00 Newbie questions Maury Markowitz
2000-04-01  0:00 ` Tom Tromey
2000-04-01  0:00   ` Objective-C vs. gcj (was: Re: Newbie questions) Jeff Sturm
2000-04-01  0:00     ` Kresten Krab Thorup
2000-04-01  0:00       ` [OFFTOPIC] " Joerg Brunsmann
2000-04-01  0:00     ` Per Bothner
2002-05-06 10:13 Newbie Questions Clemens Eisserer
2002-05-06 10:20 ` Tom Tromey
2002-05-06 10:55   ` Clemens Eisserer
2002-05-06 13:01     ` Tom Tromey
2002-05-06 10:40 ` Jeff Sturm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).