Skip to content

Instantly share code, notes, and snippets.

@paulbuis
Last active August 29, 2015 14:28
Show Gist options
  • Save paulbuis/500e5acb3ce1bc6b9b6a to your computer and use it in GitHub Desktop.
Save paulbuis/500e5acb3ce1bc6b9b6a to your computer and use it in GitHub Desktop.
D version of 2 source file hello world example
import std.stdio;
void hello(int repeatCount) nothrow {
try {
foreach (i; 0..repeatCount) {
printf("hello from D\n");
}
}
catch (Throwable t) {
}
}
import hello;
void main() {
hello.hello(3);
}
@paulbuis
Copy link
Author

When compiled and linked using the GNU D compiler under Linux, the executable is large since it is statically linked with the entire D runtime library. The runtime library is separate from the Phobos standard library that defines the API for functions & types intended to be invoked by D after the appropriate import statements are included in the D source. The LVM compiler/linker appears to support shared library linkage to the D library, resulting in a smaller executable, but not necessarily smaller RAM requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment