

Programming in D – Tutorial and Reference - ingve
http://ddili.org/ders/d.en/

======
omginternets
Serious question: are D and Rust trying to be the same thing?

I'm not asking whether or not their approaches are different, but whether or
not they're trying to solve the same problem(s). I get the sense that this is
the case; they're both trying to be a "safe C(++)".

~~~
wyldfire
IIRC D has a GC that you can opt-out of but in practice it's difficult to use
its standard library when you do.

I'm just repeating a critique that I read, I haven't evaluated them against
one another.

Having a GC excludes you from some programming domains -- well controlled
latency, bootstrapping/operating systems.

~~~
acehreli
The GC situation is getting better:

\- The language has the @nogc attribute to ensure at compile time that the GC
is not used in a function or an entire module.

\- The number of standard library functions that have the @nogc attribute is
increasing by the minute. :)

\- There is some effort to port Sociomantic's proprietary multi-threaded GC to
D (theirs was written for D1).

------
acehreli
I am the author (of the book). AMA.

Ali

~~~
claudiug
Why do you choose to write a book about dlang?

Can you give us us some godo area when dlang can be used?

Can we use dlang to build IOS/Android apps?

What is the advances of this language over go, python, java, ruby, rust?

~~~
qznc
Advantages compared to ...

Go: Generic type-safe highly efficient code. Can go lower-level like inline
assembly. Can go higher-level because more meta programming.

Python: Faster. Static typing.

Ruby: See Python.

Java: Less boilerplate. More control over memory management. More meta
programming. Natively compiled.

Rust: Easier. Garbage collection makes programming just as safe and is easier
to use. Looks and feels more like C/C++/Java, if you already know them. More
meta programming.

(of course, downsides of D are omitted ;)

~~~
pjmlp
Java is also native compiled. Language != Implementation.

OpenJDK is only the reference implementation. There are plenty of commercial
implementations with AOT compilers.

Edit: did not write != properly

~~~
qznc
Yes, but it shows that the language was designed for interpretation. E.g. lazy
static initializers is weird in AOT compilation.

~~~
pjmlp
It is not weird in functional programming languages.

~~~
qznc
I think you misunderstood me, because I used "lazy". It has nothing to do with
Haskell lazyness.

In Java static fields are initialized when a class is loaded by the class
loader. A class is only loaded when used. If anything (IO,scheduler,etc)
changes the order in which classes are used, then initializers are called in a
different order and their side effects as well. This semantic is mandatory by
language definition.

In a Java AOT compiler this means every access to a static field must be
prefixed with a (synchronized) check if the class is already initialized and
optimizing it away is rarely possible. A JIT compiler does not even care,
because it knows the class is already loaded.

For contrast, in C++ static fields are all initialized before main is called.

~~~
pjmlp
Actually I don't know how the current AOT compilers approach that situation.

Now with Oracle taking the steps to eventually make AOT compilation also a
feature in the reference JDK, I suppose whatever issues might still exist they
will be tackled.

------
cooleng
What's the difference between D and C++? What's the difference between D and
C#? What's the difference between D and rust? Who(which project or company) is
using D? What's D is mainly designed for?

I like the syntax of D instead of rust, because it is much more like c++. The
syntax of rust is weird to me.

------
Snackchez
This might be a silly question: what is D used for? I "scanned" the site
fairly quickly and didn't grasp the general application idea behind it.

~~~
qznc
Facebook has made a C-Preprocessor. D is great for such command line tooling.
The standard library is not as extensive as Python's, but the situation is
much better than in C-land. You can also use it as a scripting language.

D has a nice framework for servers (vibed.org), so you can write webservices
(REST,JSON,etc). There is no great full-stack web framework like Rails or
Django though.

GUI stuff works in theory, but I don't know any non-toy project. Games
(OpenGL,SDL) are possible, but no serious project, yet.

Android/iOS does not really work, yet. Same with embedded, standalone, kernel
stuff. ARM in general needs more work. For HPC it really depends on the use
case (see dlangscience.github.io). Vector support and GPU integration is
lacking. I don't know any image, video, or audio processing stuff in D.

~~~
jibalt
Actually, that C Preprocessor was written by Walter Bright for DMC; just about
every file has his copyright notice, and no Facebook copyright notice. I think
they just translated it from C++ to D.

------
aikah
what is D concurrency model ? does it have channels or classic threads ?

~~~
qznc
D is not really opinionated about concurrency and parallelism. It provides
access to the OS mechanisms (pthreads). The standard library also has some
task-based stuff. Then there are fibers (user-level threads), which vibed.org
makes convenient to use. There is no definitive channel/queue mechanism
provided by the standard library so far, but people have implemented them in
libraries.

tl;dr: With D you use whatever is best for you.

