www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Objective-D?

reply JC <jtech ezoob.com> writes:
I was thinking a little while ago, about Objective-C allowing you to make
highly dynamic applications. Unfortunately ObjC doesn't improve the C
language other than adding a little bit of Smalltalk to it. D improves C
by quite a lot but it keeps the same kind of objects that most other
languages have: static; although D does offer more RTTI than C++.

So I came up with an idea: Objective-D. This would let you program in D
but you would be able to be highly dynamic when you want to. This doesn't
have to be added to the language, an external preprocessor would be
sufficient to pull it off.

Comments highly appreciated :)

-JC
Jul 13 2005
next sibling parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
"JC" <jtech ezoob.com> wrote in message 
news:pan.2005.07.14.01.30.55.254708 ezoob.com...
 I was thinking a little while ago, about Objective-C allowing you to make
 highly dynamic applications. Unfortunately ObjC doesn't improve the C
 language other than adding a little bit of Smalltalk to it. D improves C
 by quite a lot but it keeps the same kind of objects that most other
 languages have: static; although D does offer more RTTI than C++.

 So I came up with an idea: Objective-D. This would let you program in D
 but you would be able to be highly dynamic when you want to. This doesn't
 have to be added to the language, an external preprocessor would be
 sufficient to pull it off.

 Comments highly appreciated :)

 -JC

sounds fun but hard and complicated :-P It's a pity a preprocessor is needed - can there be some usable way to just have a Dynamic subclass of Object and use "regular" D? I don't have any solid ideas what any of this would look like - probably lots of vararg-style functions. Another way to approach the issue is to take the biggest bang-for-buck features of "highly dynamic" OOP and make proposals for including them in D proper.
Jul 14 2005
parent Joshua Cearley <jtech ezoob.com> writes:
Ben Hinkle wrote:

 sounds fun but hard and complicated :-P
 It's a pity a preprocessor is needed - can there be some usable way to just 
 have a Dynamic subclass of Object and use "regular" D? I don't have any 
 solid ideas what any of this would look like - probably lots of vararg-style 
 functions.
 Another way to approach the issue is to take the biggest bang-for-buck 
 features of "highly dynamic" OOP and make proposals for including them in D 
 proper. 

It could probably be done with a special class; I do not believe there is currently a way that you can check if a class responds to a specific function however; I have yet to experiment with D's RTTI further than getting class names and checking if interfaces were implemented. -JC
Jul 14 2005
prev sibling next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
JC wrote:

 So I came up with an idea: Objective-D. This would let you program in D
 but you would be able to be highly dynamic when you want to. This doesn't
 have to be added to the language, an external preprocessor would be
 sufficient to pull it off.

 Comments highly appreciated  :) 

You know that "Objective-C++" is an *enormous* patch to GCC, yes ? (and mostly useful for using old C++ libraries, not writing new in) Even with C++, there is a truckload of restrictions when "mixing": http://developer.apple.com/releasenotes/Cocoa/Objective-C++.html With the "standard" D compiler being in an alpha stage, it doesn't seem _that_ good an idea to start mixing another language with it ? Not mention what the resulting code would be like, as Objective-C is a strange enough mix of SmallTalk and plain old C already (IMHO) If you just want to call Objective-C classes, then you can use the Objective-C runtime - which is all in C (and thus linkable with D). In fact, I think this has already been done in the "docoa" project: http://www.dsource.org/projects/docoa/ ("A D -> Objective-C bridge") Even with the recently deprecated Java Bridge to the Cocoa framework, there was still plenty of reflection and general runtime nastiness ? I'm not sure that I would wish that type of language/library mismatch upon anyone, especially not two with such different "standpoints"... --anders PS. Apple has experimented with garbage collection and namespaces for Objective-C, but they haven't finished any implementation yet. And of course, the strings and arrays and dictionaries are being implemented by a library instead of being built-in to the language. What other language improvements over plain C does D really bring ? (design-by-contract and unit-testing are "handled" by libs/macros in Objective-C, just as how they would be handled in C++ or Java) Maybe one should take the time to fill out the "Objective-C vs. D"... http://www.prowiki.org/wiki4d/wiki.cgi?LanguagesVersusD I'm not that good at the language myself, maybe someone else could ?
Jul 15 2005
prev sibling next sibling parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
"JC" <jtech ezoob.com> wrote in message 
news:pan.2005.07.14.01.30.55.254708 ezoob.com...
 I was thinking a little while ago, about Objective-C allowing you to make
 highly dynamic applications. Unfortunately ObjC doesn't improve the C
 language other than adding a little bit of Smalltalk to it. D improves C
 by quite a lot but it keeps the same kind of objects that most other
 languages have: static; although D does offer more RTTI than C++.

 So I came up with an idea: Objective-D. This would let you program in D
 but you would be able to be highly dynamic when you want to. This doesn't
 have to be added to the language, an external preprocessor would be
 sufficient to pull it off.

 Comments highly appreciated :)

 -JC

Thinking about a more dynamic D it would be fun to even try to see if this would let you essentially mix static typing and dynamic typing (ie scripting). For example http://pico.vub.ac.be/~wdmeuter/RDL04/papers/Meijer.pdf talks about a golden sweet spot mix of static and dynamic. Maybe an untyped variable would implicitly be one of these "highly dynamic" types that can be converted to and from regular D types. The dynamic types would be slower than the static types (though a jit might be able to solve that) but would be very useful for cutting through static typing clutter.
Jul 16 2005
next sibling parent Charles Hixson <charleshixsn earthlink.net> writes:
Ben Hinkle wrote:
 "JC" <jtech ezoob.com> wrote in message 
 news:pan.2005.07.14.01.30.55.254708 ezoob.com...
 I was thinking a little while ago, about Objective-C allowing you to make
 highly dynamic applications. Unfortunately ObjC doesn't improve the C
 language other than adding a little bit of Smalltalk to it. D improves C
 by quite a lot but it keeps the same kind of objects that most other
 languages have: static; although D does offer more RTTI than C++.

 So I came up with an idea: Objective-D. This would let you program in D
 but you would be able to be highly dynamic when you want to. This doesn't
 have to be added to the language, an external preprocessor would be
 sufficient to pull it off.

 Comments highly appreciated :)

 -JC

Thinking about a more dynamic D it would be fun to even try to see if this would let you essentially mix static typing and dynamic typing (ie scripting). For example http://pico.vub.ac.be/~wdmeuter/RDL04/papers/Meijer.pdf talks about a golden sweet spot mix of static and dynamic. Maybe an untyped variable would implicitly be one of these "highly dynamic" types that can be converted to and from regular D types. The dynamic types would be slower than the static types (though a jit might be able to solve that) but would be very useful for cutting through static typing clutter.

language, then you should require that variables be declared of a type, though one could steal from Basic and call them of type Variant...perhaps abbreviated to merely var. OTOH, I don't know enough about Objective-C to guess what the appropriate approach would be. When I think of it I tend to think of something like Pyrex, with D underneath it instead of C. And each file should probably be either D or Dynamic. (Note that this language isn't as dynamic as Python, but more like Pyrex...and that it's native interface type would be to D). OTOH, I'm not about to start on this project, and if someone is, then their wishes should clearly govern.
Jul 19 2005
prev sibling parent Joshua Cearley <joshua blackcrystal.us> writes:
Ben Hinkle wrote:
 "JC" <jtech ezoob.com> wrote in message 
 news:pan.2005.07.14.01.30.55.254708 ezoob.com...
 
I was thinking a little while ago, about Objective-C allowing you to make
highly dynamic applications. Unfortunately ObjC doesn't improve the C
language other than adding a little bit of Smalltalk to it. D improves C
by quite a lot but it keeps the same kind of objects that most other
languages have: static; although D does offer more RTTI than C++.

So I came up with an idea: Objective-D. This would let you program in D
but you would be able to be highly dynamic when you want to. This doesn't
have to be added to the language, an external preprocessor would be
sufficient to pull it off.

Comments highly appreciated :)

-JC

Thinking about a more dynamic D it would be fun to even try to see if this would let you essentially mix static typing and dynamic typing (ie scripting). For example http://pico.vub.ac.be/~wdmeuter/RDL04/papers/Meijer.pdf talks about a golden sweet spot mix of static and dynamic. Maybe an untyped variable would implicitly be one of these "highly dynamic" types that can be converted to and from regular D types. The dynamic types would be slower than the static types (though a jit might be able to solve that) but would be very useful for cutting through static typing clutter.

I'm reading that white paper now; since I finally got around to installing a news reader on my new laptop (blammed Mail's lack of NNTP support). Some of Cocoa/NeXTStep things are probably superfluous such as poseAsClass and others such as respondsToSelector can be emulated in a custom class. I'm not sure how easy it would be to implement some of other few commands though, since Objective-C/Cocoa lets me ask for a class by giving it the name of it via string. I imagine with a little bit of handy work in this area and D will be a blessing :) At least on OS X anyway. -JC "One Language to rule them all, One Browser to find them, One Framework to bring them all and in Assembler bind them."
Jul 30 2005
prev sibling parent Tom Edelson <edelsont well.com> writes:
I think this is a terrific idea.  But then I would think that, since I had
pretty
much the same idea independently, and found your post by searching to see if
anyone else had had it before.

Disclaimer: I am not an expert, nor even a competent programmer, in either
Objective-C or D.  My favorite languages -- the ones I choose to consider part
of
my primary toolkit, today -- are Java, Scheme, and Perl.

But that list feels incomplete, since none of the three is [designed to be]
compiled directly to native code.  So D or [even more so] Objective-C are prime
candidates to be added to my list; or even better, something that combines them,
or at least has [what I think of as] the best features of both.

Actually, I'd be happy to do without the "C++ style" objects in D, and have the
only objects in my imaginary language be "Objective-C style" instead.  What I
really would like best would be Objective-C, except that the underlying language
-- in the same sense in which C is the underlying language for Objective-C --
would be like D *without* its object system.

Or at any rate, like C but safer: it would have garbage collection, [automatic
and
mandatory] array bounds checking ... and in one respect, I'd go beyond D in
emphasizing safety.  I would eliminate true C-style pointers, and replace them
with something like Perl's references.  In other words, with a data type which
points to something else, but doesn't let you do arithmetic on it.  Or to state
it
in terms of what I really care about: if you declare a variable as a reference
to
a certain type, then the compiler should ensure that you can only give it values
which actually do point to a data item of that type.

A number of other features of D, that aren't part of the object system, are
attractive, too: eliminating the C preprocessor, exception handling in
try-catch-finally style, built-in string data type, name spaces, support for
programming by contract, and the like.  But not as important, in my eyes, as the
safety features I mentioned first.

The main problem with this version of [a concept for] "Objective-D" is that
people
would say that the correct name for it would be "Objective-D--" -- and that
sounds
terrible, from a "marketing" (recruiting initial interest) point of view.

But otherwise, that's a [very broad] description of the programming language I'd
like for Christmas.  I put it that way because I haven't yet convinced myself
that
I should throw myself into organizing a project to implement it.  But perhaps I
could be persuaded ....

So.  A little different from [what I would envision as] "Objective-D" in the
most
natural sense, but I would call it similar in spirit.

As with your original post, comments are encouraged.
Dec 01 2006