Coinciding with news of a new release of DMD is news about DConf 2019 in London. From new GC options in DRuntime to free beers and free tours at DConf, we may as well kill two birds with one blog post!
Compiler news
The 2.085.0 release of DMD, the D reference compiler, is now ready for download. Among other things, this release sees support for 32-bit OS X removed, more support for interfacing with Objective-C, and big news on the garbage collection front. There’s also been some work on compatibility with the standard C++ library. In total, 2.085.0 represents 58 closed Bugzilla issues and the efforts of 49 contributors. See the changelog for the full details.
Interfacing with Objective-C
DMD has had limited support for binding with Objective-C for some time. This release expands that support to include classes, instance variables, and super calls.
Previously, binding with Objective-C classes required using D interfaces. No longer. Now, Objective-C classes can be declared directly as D classes. Decorate an Objective-C class with extern(Objective-C)
, make use of the @selector
attribute on the methods, and away you go.
To better facilitate interaction between the two languages, such classes have slightly modified behavior. Any static
and final
methods in an extern(Objective-C)
class are virtual. However, final
methods still are forbidden from being overridden by subclasses. static
methods are overridable.
extern (Objective-C) class NSObject { static NSObject alloc() @selector("alloc"); NSObject init() @selector("init"); void release() @selector("release"); } extern (Objective-C) class Foo : NSObject { override static Foo alloc() @selector("alloc"); override Foo init() @selector("init"); int bar(int a) @selector("bar:") { return a; } } void main() { auto foo = Foo.alloc.init; scope (exit) foo.release(); assert(foo.bar(3) == 3); }
It’s also now possible to declare instance variables in Objective-C classes and for a method in an Objective-C class to make a super call.
extern (Objective-C) class NSObject { void release() @selector("release"); } extern (Objective-C) class Foo : NSObject { // instance variable int bar; int foo() @selector("foo") { return 3; } int getBar() @selector("getBar") { return bar; } } extern (Objective-C) class Bar : Foo { static Bar alloc() @selector("alloc"); Bar init() @selector("init"); override int foo() @selector("foo") { // super call return super.foo() + 1; } }
New GC stuff
Perhaps the biggest of the GC news items is that DRuntime now ships with a precise garbage collector. This can be enabled on any executable compiled and linked against the latest DRuntime by passing the runtime option --DRT-gcopt=gc:precise
. To be clear, this is not a DMD compiler option. Read the documentation on the precise GC for more info.
Another new GC configuration option controls the behavior of the GC at program termination. Currently, the GC runs a collection at termination. This is to present the opportunity to finalize any live objects still holding on to resources that might affect the system state. However, this doesn’t guarantee all objects will be finalized as roots may still exist, nor is the need for it very common, so it’s often just a waste of time. As such, a new cleanup
option allows the user of a D program to specify three possible approaches to GC clean up at program termination:
collect
: the default, current, behavior for backward compatibilitynone
: do no cleanup at allfinalize
: unconditionally finalize all live objects
This can be passed on the command line of a program compiled and linked against DRuntime as, e.g. --DRT-gcopt=cleanup:finalize
.
All DRuntime options, including the two new ones, can be set up in code rather than being passed on the command line by declaring and initializing an array of strings called rt_options
. It must be both extern(C)
and __gshared
:
extern(C) __gshared string[] rt_options = ["gcopt=gc:precise cleanup:none"];
See the documentation on configuring the garbage collector for more GC options.
Additional GC-related enhancements include programmatic access to GC profiling statistics and a new GC registry that allows user-supplied GCs to be linked with the runtime (see the documentation for details).
Standard C++
There are two enhancements to D’s C++ interface in this release. The first is found in the new DRuntime module, core.stdcpp.new_
. This provides access to the global C++ new
and delete
operators so that D programs can allocate from the C++ heap. The second is the new core.stdcpp.allocator
module, which exposes the std::allocator<T>
class of C++ as a foundation for binding to the STL container types that allocate.
DConf 2019 news
There are two interesting perks for conference goers this year.
The nightly gathering spot
We now have an “official” gathering spot. Usually at DConf, we pick an “official” hotel where the D Language Foundation folks and many attendees stay, but where a number of conference goers gather in the evenings after dinner. This year, a number of factors made it difficult to pick a reasonable spot, so we opted for something different.
There’s a cozy little pub around the corner from the venue, the Prince Arthur, that has a nice room on the second floor available for reservation. There’s a limit on how many bodies we can pack in there at once, but folks generally come and go throughout the evening anyway. Any overflow can head downstairs to the public area. We’ve got the room May 8, 9, and 10.
Additionally, we’ll be offering a couple of free rounds each night courtesy of Mercedes-Benz Research & Development North America. Free drinks in a cozy backstreet London pub sounds like a great way to pass the time!
Check out the DConf venue page for details about the Prince Arthur and how to get there.
A free tour by Joolz Guides
Julian McDonnell of Joolz Guides will be taking some DConf registrants on a guided walk May 6 and 7. If you’ve never seen his YouTube channel, we recommend it. His video guides are quirky, informative, and fun.
This is available for free to all registrants, but space is limited! When you register for DConf, you’ll receive information on how to reserve your spot. We’ve arranged to have the tours in the mid-afternoon on both days so that folks arriving in the morning will have a chance to participate. This is a walking tour that will last somewhere between 3 – 4 hours, so be sure to wear comfortable shoes.
The current plan is to start at Temple Station and end at London Bridge. We hope you join us!
Deadlines
The DConf submission deadline of March 10 is just around the corner. Now’s the time to send in your proposal for a talk, demo, panel or research report. See the DConf 2019 homepage for submission guidelines and selection criteria. And remember, speakers are eligible for reimbursement of travel and accommodation expenses.
The early-bird registration deadline of March 17 is fast approaching. Register now to take advantage of the 15% discount!