Configs2026年7月13日·1 分钟阅读

D — Systems Programming Language Bridging High-Level and Low-Level Code

D is a systems programming language with C-compatible performance that adds modern features like garbage collection, closures, and compile-time function execution.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
D Language Overview
直接安装命令
npx -y tokrepo@latest install 8be2b07b-7ef8-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

D is a systems programming language designed as a practical alternative to C and C++. It retains compatibility with C ABIs and header files while adding modern features such as garbage collection, first-class functions, and compile-time evaluation. D has been in development since 2001 and is maintained by the D Language Foundation.

What D Does

  • Compiles to efficient native code via DMD, LDC (LLVM), or GDC (GCC) backends
  • Provides direct C and C++ ABI interoperability without wrappers
  • Supports compile-time function execution (CTFE) for code generation
  • Includes a standard library (Phobos) with ranges, algorithms, and concurrency
  • Offers optional garbage collection with the ability to use manual memory management

Architecture Overview

D has three compiler implementations: DMD (reference compiler), LDC (LLVM-based for optimized output), and GDC (GCC-based). All produce native binaries. The language supports a unique range-based iteration model that underpins the standard library algorithms. CTFE allows arbitrary D code to execute at compile time, enabling powerful metaprogramming without separate tooling.

Self-Hosting & Configuration

  • Install DMD or LDC via package managers, or use the install.sh script from dlang.org
  • Manage projects and dependencies with dub, the D package manager and build tool
  • Configure builds in dub.json or dub.sdl files
  • Cross-compile using LDC with target triple flags
  • Use rdmd for script-like execution of single-file programs

Key Features

  • Three compiler backends (DMD, LDC, GDC) for different optimization needs
  • Compile-time function execution (CTFE) for zero-cost abstractions
  • String mixins and template metaprogramming for code generation
  • Ranges and algorithms for composable lazy data processing
  • Direct extern(C) and extern(C++) interop with existing codebases

Comparison with Similar Tools

  • C++ — C++ has a larger ecosystem but more complexity; D simplifies many patterns while maintaining similar performance
  • Rust — Rust enforces memory safety via borrow checking; D offers optional GC and a gentler learning curve
  • Go — Go is simpler with built-in concurrency; D provides more low-level control and metaprogramming
  • Nim — Nim compiles via C with Python-like syntax; D has C/C++ syntax familiarity and three mature compiler backends
  • Zig — Zig is minimal with no hidden control flow; D is higher-level with GC, exceptions, and a rich standard library

FAQ

Q: Is D garbage collected? A: D includes an optional GC. You can disable it and use manual memory management or allocators for performance-critical code.

Q: Can D call C libraries directly? A: Yes. D supports extern(C) declarations, and tools like dstep can auto-generate D bindings from C headers.

Q: Who uses D in production? A: Companies including eBay, Netflix, and Mercedes-Benz have used D for performance-sensitive backend systems and tooling.

Q: How does CTFE work? A: Any D function without side effects can be evaluated at compile time. The compiler literally runs the function during compilation and embeds the result in the binary.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产