Last active
August 29, 2015 14:28
-
-
Save paulbuis/500e5acb3ce1bc6b9b6a to your computer and use it in GitHub Desktop.
D version of 2 source file hello world example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
void hello(int repeatCount) nothrow { | |
try { | |
foreach (i; 0..repeatCount) { | |
printf("hello from D\n"); | |
} | |
} | |
catch (Throwable t) { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hello; | |
void main() { | |
hello.hello(3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.