Download

Sample Cocoa project written in D/Objective-C, June 1, 2011. Requires D for Xcode.

You can track the development of this project from the Git repository at Github.

Introduction

This project is an extension of the D programming language adding support for Objective-C objects. DMD/Objective-C is a modified version of DMD, the reference compiler for D, which implements those additions. The ultimate goal is to merge the capabilities back into mainline DMD, which should be doable once it is proven solid and usable enough.

With D/Objective-C, D can interact directly with Objective-C objects almost exactly as if they were regular D objects. All we have to do is provide a declaration for the classes we want to use.

When interacting with Objective-C objects or creating new derived classes,
the D compiler emits compiled code similar to what an Objective-C compiler
would emit. There is generally no performance penalty when calling Objective-C code from D or when implementing Objective-C classes in D.

How to Use

The download above contains a folder with the same layout as the official DMD distribution, so you should be able to simply replace any installation of DMD with this one and keep things working. It lacks support for platforms other than Mac OS X as well as some of Digital Mars’s proprietary tools; if you need any of the later you can find them in the official DMD distribution.

If you have installed D for Xcode, you can simply replace the “dmd2” folder it installed at “/Library/Compilers” with the download above (rename it to “dmd2”) to use it from Xcode.

Still to do

Code generation, especially putting symbols in the right segments of object files, still need some work. Linker issues can occur sometime due to this. In the Chocolate sample project, a C source file was added as the last file to be compiled an linked to work around that problem.

No declaration for Cocoa classes are provided at this time, you’ll have to write your own. Chocolate however contains some incomplete declaration for a couple of Cocoa classes.

There is no garbage collector support. This is planned for the future, but meanwhile you’ll have to use manual memory management (retain/release/autorelease) for Objective-C objects.

Some other things. Search for “unimplemented” in the syntax section for details.

Mailing List

There is a mailing list to discuss D/Objective-C. Any topic having something to do with the D and Objective-C may be posted there.

History

DMD/Objective-C Alpha 1 (2011-06-01)

Initial release

Prehistory

License

DMD/Objective-C remains under the same license as DMD. The front end’s license is GPL/Artistic while the backend is under a proprietary license. Most of the runtime library and Phobos are under the Boost license. See the license file included with the distribution for details.