D vs Zig

monkyyy crazymonkyyy at gmail.com
Mon Dec 8 15:03:51 UTC 2025


On Monday, 8 December 2025 at 03:53:08 UTC, Julian Fondren wrote:
> On Saturday, 6 December 2025 at 23:47:40 UTC, monkyyy wrote:
>> I put allot into this: 
>> https://crazymonkyyy.github.io/writings/gif.html I didnt see a 
>> return, your free to post it to hakernews to see what happens.
>
> The breakdown's good. Quick visualizations like this are 
> seasonal
> with Advent of Code, and also are a fun part of Raytracing in 
> One
> Weekend.
>
> This doesn't work as a script but is similar:
>
> ```d
> import std;
>
> const width = 255, height = 255;
> void main() {
>     enum s = "magick -size 255x255 -depth 8 rgb:- output.gif";
>     auto convert = pipeProcess(s.split.array, Redirect.stdin);
>     foreach (ubyte time; 0 .. 255) {
>         foreach (ubyte y; 0 .. height) {
>             foreach (ubyte x; 0 .. width) {
>                 ubyte r = time;
>                 ubyte g = y;
>                 ubyte b = x;
>                 ubyte[3] pixel = [r, g, b];
>                 convert.stdin.rawWrite(pixel);
>             }
>         }
>     }
>     convert.stdin.close;
>     convert.pid.wait;
>     spawnProcess(["xdg-open", "output.gif"]);
> }
> ```
>
> This one does work as a script, pulls in a D library, and caches
> compilation, but I wasn't able to get it a gif out of it:
>
> ```d
> #! /usr/bin/env dub
> /++ dub.sdl:
>     configuration "release" {
>         targetType "executable"
>         dependency "gamut" version="~>3.3.5"
>     }
> +/
> enum width = 255, height = 254;
> import std;
> import gamut;
>
> void main() {
>     ubyte[3][] pixels = new ubyte[3][width * height];
>     foreach (ubyte y; 0 .. height) {
>         foreach (ubyte x; 0 .. width) {
>             ubyte r = 1;
>             ubyte g = y;
>             ubyte b = x;
>             pixels[y * width + x] = [r, g, b];
>         }
>     }
>     Image image;
>     image.createLayeredView(&pixels[0][0], width, height, 
> layers: 1,
>             PixelType.rgb8, pitchInBytes: 3 * width, 
> layerOffsetBytes: width * height * 3);
>     enforce(!image.isError);
>     image.saveToFile("output.png");
>     spawnProcess(["xdg-open", "output.png"]);
> }
> ```

Im fairly opinionated about line count and start up time to get a 
hello world; and youve more then doubled the line count and added 
a language specific dependency.

Your lib likely makes sense if your doing a 1000 line task, but 
Im trying to communicate using a computer as data processing with 
"pipes" of black boxes visually with this article.


More information about the Digitalmars-d mailing list