s hero

D Programming Language BOOK

Master D programming language for faster and more reliable software development

Master D programming language or DLang (for Python programmers). “There is no best programming language”, they say. There is, for most applications D is the best among imperative languages. Switch your mind from nervous mode of finding bugs in your Python software (Have you ever mistyped an identifier?) to calm mode of multiparadigm programming language of increased reliability. And make your software up to hundreds times faster and less resource-hungry. Finally, you really can learn D because it isn't a language for geniuses like Rust. You write in D as easily as in Python.
Purchasing this book, you support carbon accounting and DeSci (decentralized science).

Available On

download
swlogo
barnes
amz

Personal Introduction

Social proof: testimonials

“I find Python quite quickly becomes unwieldy for large projects, even if the performance is not an issue.”
“I don't know what kind of projects you have in mind, but in our projects Python is always the bottleneck and has to be rewritten in a different language anyway, sooner or later.”

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.

D compared to Python and other languages

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 or the Programming Library I list the well-known advantages of Python and show that D is better in (almost) every respect, see the Advantages of D Programming Language:

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.

PythonD
You need less lines of codeThe program structure is seen better thanks to explicit delimiters.
It’s simpleYou get more power
It’s free and open sourcetoo
It’s easy to usetoo
It’s highly compatible and portabletoo, any of the common OSes
It is object-orientedtoo
It has lots of librariesSorry, D is a new programming language and has fewer libraries
It has built-in data structurestoo, and more advanced than Python
It’s widely applicableMuch more widely
It Increases speed of development and productivity D has better productivity than Python, thanks to more reliability and therefore reduced time spent for debugging
It’s easy to learn 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):

PythonD
Slow speed one of the fastest languages, probably only Rust is faster
Not memory efficientmemory efficient
Runtime errors (not enough static checking). One in particular is that Python does not detect mis-spelled identifiers during compilation 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 corefull multicore multithreading support
No serious support for code generationcompiler can automatically generate code
Very small compile timeSmall compile time
No UFCSSupported, 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 D Programming Language 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 “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, Python 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.

programming paradigms supported by D

Some Features of D

Strongly typed

Inferred types

Unit testing

Compile-time code analysis and execution

Asynchronous and Parallel programming

Arrays slices and Iterators

Templates

Object-oriented

Procedural imperative programming

Functional-style programming (including pure functions)

Suitable for beginners

The only prerequisite is knowledge of basic Python features.

Almost complete language lessons

You learn almost all features of D language (except of the most rarely used or very advanced).

Standard library

You learn the most important features of standard library. Yet without being overloaded into trying to learn everything.

Author's own libraries

You learn author's own libraries that fill gaps in standard library to program as easily as in Python

Learn good programming

You learn not just to write programs, you are guided how to do it in a good way.

Support

Ask instructor any questions. The instructor is the author of many D libraries.

Nonexpensive and green

Very low energy usage by your programs. You could replace 100 servers by one!

Victor Porton (not a mathematics PhD, but expertise in math research helped me to discover discontinuous analysis that combined together functional analysis and discrete analysis).

Victor Porton

Your instructor is Victor Porton, the person who discovered ordered semigroup actions (and wrote 500 pages about them), a theory as general as group theory but unknown before. Victor Porton is a programming languages polyglot, author of multitudinous softwares and programming libraries, blockchain expert and winner of multitudinous blockchain hackathons, author of several books, a philosopher.

  • Title Page
  • Introduction video
  • Chapter 2. Introduction
  • Are you going to continue study?
  • Exam: General information about D

  • Chapter 3. Hello World
  • Practice Work
  • Exam: Hello World
  • Chapter 4. Tokenization
  • Practice Work
  • Exam: Syntax and tokenization
  • Chapter 5. Functions and Variables
  • Practice Work
  • Exam: Functions and Variables
  • Chapter 6. Imports and aliases
  • Practice Work
  • Exam: Imports and Aliases
  • Chapter 7. Introduction to Types
  • Practice Work
  • Exam: Introduction to Types
  • Chapter 8. Expressions
  • Practice Work
  • Exam: Expressions
  • Chapter 9. Literals
  • Practice Work
  • Exam: Literals
  • Chapter 10. Statements
  • Practice Work
  • Exam: Statements
  • Chapter 11. Functional Programming
  • Practice Work
  • Exam: Functional programming
  • Chapter 12. Structs and Classes
  • Practice Work
  • Exam: Structs and Classes
  • Chapter 13. Cast Operations
  • Practice Work
  • Exam: Cast operations
  • Chapter 14. Pointers
  • Practice Test
  • Exam: Pointers
  • Chapter 15. Exceptions and Scope Guard Statement
  • Practice Work
  • Exam: Exceptions and Scope Guard Statement
  • Chapter 16. Templates
  • Practice Work
  • Exam: Templates
  • Chapter 17. Mixins
  • Exam: Mixins
  • Chapter 18. Documentation Comments
  • Practice Test
  • Exam: Documentation Comments
  • Chapter 19. Unit Testing
  • Practice Work
  • Exam: Unit Testing
  • Chapter 20. Contract Programming
  • Practice Work
  • Exam: Contract Programming
  • Chapter 21. Static Compilation Control
  • Practice Work
  • Exam: Static Compilation Control
  • Chapter 22. Overloading Operators
  • Practice Work
  • Chapter 23. Compile-Time Sequences
  • Practice Work (somehow hard)
  • Exam: Compile-Time Sequences
  • Chapter 24. Modules
  • Practice Work
  • Exam: Modules
  • Chapter 25. User-Defined Attributes
  • Exam: User-Defined Attributes
  • Chapter 26. BetterC
  • Exam: BetterC
  • Chapter 27. Advice for Good Programs
  • Chapter 28. Introduction to the Standard Library
  • Practice Work
  • Chapter 29. Concurrency
  • Practice Work
  • Chapter 30. Memoizing that is caching function result in D language
  • Chapter 31. Passing parameters through structs with nullable fields
  • Chapter 32. Modify tuple modifiers
  • Chapter 33. Pure Dependency Injection in D
 
  • Chapter 34. Why I can’t call new from a template
  • Chapter 35. Writing thick (object oriented) D binding of a C library
  • Chapter 36. How to Make Your Programs Run Hundreds to Thousands Times Faster Without Giving up Reliability and Ease of Programming
  • Chapter 37. What would be my choice of programming language if I was ordered to write a nuclear weapon control system?
  • Exam: What would be my choice of programming language if I was ordered to write a nuclear weapon control system?
  • Chapter 38. Which compiler should I use?
  • Bibliography

  • Masters Thesis!

Reviews

This course price includes the e-textbook. However, you can purchase text book separately.

D language is an advanced multipurpose high-performance (on par with C/C++, or sometimes much faster) and increased reliability (better than Ada in most aspects of reliability), yet feature-rich (about as flexible as Python) programming language.

Develop high-performance and reliable applications or libraries faster than if you used Python. You do about the same things as if you were a Python programmer, but you get blazing fast and having much less bugs apps. Impress your employer that you know the world most advanced programming language. I will better answer when NOT to study D: only if you have a specific language required by an employer or if need some specific library not available in D. D almost absolutely well replaces C, C++, Python, Ruby, etc. It’s just better than any of these.

In course author’s opinion, D is harder to learn than Python, however much easier than C++ or Rust. After you have mastered it, it’s more difficult to write in it than in Python, but you will develop faster because you spend less time on debugging.

D has a growing set of libraries, including mainly open-source ones, but it has not yet became as popular as Python, so Python has more libraries.

The course is intended to be a Master of Science level course. Your certificate will have the word MASTER on it. But you indeed can take it during your Bachelor or even Associate CS studies, it is OK even for amateurs knowing only Python.

Yes! Well, except of some special tasks: some kinds of mathematical programming, complex real-time programming tasks, task requiring nuclear technology reliability level, things inside browsers and other specialized scripts. And well, some other languages have more libraries available. D is not good for novices (that’s why you are to learn something like Python or Java first).

I think, the main reason is that the D language author renamed it from Mars to D, that was an unfortunate name choice and broke marketing. Another reason is that it’s complex: you need to spend some time learning it, it is not as simple as Python. Invest your time in learning.