万本电子书0元读

万本电子书0元读

顶部广告

Learning D电子书

售       价:¥

1人正在读 | 0人评论 9.8

作       者:Michael Parker

出  版  社:Packt Publishing

出版时间:2015-11-27

字       数:914.0万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Leverage the modern convenience and modelling power of the D programming language to develop software with native efficiency About This Book Acquire the skills to understand the fundamentals of D through its support for imperative and object-oriented programming Take advantage of D’s powerful compile-time features, templates and ranges to apply generative, generic, and functional style A systematic guide that will help you become familiar with the concepts in D with the help of simple and easy-to-understand examples Who This Book Is For This book is intended for those with some background in a C-family language who want to learn how to apply their knowledge and experience to D. Perhaps you’re a college student looking to use D for hobby projects, or a career programmer interested in expanding your skillset. This book will help you get up to speed with the language and avoid common pitfalls that arise when translating C-family experience to D. What You Will Learn Compile programs with DMD and manage projects with DUB Work efficiently by binding your D programs with new and existing C libraries Generate code at compile-time to enhance runtime performance Implement complex templates for more powerful generic code Write idiomatic D with range-based functional pipelines Use the DUB repository to find a link with a variety of D libraries Implement a web-app in D from the ground up In Detail D is a modern programming language that is both powerful and efficient. It combines multiple paradigms in a way that opens up a whole new world of software design. It is used to develop both desktop and web applications, with future targets including mobile, and is available on multiple platforms. It is familiar to anyone with some experience in one or more of the C-family languages. However, hidden in the similarities are several differences that can be surprising when trying to apply common idioms from other languages. When learning D on your own, this can make it more time-consuming to master. In order to make the most of the language and become an idiomatic D programmer, it’s necessary to learn how to think in D. This book familiarizes you with D from the ground up, with a heavy focus on helping you to avoid surprises so that you can take your D knowledge to the next level more quickly and painlessly. Your journey begins with a taste of the language and the basics of compiling D programs with DMD, the reference D compiler developed by Digital Mars, and DUB, a community-developed build utility and package manager. You then set out on an exploration of major language features. This begins with the fundamentals of D, including built-in types, conditionals, loops and all of the basic building-blocks of a D program, followed by an examination of D’s object-oriented programming support. You’ll learn how these features differ from languages you may already be familiar with. Next up are D’s compile-time features, such as Compile-Time Function Evaluation and conditional compilation, then generic programming with templates. After that, you’ll learn the more advanced features of ranges and functional pipeline programming. To enhance your D experience, you are next taken on a tour of the D ecosystem and learn how to make D interact with C. Finally, you get a look at D web development using the vibe.d project and the book closes with some handy advice on where to go next. Style and approach A friendly guide to the D programming language and its ecosystem that walks programmers through all they need to know for a painless experience in learning D.
目录展开

Learning D

Table of Contents

Learning D

Credits

Foreword

About the Author

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. How to Get a D in Programming

Say hello to D

An introductory program

Getting help

The Digital Mars D compiler

Frontends, backends, and linkers

Installing DMD

The Windows installer

Installing from the ZIP

The Windows ZIP

The POSIX ZIPs

Compiling the example

Documentation and source code

The documentation

The source

Say hello to MovieMan

The problem

The features

DUB – the D build tool and package manager

Getting started

Configuring the MovieMan project

Understanding dub.sdl

Building and running MovieMan

Changing the output directory

Summary

2. Building a Foundation with D Fundamentals

The very basics

Identifiers

A note about scope

More on modules

Module declarations

More about import declarations

The special package module

Comments

Variable declaration and initialization

Basic types

The types

Literals

Integer literals

Floating-point literals

Character literals

Conversions

Alias declarations

Properties

Basic operators

Arithmetic operators

Bitwise operators

Relational and logical operators

The cast operator

Derived data types

Pointers

Arrays

Array basics

Rectangular arrays

Slices

Array literals

Arrays and void

Array operations

Strings

String essentials

Alternative string literals

WYSIWYG strings

Delimited strings

Token strings

Associative arrays

Control flow statements

Traditional loops

The foreach loop

Traditional conditionals

The goto statement

Type qualifiers – const and immutable

The contracts

With the basic types

With pointers

With arrays

Conversions

Functions

Overloaded functions

ref and out

inout parameters

lazy parameters

Function attributes

Return statements and memory

Function pointers and delegates

MovieMan – first steps

The io module

The app module

Summary

3. Programming Objects the D Way

User-defined types

Enumerations

Unions

Structs and classes

Working with objects

Encapsulation with protection attributes

Public

Private

Package

Voldemort types

Constructors and destructors

Class constructors and destructors

Struct constructors and destructors

Static constructors and destructors

Inheritance and polymorphism

Interfaces

Fake inheritance

Nested classes

Objects with const and immutable

const as a storage class

Error handling

Scope guards

Exception handling

Contract programming and unit tests

Assert contracts

Function contracts

Invariants

Unit tests

MovieMan – adding menus

The Menu base class

The MainMenu class

The DisplayMenu class

Summary

4. Running Code at Compile Time

Pragmas

The lib pragma

The msg pragma

The inline pragma

Conditional compilation

The version condition

The debug condition

The static if condition

Compile-time strings

The import expression

String mixins

Compile-time function execution

Odds and ends

static assert

The is expression

Alignment

Compile-time reflection

User-defined attributes

Summary

5. Generic Programming Made Easy

Template basics

Templates as code blocks

Struct and class templates

Enum templates

Function templates

Special features

More template parameters

Value parameters

Alias parameters

This parameters

Beyond the basics

Template specializations

Specialization on pointers and arrays

Template constraints

Template mixins

Variadic templates

Terminology

More on usage

Operator overloading

Non-templated operator overloads

Comparison overloads – opEquals and opCmp

opEquals

opCmp

Considerations

Function call overloads

Assignment overloads

Index overloads

opIndex

opIndexAssign

opDollar

Templated operator overloads

Unary overloads

Binary overloads

Cast overloads

Operator assignment overloads

Slice operator overloads

Other overloads

opDispatch

opApply

toHash

MovieMan – the database

db.d

Back to the menus

Summary

6. Understanding Ranges

Ranges defined

The problem

The solution

The interface

A range for arrays

The implementation of filter

The test

The real ranges

Input ranges

Forward ranges

Bidirectional ranges

Random-access ranges

Output ranges

Optional range primitives

hasLength

isInfinite

Other options

Ranges in use

Custom ranges

Getting a range from a stack

A name generator range

Other considerations

Custom algorithms

Summary

7. Composing Functional Pipelines with Algorithms and Ranges

Functional programming and composable pipelines

A simple example

A more complex example

Sometimes we can't

Navigating Phobos

std.range

Generative ranges

iota

recurrence

sequence

Selective ranges

take

drop

stride

retro

Compositional ranges

chain

roundRobin

transposed

zip

lockstep

std.algorithm

Comparison

equal

cmp

mismatch

levenshteinDistance

Iteration

group

map

reduce

Mutation

copy

fill

remove

Searching

find

count

any

Set operations

setIntersection

setDifference

setUnion

Sorting

sort

partition

std.array

Appender

assocArray

join

Where to look for more

MovieMan – wrapping up

The db module

The display menu

Making it better

Summary

8. Exploring the Wide World of D

Online resources

DWiki

Planet D

reddit and StackOverflow

This Week in D

DConf

DSource

Editors and IDEs

Text editors

Vim and Emacs

Textadept

Sublime Text

IDEs

Visual D

Mono-D

DDT

Code::Blocks

Tools and utilities

DMD

Optimized and debug builds

Changing the default output

Compiling libraries

Using libraries

Warnings

Profiling

Code coverage analysis

Compile and run

GDC and LDC

GDC

LDC

RDMD

DustMite

DCD

DVM

Libraries

code.dlang.org

Using libraries from the DUB registry

Registering libraries with the DUB registry

Browsing the DUB registry

Deimos and DerelictOrg

Summary

9. Connecting D with C

Preliminaries

Terminology

Bindings, wrappers, and ports

Dynamic and static – context matters

Static libraries and static linking

Dynamic libraries and dynamic linking

Dynamic and static bindings

Object file formats

Linkage attributes

Name mangling

Calling conventions

Putting it together

Binding D to C

Function prototypes

Manually loading shared libraries

Trying it out

C types to D types

Strings and characters

Special types

Enumerations

Structures

Pointers

Type aliases

Function pointers

Defined constants

Function parameters and return types

Symbols

Global variables

Macros

Conditional compilation

Calling C from D

D arrays and C arrays

Basic arrays

Arrays of arrays

Strings

Memory

C callbacks and exceptions

Calling D from C

Summary

10. Taking D Online

The software

vibe.d

Package overview

The anatomy of a vibe.d web app

The database library

MovieManWeb

Getting started

The basics of diet templates

Tags and indentation

Including and extending templates

The MovieManWeb layout

Setting up the database

Fleshing out the index page

Mapping web interface functions to URLs

Rendering diet templates

Rewriting index.dt

Adding movies

Implementing the addMovie function

Implementing the postAdd function

Implementing add.dt

Modifying index.dt

Modifying app.d

Modifying layout.dt

Listing movies

Implementing the listMovies function

Modifying the index function

Modifying index.dt

Finding movies

Implementing the postFind function

Implementing find.dt

Modifying index.dt

Modifying app.d and layout.dt

Implementing the findMovie functions

findMovie the first

findMovie the second

Editing and deleting movies

Expanding on MovieManWeb

Summary

11. Taking D to the Next Level

Concurrency

Threads and fibers

Threads

Fibers

Data sharing

__gshared

Shared

Synchronization and atomics

Automatic synchronization

Manual synchronization

Atomics

Message passing

Parallelism

More information

SafeD

Functional purity

The garbage collector

Connecting with C++

More on Phobos

std.container

std.datetime

std.digest

std.experimental

std.getopt

std.process

std.socket

Modules for Unicode and other encodings

System bindings

Game development with D

The future of D

Summary

Index

累计评论(0条) 4个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部