Take a look at this simple filtering code:
// NodeJS
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const evenArr = arr.filter((x) => x % 2 == 0);
// [2, 4, 6, 8]
// Dlang
import std.algorithm.iteration : filter;
void main() {
auto arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
auto evenArr = arr.filter!(x => x % 2 == 0);
// [2, 4, 6, 8]
}
Both require identical effort to write, but with Dlang, you get insane speed and reliability.
Scripting vs. Compiled
Even better, you don't even feel like you're using the compiled language.
This means your development speed stays the same compared to scripting languages:
// running NodeJS program
$ node app.js
// running D program
$ rdmd app.d
The program is compiled in the background, but you, as a developer, don't have to worry about it.
Also, since type checking is part of the compiler, you will avoid all those errors you're trying to prevent using TypeScript.
Doing Some Web Work?
I already wrote on Dlang being the best programming language for finance but how does it fair with more common web tasks?
Here's an example of fetching some API data:
// NodeJS
fetch('https://example.com/api')
.then((response) => response.text())
.then((body) => {
console.log(body.name); // John
console.log(body.age); // 25
});
// Dlang
import std.stdio : print = writeln;
import std.net.curl : get;
import std.json : parseJSON;
void main() {
auto response = get("https://example.com/api");
auto json = parseJSON(response);
print(json["name"]); // "John"
print(json["age"]); // 25
}
Now remember: you get all of this at the speed of C/C++!
Language of Choice
What I just showed you is barely scratching the surface.
And this wasn't meant to be an extensive guide or tutorial... BUT... I do want to draw your attention to it.
Why?
Because, as a developer myself with a full decade of experience, no one ever told me about the awesomeness of D language.
And I feel I missed out on so much.
What Can You Build With It?
Everything.
Personally, I'm using it to build algo-trading bots (you can read all about it on my website).
It is an ideal language to experiment and test new ideas while still brutally powerful to be a production language.
So when I build something, I know I won't have to rewrite it, and I know it will run reliably 80 years from now.
Now, that is the stuff a modern software should be built upon.
And I invite you to try and see how awesome Dlang really is.
Will
Creator of (FREE) AI For Finance Course
Top comments (0)