1543 lines
36 KiB
Plaintext
1543 lines
36 KiB
Plaintext
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0">
|
||
<title>Life in the Fast Lane | The D Blog</title>
|
||
<meta name="description" content="The official blog for the D Programming Language.">
|
||
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/d.min.js"></script>
|
||
|
||
<meta name="theme-color" content="#b03931">
|
||
<link type="application/atom+xml" rel="alternate" href="https://blog.dlang.org/feed.xml" title="The D Blog" />
|
||
<link rel="stylesheet" href="/assets/css/style.css">
|
||
|
||
<link rel="icon" href="/assets/images/favicon-192.png" sizes="192x192" />
|
||
<link rel="apple-touch-icon" href="/assets/images/apple-touch-icon.png" />
|
||
<link rel="icon" href="/assets/images/favicon-32.png" sizes="32x32" />
|
||
<meta name="msapplication-TileImage" content="/assets/images/favicon-270.png" />
|
||
<link rel="manifest" href="/manifest.json">
|
||
</head>
|
||
<body>
|
||
|
||
<div class="blog-container">
|
||
<header class="dlf-header">
|
||
<h1>The D Blog</h1>
|
||
<p style="color: #666; font-size: 1.1em; margin: 5px 0 0 0; border-bottom: none !important; padding-bottom: 0 !important;">
|
||
The official blog for the D Programming Language.
|
||
</p>
|
||
<nav class="nav-bar">
|
||
<ul>
|
||
<li><a href="https://dlang.org">D HOME</a></li>
|
||
<li><a href="https://forum.dlang.org/">D FORUMS</a></li>
|
||
<li><a href="https://dlang.org/donate.html">DONATE</a></li>
|
||
<li><a href="https://store.dlang.org/">SHOP</a></li>
|
||
</ul>
|
||
</nav>
|
||
</header>
|
||
|
||
|
||
<div class="main-grid">
|
||
<main class="article-col" style="">
|
||
<article class="post">
|
||
|
||
<header>
|
||
<h2 style="font-size: 2.6em; font-weight: bold; margin-bottom: 15px;">
|
||
|
||
Life in the Fast Lane
|
||
|
||
</h2>
|
||
|
||
<p>
|
||
Jun 16, 2017 • DBlogAdmin
|
||
|
||
•
|
||
|
||
<a href="/search?q=Code" class="tag-link">#Code</a>,
|
||
|
||
<a href="/search?q=GC" class="tag-link">#GC</a>
|
||
|
||
|
||
</p>
|
||
</header>
|
||
|
||
<div class="post-content" style="line-height: 1.6; font-size: 1.1em; color: #222;">
|
||
<p><a href="https://dlang.org/blog/2017/03/20/dont-fear-the-reaper/"><img src="http://dlang.org/blog/wp-content/uploads/2016/08/d6.png" alt="" />The first post</a> I wrote in the <a href="http://dlang.org/blog/the-gc-series/">GC series</a> introduced the D garbage collector and the language features that use it. Two key points that I tried to get across in the article were:</p>
|
||
|
||
<ol>
|
||
<li>
|
||
<p><strong>The GC can only run when memory allocations are requested</strong>. Contrary to popular misconception, the D GC isn’t generally going to decide to pause your Minecraft clone in the middle of the hot path. It will only run when memory from the GC heap is requested, and then only if it needs to.</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>Simple C and C++ allocation strategies can mitigate GC pressure</strong>. Don’t allocate memory in inner loops – preallocate as much as possible, or fetch it from the stack instead. Minimize the total number of heap allocations. These strategies work because of point #1 above. The programmer can dictate when it is possible for a collection to occur simply by being smart about when GC heap allocations are made.</p>
|
||
</li>
|
||
</ol>
|
||
|
||
<p>The strategies in point #2 are fine for code that a programmer writes herself, but they aren’t going to help at all with third-party libraries. For those situations, D provides built-in mechanisms to guarantee that no GC allocations can occur, both in the language and the runtime. There are also command-line options that can help make sure the GC stays out of the way.</p>
|
||
|
||
<p>Let’s imagine a hypothetical programmer named J.P. who, for reasons he considers valid, has decided he would like to avoid garbage collection completely in his D program. He has two immediate options.</p>
|
||
|
||
<h4 id="the-gc-chill-pill">The GC chill pill</h4>
|
||
|
||
<p>One option is to make a call to <code>GC.disable</code> when the program is starting up. This doesn’t stop allocations, but puts a hold on collections. That means <em>all</em> collections, including any that may result from allocations in other threads.</p>
|
||
|
||
<pre><code class="language-d">void main() {
|
||
import core.memory;
|
||
import std.stdio;
|
||
GC.disable;
|
||
writeln("Goodbye, GC!");
|
||
}
|
||
</code></pre>
|
||
<p>Output:</p>
|
||
|
||
<pre><code>Goodbye, GC! This has the benefit that all language features making use of the GC heap will still work as expected. But, considering that allocations are still going without any cleanup, when you do the math you'll realize this might be problematic. If allocations start to get out of hand, something's gotta give. From [the documentation](http://dlang.org/phobos/core_memory.html#.GC.disable):
|
||
</code></pre>
|
||
|
||
<p>Collections may continue to occur in instances where the implementation deems necessary for correct program behavior, such as during an out of memory condition.</p>
|
||
|
||
<p>Depending on J.P.’s perspective, this might not be a good thing. But if this constraint is acceptable, there are some additional steps that can help keep things under control. J.P. can make calls to <code>GC.enable</code> or <code>GC.collect</code> as necessary. This provides greater control over collection cycles than the simple C and C++ allocation strategies.</p>
|
||
|
||
<h4 id="the-gc-wall">The GC wall</h4>
|
||
|
||
<p>When the GC is simply intolerable, J.P. can turn to the <code>@nogc</code> attribute. Slap it at the front of the <code>main</code> function and thou shalt suffer no collections.</p>
|
||
|
||
<pre><code class="language-d">@nogc
|
||
void main() { ... }
|
||
</code></pre>
|
||
<p>This is the ultimate GC mitigation strategy. <code>@nogc</code> applied to <code>main</code> will guarantee that the garbage collector will never run anywhere further along the callstack. No more caveats about collecting “where the implementation deems necessary”.</p>
|
||
|
||
<p>At first blush, this may appear to be a much better option than <code>GC.disable</code>. Let’s try it out.</p>
|
||
|
||
<pre><code class="language-d">@nogc
|
||
void main() {
|
||
import std.stdio;
|
||
writeln("GC be gone!");
|
||
}
|
||
</code></pre>
|
||
<p>This time, we aren’t going to get past compilation:</p>
|
||
|
||
<pre><code>Error: @nogc function 'D main' cannot call non-@nogc function 'std.stdio.writeln!string.writeln' What makes `@nogc` tick is the compiler’s ability to enforce it. It’s a very blunt approach. If a function is annotated with `@nogc`, then any function called from inside it must also be annotated with `@nogc`. As may be obvious, `writeln` is not.
|
||
</code></pre>
|
||
|
||
<p>That’s not all:</p>
|
||
|
||
<pre><code class="language-d">@nogc
|
||
void main() {
|
||
auto ints = new int[](100);
|
||
}
|
||
</code></pre>
|
||
<p>The compiler isn’t going to let you get away with that one either.</p>
|
||
|
||
<pre><code>Error: cannot use 'new' in @nogc function 'D main' Any language feature that allocates from the GC heap is out of reach inside a function marked `@nogc` (refer to [the first post in this series](https://dlang.org/blog/2017/03/20/dont-fear-the-reaper/) for an overview of those features). It’s turtles all the way down. The big benefit here is that it guarantees that third-party code can’t use those features either, so can’t be allocating GC memory behind your back. Another downside is that any third-party library that is not `@nogc` aware is not going to be available in your program.
|
||
</code></pre>
|
||
|
||
<p>Using this approach requires a number of workarounds to make up for non-<code>@nogc</code> language features and library functions, including several in the standard library. Some are trivial, some are not, and others can’t be worked around at all (we’ll dive into the details in a future post). One example that might not be obvious is throwing an exception. The idiomatic way is:</p>
|
||
|
||
<pre><code class="language-d">throw new Exception("Blah");
|
||
</code></pre>
|
||
<p>Because of the <code>new</code> in that line, this isn’t possible in <code>@nogc</code> functions. Getting around this requires preallocating any exceptions that will be thrown, which in turn runs into the issue that any exception memory allocated from the regular heap still needs to be deallocated, which leads to ideas of reference counting or stack allocation… In other words, it’s a big can of worms. There’s currently <a href="https://github.com/dlang/DIPs/blob/master/DIPs/DIP1008.md">a D Improvement Proposal</a> from Walter Bright intended to stuff all the worms back into the can by making <code>throw new Exception</code> work without the GC when it needs to.</p>
|
||
|
||
<p>It’s not an insurmountable task to get around the limitations of <code>@nogc main</code>, it just requires a good bit of motivation and dedication.</p>
|
||
|
||
<p>One more thing to note about <code>@nogc main</code> is that it doesn’t banish the GC from the program completely. D has support for <a href="https://dlang.org/spec/class.html#static-constructor">static constructors and destructors</a>. The former are executed by the runtime before entering <code>main</code> and the latter upon exiting. If any of these exist in the program and are not annotated with <code>@nogc</code>, then GC allocations and collections can technically be present in the program. Still, <code>@nogc</code> applied to <code>main</code> means there won’t be any collections running once <code>main</code> is entered, so it’s effectively the same as having no GC at all.</p>
|
||
|
||
<h4 id="working-it-out">Working it out</h4>
|
||
|
||
<p>Here’s where I’m going to offer an opinion. There’s a wide range of programs that can be written in D without disabling or cutting the GC off completely. The simple strategies of minimizing GC allocations and keeping them out of the hot path will get a lot of mileage and <em>should be preferred</em>. It can’t be repeated enough given how often it’s misunderstood: D’s GC will only have a chance to run when the programmer allocates GC memory and it will only run if it needs to. Use that knowledge to your advantage by keeping the allocations small, infrequent, and isolated outside your inner loops.</p>
|
||
|
||
<p>For those programs where more control is actually needed, it probably isn’t going to be necessary to avoid the GC entirely. Judicious use of <code>@nogc</code> and/or the <code>core.memory.GC</code> API can often serve to avoid any performance issues that may arise. Don’t put <code>@nogc</code> on <code>main</code>, put it on the functions where you really want to disallow GC allocations. Don’t call <code>GC.disable</code> at the beginning of the program. Call it instead before entering a critical path, then call <code>GC.enable</code> when leaving that path. Force collections at strategic points, such as between game levels, with <code>GC.collect</code>.</p>
|
||
|
||
<p>As with any performance tuning strategy in software development, it pays to understand as fully as possible what’s actually happening under the hood. Adding calls to the <code>core.memory.GC</code> API in places where you <em>think</em> they make sense could potentially make the GC do needless work, or have no impact at all. Better understanding can be achieved with a little help from the toolchain.</p>
|
||
|
||
<p>The DRuntime <a href="https://dlang.org/spec/garbage.html#gc_config">GC option</a> <code>--DRT-gcopt=profile:1</code> can be passed to a compiled program (not to the compiler!) for some tune-up assistance. This will report some useful GC profiling data, such as the total number of collections and the total collection time.</p>
|
||
|
||
<p>To demonstrate, <strong>gcstat.d</strong> appends twenty values to a dynamic array of integers.</p>
|
||
|
||
<pre><code class="language-d">void main() {
|
||
import std.stdio;
|
||
int[] ints;
|
||
foreach(i; 0 .. 20) {
|
||
ints ~= i;
|
||
}
|
||
writeln(ints);
|
||
}
|
||
</code></pre>
|
||
<p>Compiling and running with the GC profile switch:</p>
|
||
|
||
<pre><code class="language-bash">dmd gcstat.d
|
||
gcstat --DRT-gcopt=profile:1
|
||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
|
||
Number of collections: 1
|
||
Total GC prep time: 0 milliseconds
|
||
Total mark time: 0 milliseconds
|
||
Total sweep time: 0 milliseconds
|
||
Total page recovery time: 0 milliseconds
|
||
Max Pause Time: 0 milliseconds
|
||
Grand total GC time: 0 milliseconds
|
||
GC summary: 1 MB, 1 GC 0 ms, Pauses 0 ms < 0 ms
|
||
</code></pre>
|
||
<p>This reports one collection, which almost certainly happened as the program was shutting down. The runtime terminates the GC as it exits which, in the current implementation, will generally trigger a collection. This is done primarily to run destructors on collected objects, even though D does not require destructors of GC-allocated objects to ever be run (a topic for a future post).</p>
|
||
|
||
<p>DMD supports a command-line option, <code>-vgc</code>, that will display every GC allocation in a program, including those that are hidden behind language features like the array append operator.</p>
|
||
|
||
<p>To demonstrate, take a look at <strong>inner.d</strong>:</p>
|
||
|
||
<pre><code class="language-d">void printInts(int[] delegate() dg)
|
||
{
|
||
import std.stdio;
|
||
foreach(i; dg()) writeln(i);
|
||
}
|
||
|
||
void main() {
|
||
int[] ints;
|
||
auto makeInts() {
|
||
foreach(i; 0 .. 20) {
|
||
ints ~= i;
|
||
}
|
||
return ints;
|
||
}
|
||
|
||
printInts(&makeInts);
|
||
}
|
||
</code></pre>
|
||
<p>Here, <code>makeInts</code> is an inner function. A pointer to a non-static inner function is not a function pointer, but a <code>delegate</code> (a context pointer/function pointer pair; if an inner function is <code>static</code>, a pointer of type <code>function</code> is produced instead). In this particular case, the delegate makes use of a variable in its parent scope. Here’s the output of compiling with <code>-vgc</code>:</p>
|
||
|
||
<pre><code class="language-bash">dmd -vgc inner.d
|
||
inner.d(11): vgc: operator ~= may cause GC allocation
|
||
inner.d(7): vgc: using closure causes GC allocation
|
||
</code></pre>
|
||
<p>What we’re seeing here is that memory needs to be allocated so that the delegate can carry the state of <code>ints</code>, making it a <em>closure</em> (which is not itself a type – the type is still <code>delegate</code>). Move the declaration of <code>ints</code> inside the scope of <code>makeInts</code> and recompile. You’ll find that the closure allocation goes away. A better option is to change the declaration of <code>printInts</code> to look like this:</p>
|
||
|
||
<pre><code class="language-d">void printInts(scope int[] delegate() dg)
|
||
</code></pre>
|
||
<p>Adding <code>scope</code> to any function parameter ensures that any references in the parameter cannot be escaped. In other words, it now becomes impossible to do something like assign <code>dg</code> to a global variable, or return it from the function. The effect is that there is no longer a need to create a closure, so there will be no allocation. See the documentation for more on <a href="https://dlang.org/spec/function.html#closures">function pointers, delegates and closures</a>, and <a href="https://dlang.org/spec/function.html#parameters">function parameter storage classes</a>.</p>
|
||
|
||
<h4 id="the-gist">The gist</h4>
|
||
|
||
<p>Given that the D GC is very different from those in languages like Java and C#, it’s certain to have different performance characteristics. Moreover, D programs tend to produce far less garbage than those written in a language like Java, where almost everything is a reference type. It helps to understand this when embarking on a D project for the first time. The strategies an experienced Java programmer uses to mitigate the impact of collections aren’t likley to apply here.</p>
|
||
|
||
<p>While there is certainly a class of software in which no GC pauses are ever acceptable, that is an arguably small set. Most D projects can, and should, start out with the simple mitigation strategies from point #2 at the top of this article, then adapt the code to use <code>@nogc</code> or <code>core.memory.GC</code> as and when performance dictates. The command-line options demonstrated here can help ferret out the areas where that may be necessary.</p>
|
||
|
||
<p>As time goes by, it’s going to become easier to micromanage garbage collection in D programs. There’s a concerted effort underway to make Phobos, D’s standard library, as <code>@nogc</code>-friendly as possible. Language improvements such as Walter’s proposal to modify how exceptions are allocated should speed that work considerably.</p>
|
||
|
||
<p>Future posts in <a href="http://dlang.org/blog/the-gc-series/">this series</a> will look at how to allocate memory outside of the GC heap and use it alongside GC allocations in the same program, how to compensate for disabled language features in <code>@nogc</code> code, strategies for handling the interaction of the GC with object destructors, and more.</p>
|
||
|
||
<p><em>Thanks to Vladimir Panteleev, Guillaume Piolat, and Steven Schveighoffer for their valuable feedback on drafts of this article.</em></p>
|
||
|
||
<p><em>The article has been amended to remove a misleading line about Java and C#, and to add some information about multiple threads.</em></p>
|
||
|
||
|
||
</div>
|
||
|
||
<div class="related-posts" style="margin-top: 60px; padding-top: 30px; border-top: 2px solid #eee;">
|
||
<h3 style="font-size: 1.3em; margin-bottom: 20px;">Related Articles</h3>
|
||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div style="background: #fdfdfd; padding: 15px; border: 1px solid #eee; border-radius: 4px;">
|
||
<h4 style="margin: 0 0 10px 0; font-size: 1rem;">
|
||
<a href="/2026/07/01/symmetry-autumn-of-code-report-importc-enhancements/" style="color: #b03931; text-decoration: none;">Symmetry Autumn of Code Report: ImportC Enhancements</a>
|
||
</h4>
|
||
<small style="color: #888;">Jul 01, 2026</small>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div style="background: #fdfdfd; padding: 15px; border: 1px solid #eee; border-radius: 4px;">
|
||
<h4 style="margin: 0 0 10px 0; font-size: 1rem;">
|
||
<a href="/2026/06/07/teaching-an-ai-to-know-itself-building-a-local-llm-agent-in-d/" style="color: #b03931; text-decoration: none;">Teaching an AI to Know Itself: Building a Local LLM Agent in D</a>
|
||
</h4>
|
||
<small style="color: #888;">Jun 07, 2026</small>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div style="background: #fdfdfd; padding: 15px; border: 1px solid #eee; border-radius: 4px;">
|
||
<h4 style="margin: 0 0 10px 0; font-size: 1rem;">
|
||
<a href="/2026/05/29/i-stopped-fighting-my-tools-and-built-a-game-engine-in-d/" style="color: #b03931; text-decoration: none;">I Stopped Fighting My Tools and Built a Game Engine in D</a>
|
||
</h4>
|
||
<small style="color: #888;">May 29, 2026</small>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</article>
|
||
</main>
|
||
|
||
|
||
<aside class="sidebar-col">
|
||
<div class="sidebar-section" style="margin-bottom: 30px;">
|
||
<form action="/search" method="get" style="display: flex; align-items: stretch; gap: 0; width: 100%; max-width: 280px; border: 1px solid #ccc; border-radius: 3px; overflow: hidden; margin-bottom: 15px;">
|
||
<input type="text" name="q" placeholder="Search..."
|
||
style="flex: 1; padding: 8px 10px; border: none; font-size: 0.95em; outline: none; color: #333;">
|
||
<button type="submit" style="padding: 0 12px; cursor: pointer; background: #f4f4f4; border: none; border-left: 1px solid #ccc; display: flex; align-items: center; justify-content: center;">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||
<circle cx="11" cy="11" r="8"></circle>
|
||
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
||
</svg>
|
||
</button>
|
||
</form>
|
||
|
||
<div style="display: flex; flex-direction: column; gap: 12px; padding-left: 2px;">
|
||
<a href="/feed.xml" style="text-decoration: none; color: #b03931; font-weight: bold; font-size: 0.9em; display: flex; align-items: center; gap: 8px;">
|
||
<span style="background: #b03931; color: white; padding: 2px 6px; border-radius: 3px; font-size: 0.7em;">RSS</span> RSS FEED
|
||
</a>
|
||
<a href="https://x.com/d_programming" target="_blank" style="text-decoration: none; color: #666; font-size: 0.9em; display: inline-flex; align-items: center; gap: 8px;">
|
||
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
|
||
Follow @D_Programming
|
||
</a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="sidebar-section" style="margin-bottom: 35px;">
|
||
<h4 style="font-size: 0.85em; letter-spacing: 1px; color: #888; border-bottom: 1px solid #eee; padding-bottom: 8px; margin-bottom: 15px; text-transform: uppercase;">Recent Articles</h4>
|
||
<ul style="list-style: none; padding: 0; margin: 0;">
|
||
|
||
<li style="margin-bottom: 14px;">
|
||
<a href="/2026/08/10/language-plasticity-is-more-important-than-ever/" style="color: #b03931; text-decoration: none; font-weight: 500; font-size: 0.95em; line-height: 1.3; display: block;">
|
||
Language Plasticity is More Important Than Ever
|
||
</a>
|
||
</li>
|
||
|
||
<li style="margin-bottom: 14px;">
|
||
<a href="/2026/07/19/abusing-overload-sets-to-create-ad-hoc-template-apis/" style="color: #b03931; text-decoration: none; font-weight: 500; font-size: 0.95em; line-height: 1.3; display: block;">
|
||
(Ab)using Overload Sets to Create Ad-Hoc Template APIs
|
||
</a>
|
||
</li>
|
||
|
||
<li style="margin-bottom: 14px;">
|
||
<a href="/2026/07/01/symmetry-autumn-of-code-report-importc-enhancements/" style="color: #b03931; text-decoration: none; font-weight: 500; font-size: 0.95em; line-height: 1.3; display: block;">
|
||
Symmetry Autumn of Code Report: ImportC Enhancements
|
||
</a>
|
||
</li>
|
||
|
||
<li style="margin-bottom: 14px;">
|
||
<a href="/2026/06/07/teaching-an-ai-to-know-itself-building-a-local-llm-agent-in-d/" style="color: #b03931; text-decoration: none; font-weight: 500; font-size: 0.95em; line-height: 1.3; display: block;">
|
||
Teaching an AI to Know Itself: Building a Local LLM Agent in D
|
||
</a>
|
||
</li>
|
||
|
||
<li style="margin-bottom: 14px;">
|
||
<a href="/2026/05/29/i-stopped-fighting-my-tools-and-built-a-game-engine-in-d/" style="color: #b03931; text-decoration: none; font-weight: 500; font-size: 0.95em; line-height: 1.3; display: block;">
|
||
I Stopped Fighting My Tools and Built a Game Engine in D
|
||
</a>
|
||
</li>
|
||
|
||
<li style="margin-bottom: 14px;">
|
||
<a href="/2026/05/05/the-amazing-compile-time-state-machine/" style="color: #b03931; text-decoration: none; font-weight: 500; font-size: 0.95em; line-height: 1.3; display: block;">
|
||
The Amazing Compile-Time Metaprogramming State Machine
|
||
</a>
|
||
</li>
|
||
|
||
<li style="margin-bottom: 14px;">
|
||
<a href="/2026/04/12/dip-1053-a-tale-of-tuples/" style="color: #b03931; text-decoration: none; font-weight: 500; font-size: 0.95em; line-height: 1.3; display: block;">
|
||
DIP 1053 - A Tale of Tuples
|
||
</a>
|
||
</li>
|
||
|
||
<li style="margin-bottom: 14px;">
|
||
<a href="/archive/2024/02/22/dmd-compiler-as-a-library-a-call-to-arms/" style="color: #b03931; text-decoration: none; font-weight: 500; font-size: 0.95em; line-height: 1.3; display: block;">
|
||
DMD Compiler as a Library: A Call to Arms
|
||
</a>
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="sidebar-section">
|
||
<div style="background: white; padding: 5px; border: 1px solid #eee; border-radius: 4px;" class="banner-shadow">
|
||
<a href="https://dlang.org/shop.html" style="display: block;">
|
||
<img src="/assets/images/do-it-in-d-banner.png" alt="Do it in D" style="width: 100%; display: block; border-radius: 2px;">
|
||
</a>
|
||
</div>
|
||
<p style="font-size: 0.85em; color: #666; margin: 15px 0 25px; line-height: 1.4;">
|
||
Support the D Language Foundation at the <a href="https://store.dlang.org/" style="color: #b03931; font-weight: bold; text-decoration: none;">DO IT IN D shop!</a>
|
||
</p>
|
||
<div style="text-align: center; border-top: 1px dashed #ddd; padding-top: 20px;">
|
||
<a href="https://dlang.org/donate.html">
|
||
<img src="/assets/images/donatenew.png" alt="Donate" style="max-width: 140px;">
|
||
</a>
|
||
<p style="font-size: 0.85em; color: #666; margin-top: 10px;">
|
||
Or make a <a href="https://dlang.org/donate.html" style="color: #b03931; font-weight: bold; text-decoration: none;">direct donation</a>.
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
hljs.configure({ languages: ['d', 'cpp', 'python', 'bash', 'rust', 'julia', 'chapel', 'haskell'] });
|
||
hljs.highlightAll();
|
||
</script>
|
||
</body>
|
||
</html> |