Top Related Projects
Empowering everyone to build reliable and efficient software.
The Kotlin Programming Language.
The Go programming language
The Swift Programming Language
The official repo for the design of the C# programming language
The Crystal Programming Language
Quick Overview
The dlang/dmd repository contains the source code for the reference compiler for the D programming language, known as the Digital Mars D Compiler (DMD). D is a statically-typed, multi-paradigm programming language that combines the performance and low-level control of C/C++ with a modern, expressive, and safe syntax.
Pros
- High Performance: D is designed to be a high-performance systems programming language, with performance comparable to C/C++.
- Modern Syntax: D has a modern, expressive syntax that makes it easy to write concise and readable code.
- Memory Safety: D provides built-in memory safety features, such as automatic memory management and array bounds checking, to help prevent common programming errors.
- Powerful Standard Library: D comes with a comprehensive standard library that provides a wide range of functionality, from file I/O to networking to data structures.
Cons
- Smaller Ecosystem: Compared to more established languages like C++ and Java, the D ecosystem is relatively smaller, with fewer libraries and tools available.
- Slower Adoption: Despite its technical merits, D has not achieved the same level of widespread adoption as some other programming languages.
- Compatibility Challenges: Maintaining compatibility with existing C/C++ code can sometimes be a challenge when working with D.
- Limited IDE Support: While there are some IDE plugins available, the level of IDE support for D is not as comprehensive as for other languages.
Code Examples
Here are a few examples of D code:
- Hello, World!:
import std.stdio;
void main() {
writeln("Hello, World!");
}
- Fibonacci Sequence:
import std.stdio;
ulong fib(ulong n) {
if (n <= 1) return n;
return fib(n - 1) + fib(n - 2);
}
void main() {
foreach (i; 0 .. 10) {
writeln(fib(i));
}
}
- Simple Web Server:
import std.stdio;
import vibe.d;
void main() {
auto settings = new HTTPServerSettings;
settings.port = 8080;
auto router = new URLRouter;
router.get("/", (req, res) {
res.writeBody("Hello, World!");
});
listenHTTP(settings, router);
logInfo("Please open http://localhost:8080/ in your browser.");
runApplication();
}
Getting Started
To get started with the dlang/dmd repository, you'll need to have a D compiler installed on your system. The easiest way to do this is to use the official D installer, which can be downloaded from the D Programming Language website.
Once you have a D compiler installed, you can clone the dlang/dmd repository and build the compiler from source:
git clone https://github.com/dlang/dmd.git
cd dmd
make -f posix.mak
This will build the DMD compiler, which you can then use to compile and run your D programs. For more detailed instructions on building and using the DMD compiler, please refer to the dlang/dmd repository README.
Competitor Comparisons
Empowering everyone to build reliable and efficient software.
Pros of Rust
- Larger and more active community, with more frequent updates and contributions
- More robust memory safety features and ownership model
- Extensive ecosystem with a wide range of libraries and tools
Cons of Rust
- Steeper learning curve, especially for developers new to systems programming
- Longer compilation times compared to D
- More complex syntax, particularly around lifetimes and borrowing
Code Comparison
Rust:
fn main() {
let numbers = vec![1, 2, 3, 4, 5];
let sum: i32 = numbers.iter().sum();
println!("Sum: {}", sum);
}
D:
void main() {
import std.stdio, std.algorithm;
int[] numbers = [1, 2, 3, 4, 5];
int sum = numbers.sum();
writeln("Sum: ", sum);
}
Both Rust and DMD are systems programming languages with a focus on performance and safety. Rust has gained significant popularity in recent years due to its strong memory safety guarantees and growing ecosystem. DMD, while less widely adopted, offers a simpler syntax and faster compilation times. The code comparison shows that both languages can achieve similar results with slightly different approaches to syntax and standard library usage.
The Kotlin Programming Language.
Pros of Kotlin
- More modern language design with null safety and coroutines
- Extensive tooling support, especially in IntelliJ IDEA
- Seamless interoperability with Java
Cons of Kotlin
- Slower compilation times compared to D
- Steeper learning curve for developers new to functional programming concepts
Code Comparison
Kotlin:
fun main() {
val numbers = listOf(1, 2, 3, 4, 5)
println(numbers.filter { it % 2 == 0 })
}
D:
import std.stdio;
import std.algorithm;
void main() {
int[] numbers = [1, 2, 3, 4, 5];
writeln(numbers.filter!(n => n % 2 == 0));
}
Key Differences
- Kotlin focuses on Java interoperability, while D aims for C++ compatibility
- D offers more low-level control and systems programming capabilities
- Kotlin has gained significant traction in Android development
Community and Ecosystem
- Kotlin has a larger and more active community, especially in mobile development
- D has a smaller but dedicated community, with a focus on performance-critical applications
Performance
- D generally offers better runtime performance and lower memory usage
- Kotlin leverages the JVM, providing good performance with the benefits of JIT compilation
The Go programming language
Pros of Go
- Simpler syntax and easier learning curve
- Stronger standard library and built-in concurrency support
- Larger community and ecosystem, with more third-party packages
Cons of Go
- Less flexible type system compared to D's powerful metaprogramming
- Lack of some advanced features like CTFE (Compile-Time Function Execution)
- More verbose error handling without exceptions
Code Comparison
Go:
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
D:
import std.stdio;
void main()
{
writeln("Hello, World!");
}
Summary
Go offers simplicity and a robust standard library, making it easier for newcomers and promoting consistent code across projects. It has a larger community and more resources available. However, D provides more advanced language features and flexibility in its type system, allowing for powerful metaprogramming techniques. Go's error handling can be more verbose, while D supports exceptions. Both languages have their strengths, with Go focusing on simplicity and concurrency, and D offering more advanced features for systems programming.
The Swift Programming Language
Pros of Swift
- Larger and more active community, with more frequent updates and contributions
- Broader platform support, including iOS, macOS, and Linux
- More extensive standard library with advanced features like optionals and generics
Cons of Swift
- Steeper learning curve for beginners compared to D
- Larger compiler and runtime, potentially leading to slower compilation times
- Less emphasis on systems programming and low-level control
Code Comparison
Swift:
func greet(name: String) -> String {
return "Hello, \(name)!"
}
let message = greet(name: "World")
print(message)
D:
string greet(string name) {
return "Hello, " ~ name ~ "!";
}
auto message = greet("World");
writeln(message);
Both languages offer concise syntax for defining functions and string interpolation. Swift uses parentheses for function calls and named parameters, while D uses a more C-like syntax. Swift's string interpolation is slightly more readable with \()
syntax, whereas D concatenates strings using the ~
operator.
The official repo for the design of the C# programming language
Pros of csharplang
- Larger community and more active development, with frequent updates and discussions
- More comprehensive documentation and language specification
- Broader ecosystem support, including cross-platform development with .NET Core
Cons of csharplang
- More complex language features, potentially leading to steeper learning curve
- Slower compilation times compared to D's fast compile times
- Larger runtime footprint, which may impact performance in resource-constrained environments
Code Comparison
csharplang (C#):
using System;
class Program {
static void Main() {
Console.WriteLine("Hello, World!");
}
}
dmd (D):
import std.stdio;
void main() {
writeln("Hello, World!");
}
Both languages offer similar syntax for basic programs, but D's syntax is generally more concise. C# requires explicit use of the Console
class for output, while D's std.stdio
module provides a more straightforward writeln
function. D's main
function doesn't require a static
modifier or a class wrapper, making it more compact for simple programs.
The Crystal Programming Language
Pros of Crystal
- Syntax inspired by Ruby, making it more familiar to Ruby developers
- Built-in concurrency support with fibers and channels
- Null reference checks at compile-time, reducing runtime errors
Cons of Crystal
- Smaller community and ecosystem compared to D
- Less mature compiler and tooling
- Limited support for Windows development
Code Comparison
Crystal:
def fibonacci(n)
return n if n <= 1
fibonacci(n - 1) + fibonacci(n - 2)
end
puts fibonacci(10)
DMD (D):
import std.stdio;
int fibonacci(int n) {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
void main() {
writeln(fibonacci(10));
}
Key Differences
- Crystal uses Ruby-like syntax, while D has a C-like syntax
- Crystal has implicit typing, whereas D requires explicit type declarations
- D has more advanced metaprogramming capabilities
- Crystal focuses on simplicity and developer happiness, while D emphasizes performance and systems programming
Both languages aim to provide modern features with static typing and compile-time optimizations, but they cater to different developer preferences and use cases.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
DMD is the reference compiler for the D programming language.
Releases, language specification and other resources can be found on the homepage. Please refer to the guidelines for bug reports to report a problem or browse the list of open bugs.
Overview
This repository is structured into the following directories.
Refer to their respective README.md
for more in-depth information.
Directory | Description |
---|---|
changelog | changelog entries for the upcoming release |
ci | CI related scripts / utilities |
compiler | root of all compiler (DMD/frontend) related code |
compiler/src | source code, build system and build instructions |
compiler/test | tests and testing infrastructure |
compiler/docs | man pages and internal documentation |
compiler/ini | predefined dmd.conf files |
compiler/samples | Various code examples |
druntime | root of all runtime related code |
With a D compiler and dub installed, dmd can be built with:
dub build dmd:compiler
For more information regarding compiling, installing, and hacking on DMD, check the contribution guide and visit the D Wiki.
Nightlies
Nightly builds based of the current DMD / Phobos master
branch
can be found here.
Top Related Projects
Empowering everyone to build reliable and efficient software.
The Kotlin Programming Language.
The Go programming language
The Swift Programming Language
The official repo for the design of the C# programming language
The Crystal Programming Language
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot