D, the Best Programming Language, for Former Python Developers
$55.00
Minimum price
$110.00
Suggested price

D, the Best Programming Language, for Former Python Developers

Learn D Programming for Python Developers

About the Book

D programming language or DLang for Python programmers: rapid software development of high performance software and a reliable software technology. “There is no best programming language”, they say. There is, for most applications it is D.

The book starts from a comparison of D to Python. Then it explains D starting from simple features (types, variables, functions, expressions, statements) up to advanced ones (object oriented programming, templates, mixins, contract programming, overloading of operators, etc.) Then follows an advice for good programs and introduction to several libraries: the standard library Phobos (ranges, arrays, functional programming, tuples, the variant types, files, etc.) and several other important libraries including some libraries written by the author. Through these libraries D supports asynchronous programming, multithreaded programming, dependency injection (one particular “ideologically correct” flavor of which is introduced in details), etc. This book doesn’t just teach you D syntax, it gives you some principles to program in D in the right way. It is also considered how to create an object oriented wrapper over a C library. The book contains the articles “How to Make Your Programs Run Hundreds to Thousands Times Faster Without Giving up Reliability and Ease of Programming” and “What would be my choice of programming language if I was ordered to write a nuclear weapon control system?” D is the second choice for such kinds of projects after Rust (and no, it is not Ada). The book ends with an advice on which D compiler to use.

This book makes you a D programmer. 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. If you are a programming teacher, your service would be greatly improved by starting to teach D. If you belong to any of these categories (and probably many more), don’t miss this great opportunity to learn D! And D is fast and low electricity consuming (green).

And well, there are 3 (three) free D compilers for many platforms. Just start to use it. Who does use D? For example, Facebook, Mercedes-Benz, and Netflix. Sometimes big companies make right decisions.

Purchasing this book, you support carbon accounting and DeSci (decentralized science).

  • Share this book

  • Categories

    • Programming Cookbooks
    • Python
    • Software Engineering
  • Feedback

    Email the Author(s)

About the Author

Victor Porton
Victor Porton

Victor Porton is a free software (especially XML and blockchain) and mathematics developer (author of algebraic general topology and axiomatic theory of formulas), a writer and activist. Victor studied mathematics at Perm State University and did his first (big) scientific discovery at the first year of the study.

Victor Porton is the developer of several open source D libraries, especially some foundational template libraries.

Table of Contents

Abstract

Chapter 1. About the author

Chapter 2. Introduction

A comparison of Python and D

Advantages and disadvantages of D

Advantages

Disadvantages

Static vs dynamic typing

Introduction

Dynamic typing explained

Setup D Environment

Chapter 3. Hello world

In Python

In D

Chapter 4. Tokenization

Keywords and Identifiers

Comments

Chapter 5. Functions and Variables

Variables

Immutable variables

References

Constant variables

Static variables

More about variables

Functions

Function arguments

Function modifiers

Pure functions

Ref functions

Auto functions

Function calls

Function overloading

`scope` and `return ref` function argument modifiers

Default arguments

More function attributes

Variadic functions

Chapter 6. Imports and Aliases

Aliases

Chapter 7. Introduction to Types

Basic types

Arithmetic conversions

Enum types

Arrays

By-value and by-reference types

Associative arrays

Type qualifiers

Chapter 8. Expressions

Assignment operator

Arithmetic operators

Increment/decrement operators

Index and slice expressions

Cat expressions

Function call expressions

Boolean and bitwise expressions

Compare expressions

In expressions

Comma expression

Cast expression

Typeid expressions

Assignment operator expressions

Conditional expression

Precedence and associativity

Import expressions

Vector operations

Other expressions

Properties

Chapter 9. Literals

Boolean literals

Null literal

Integer literals

Floating point literals

Array literals

Associative array literals

String literals

Character literals

Other literals

Chapter 10. Statements

Declaration statement

Expression statement

Block statement

Statement `if`

Statement `switch`

Final switch

Statement `while`

Statement `do … while`

Statement `for`

Statement `foreach`

`with` statement

`break` and `continue` statements

`goto` statement

Chapter 11. Functional Programming

Function pointers and delegate variables

Function literals

Chapter 12. Structs and Classes

Structs

Member functions

`this`

Visibility

Constructors

Copy constructors

Disabling constructors

Constructor Attributes

Destructors

Properties

`alias this`

`with` with scopes

Structs misc

Classes

Inheritance

Virtual functions

Other class features. Memory management

Abstract functions and classes

Interfaces

Anonymous nested classes

Using a class as an associative array index

Associative Array Properties

Unions

Chapter 13. Cast Operations

Casting between classes

Numeric casts

Struct casts

Casting type qualifiers

Casting to `void`

Void arrays

Other notes

Chapter 14. Pointers

Chapter 15. Exceptions and Scope Guard Statement

Exceptions

Scope guard statement

`nothrow` functions

Array bounds and memory checking

Chapter 16. Templates

Template Constraints

Template Specialization

Kind of templates. Eponymous templates

Eponymous templates

Metaprogramming

Metaprogramming with template specialization

Chapter 17. Mixins

Mixin statement

Template mixins

Using mixin statement and template mixins together

Chapter 18. Documentation Comments

Chapter 19. Unit Testing

Attributed Unittests

Best practices

Documented Unittests

Chapter 20. Contract Programming

`assert`

`in` and `out` conditions

`in`, `out` and inheritance

Invariants

The order of function execution

Chapter 21. Static Compilation Control

`static if`

`version` and `debug`

`static assert`

`static foreach`

Double braces in static constructs

Pragmas

Special keywords

Chapter 22. Overloading Operators

Postincrement ++ and Postdecrement -- Operators

Cast Operator Overloading

Boolean Operations

Overloading `==` and `!=`

Overloading `<`, `<=`, `>`, and `>=`

Function Call Operator Overloading f()

Static opCall

Assignment Operator Overloading

Op Assignment Operator Overloading

Index Operator Overloading

Overloading `foreach` and `foreach_reverse`

Forwarding

Chapter 23. Compile-Time Sequences

Compile-time loops

Chapter 24. Modules

Modules

Public import

Packages

`static this`

Chapter 25. User-Defined Attributes

Chapter 26. BetterC

Chapter 27. Advice for Good Programs

The D Style

Whitespace

Naming Conventions

General

Modules

Classes, Interfaces, Structs, Unions, Enums, Non-Eponymous Templates

Eponymous Templates

Functions

Constants

Enum members

Keywords

Acronyms

User-Defined Attributes

Declaration Style

Operator Overloading

Hungarian Notation

Properties

Documentation

Unit Tests

Programming patterns

Chapter 28. Introduction to the Standard Library

Ranges

Random access ranges

Output ranges

Range operations

More functional programming

`std.array`

`std.file`

`std.typecons`

Value tuples

Flags

`Nullable`

`std.variant`

`std.stdio`

struct File

Bit fields

Chapter 29. Concurrency

async/await

`dawait`

Shared variables

Synchronized code sections

Threads

`std.parallelism`

Fibers

Generators

Chapter 30. Memoizing that is caching function result in D language

std.functional.memoize from the standard library

Memoizing struct or class properties

Memoization in the D Programming Language, part 2

memoize functions

memoizeMember

Chapter 31. Passing parameters through structs with nullable fields

The problem

Variants of solutions

Example of definition and combination

Calling functions

Last considerations

Chapter 32. Modify tuple modifiers

The problem

The implementation

Possible usage

Chapter 33. Pure Dependency Injection in D

Dependency injection

Taxonomy

Advantages

Disadvantages

Types of dependency injection

Pure dependency injection

Python Dependency Injector

My D dependency injector

Providers

Classes

`Provider` and `ReferenceProvider`

`Callable` and `ReferenceCallable`

Singletons

`BaseGeneralSingleton` and `ReferenceBaseGeneralSingleton`

Three kinds of singletons

`ThreadSafeSingleton` and `ReferenceThreadSafeSingleton`

`ThreadSafeCallableSingleton` and `ReferenceThreadSafeCallableSingleton`

`FixedObject` and `ReferenceFixedObject`

`ProviderWithDefaults`

Chapter 34. Why I can’t call `new` from a template

Chapter 35. Writing thick (object oriented) D binding of a C library

Other programming languages

Introduction

Packages structure

My mixins

About finalization and related stuff

Dealing with callbacks

More little things

Static if

Comparisons

Chapter 36. How to Make Your Programs Run Hundreds to Thousands Times Faster Without Giving up Reliability and Ease of Programming

Introduction

Frequently Asked Questions

Chapter 37. 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?

Comparison

Package and/or binary availability, by platform and compiler

Experimental compilers and forks

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub