Comparison of D and Rust
For high-reliability (such as nuclear industry or blockchain) or for real-time software Rust is better than D. But Rust is a language for geniuses (or at least is too difficult, especially for beginners). Also Rust is difficult to refactor. In my opinion, for general purpose programming we need just two languages: Rust and D.
For which applications we need a specialized programming language?
For some applications specialized languages are better. For example, you may have no other choice than to use JavaScript for in-browser programming. Mathematical checking ("validation") of software is easier if it is written in a functional language like Haskell. There are languages that allow "secure capabilities" making it impossible to call a private function (in D it is sometimes possible for example by using assembler code) allowing to use the programming language itself rather than OS to protect from hackers.
My claim is that in all other cases that I know, D is better than any other existing programming language (maybe except Rust), best programming language today. Unlike Rust, D has memory safety using memory management by garbage collection just like Python. In other words, D is the best general purpose programming language (maybe except Rust). Next I will show how D is better than Python.
In the following table I list the well-known advantages of Python and show that D is better in (almost) every respect:
Python |
D
|
You need less lines of code [2] |
The program structure is seen better thanks to explicit delimiters. |
It's simple [1] |
You get more power |
It's free and open source [1][2] |
too |
It's easy to use [1] |
too |
It's highly compatible and portable [1][2] |
too, any of the common OSes |
It is object-oriented [1] |
too |
It has lots of libraries [1][2] |
Sorry, D is a new programming language and has fewer libraries |
It has built-in data structures [1] |
too, and more advanced than Python |
It's widely applicable [1] |
Much more widely |
It Increases speed of development and productivity [1][2] |
D has better productivity than Python, thanks to more reliability and therefore reduced time spent for debugging |
It's easy to learn [1][2] |
I'd say D is a little harder to study than Python, but you get more power |
rapid development? (not really, in complex Python projects you often stuck somewhere in the middle and need to rewrite everything) |
Rapid development, even more rapid thanks to reliability features allowing you to spend less time in debugging |
Now to disadvantages of Python (compared to other programming languages and to D in particular):
Python |
D |
Slow speed [2] |
one of the fastest languages, probably only Rust is faster |
Not memory efficient [2] |
memory efficient |
Runtime errors (not enough static checking). One in particular is that Python does not detect mis-spelled identifiers during compilation [2] |
provides reliability features allowing to detect many errors during compilation, moreover at runtime errors can be detected by contract programming before they do harm; be sure D is more reliable than technologies used in most nuclear plants and rocket controls |
Not energy-efficient (expensive server CPU time and not green) |
one of the most energy-efficient languages, probably only Rust is more energy-efficient |
Poor multithreading support, all threads run on one CPU core |
full multicore multithreading support |
No serious support for code generation |
compiler can automatically generate code |
Very small compile time |
Small compile time |
No UFCS |
Supported, see below |
D is a statically typed programming language, but almost all "dynamic" features of Python can be easily imitated in D using only static (type-checked) language features. For example, decorators can be imitated with templates.
Using D language for scripting
Fast compilation time of D and rdmd command allow to use D as a scripting language, but scripts running with native speed of machine code.
D Language Advantages
Put short, D is the only programming language that is at once:
- rapid development (easy to use, avoids repetitive tasks)
- efficient (produces fast code)
- increased reliability (less bugs in your code)
This is why D is the best general purpose programming language (if we exclude Rust as its closest competitor to be the the best back-end language). Specifically D is:
- best hybrid programming language
- best backend programming language
- best programming language for SaaS
-
best programming language for IoT (see also the course sectionabout Better C)
- best programming language for API
-
best embedded programming language (see also the course section about Better C)
A selection of GUI libraries makes D a "candidate" for best programming language for GUI, too.
Universal Function Call Syntax (UFCS) in D Programming Language
Another "bonus" feature of D is [3] "Universal Function Call Syntax (UFCS). UFCS is a syntactic sugar in D that enables chaining any regular function on a type (string, number, boolean, etc.) like its member function of that type." Example:
numbers.filter!(n => n % 2 == 0).array
instead of
array(filter!(n => n % 2 == 0)(numbers))
What is the best programming language to learn?
D is the best programming language to learn! Dlang has almost all C, C++, Java, C#, Ruby & Python, JavaScript & TypeScript, PHP, Ada, and Go features. It is just more powerful programming language than any of those languages.
D Programming Language is good for:
D is a very unusually good programming language for startups, academics, programming hobbyists, open source developers, big and small companies who decided to improve their efficiency and effectivity, electronics companies, game developers, system programmers, military, industry, supercomputers and mainframes. D can be used for desktop, Web development, electronics, smartphones, servers, mathematics, robots, games, GPU and AI, and even for writing an OS.