Please disable your adblock and script blockers to view this page

Porting a Golang and Rust CLI tool to D


Programming
Hashtrack
API
DMD
Windows
Ubuntu
IDE
Intellij
DCD
DScanner
HTTP
Python
code.dlang.org
Firefox
JSON
views/).As
UFCS
response.throwOnFailure
Vibe.d
CI
GC


Paulo Henrique Cuchi
Rust
comparisonI
MacOS
Edit
5.7MD
DNice


D.


stringImportPaths

No matching tags


graphQL

No matching tags

Positivity     39.00%   
   Negativity   61.00%
The New York Times
SOURCE: https://pingfrommorocco.blogspot.com/2020/08/porting-golang-and-rust-cli-tool-to-d.html
Write a review: Hacker News
Summary

I'll try to keep the same structure as the one he used in his blog post.Source code on GithubThe main reason is that the original blog post compared statically typed languages like Go and Rust, and made honorable mentions to Nim and Crystal, but didn't mention D. D falls under this category, so I think this will make for an interesting comparisonI also like D as a language and I have mentioned it in various other blog posts.The manual has a lengthy page on how to download and install the reference compiler, DMD. After looking into it though, it struck me as more of a vibe.d plugin than an actual client, if there is such a thing.After inspecting the network requests on Firefox, I realized that for this project, I could just mimic the graphql queries and mutations, which I would then send with an HTTP client. I don't think D has anything like that in the standard library, but there have been discussions about implementing it as a third party library.I just want to quickly mention that I didn't use websockets to implement the "watch" command. I think the results are pretty good considering that I didn't have memory consumption in mind while I was writing the code.Rust, built with cargo build --release : 7.0MD, built with dub build -b release : 5.7MD, built with dub build -b release --compiler=ldc2: 2.4MGo, built with go build : 7.1MGo, built with go build -ldflags "-s -w" : 5.0MI think D is a solid language for writing command line tools like these. Things like parsing command line arguments, handling JSON, unit testing, making HTTP requests (with cURL) are all available in the standard library.

As said here by Azi Hassan