
Specification for the D Programming Language - crazypython
https://dlang.org/spec/spec.html
======
tastyminerals
I started reading about D couple of months ago after work. For me, it appeared
to be easier than Scala for example which I use at work. Not only is it
simpler, it is faster and I am not even talking about compile times. These
features alone persuaded me to rewrite couple of Scala based data processing
algorithms we use for our ML models to give it a try. What I really liked is
that you don't have to know all about the language to write perfomant code.
Still keep wondering how does it get constantly overlooked.

~~~
Neku42
This seems to be an increasingly growing niche where D is gaining popularity.
I see more and more people turning to D where they would normally use python
or R for adhoc data crunching

~~~
mochomocha
I also use D for data & ML at work (Netflix) when standard python workflow
doesn't cut it anymore. There's just so far you can go with the typical "call
a popular python lib interfacing with a C++ backend" paradigm before hitting a
brick wall.

~~~
Demiurge
How far is that? What about Cython?

------
RcouF1uZ4gsC
The big issue with D, in terms of no-overhead is that is has garbage
collection by default, and if I understand correctly, the garbage collector is
not as advanced as Java's or Go's.

While you can use D without the garbage collector, you will lose access to a
lot of the standard library, which limits the practicality of running without
garbage collection.

~~~
qznc
While the opinion-pendulum is currently on the contra-GC side, I still believe
GC is the correct default. Mostly because GC is easier than manual memory
management.

If you have real-time needs, then GC is probably out. That includes handling
audio and video playback.

Tight memory constraints are another killer argument against GC but that only
applies to small embedded devices. Smartphones, desktops, and servers have
enough RAM.

The great thing about D is that you can start the easy way with a GC. When
real-time or memory become constraints at some point you can selectively adapt
parts of your program.

You could say, D wants to provide Python and Rust and everything in between so
that you can shift seamlessly to wherever your specific sweet spot is.
Different parts of your program can even use different spots. In a game
engine, you could have the audio and rendering parts as non-GC real-time code,
while the game logic is easy high-level script-like.

We are very used to a scripting language plus compiled language combo these
days but is the separation a good one?

~~~
pjmlp
Just yesterday I posted a link about real time audio processing done in Java.

Anti-GC hate seems to always come from religious objection or having had back
luck not understanding how to actually use the tools at their disposal.

~~~
skocznymroczny
Most of anti-GC hate seems to be coming from C++ and Rust programmers. Also
game developers seem to hate GC with passion, then they go back to writing
their games with Javascript and C#.

~~~
pjmlp
It comes from long time.

One thing that having been an Oberon user teached me, was that having a GC
wasn't a show stopper for systems programming.

Ironically C++ has has GC support for more than 20 years now.

Managed C++ and C++/CLI on .NET, C++/CX on UWP, Unreal C++, and the GC API
introduced in C++11.

So it seems to be one of those things that you only learn to enjoy after
experiencing it personally.

------
sam0x17
I wish I had known about D 10 years ago. It's everything I ever wanted out of
an LLVM language, but I feel like it's dying and the package ecosystem is
tiny, which is crazy with how old it is. What they need is some new web design
and docs and exciting stuff to make it feel like a new language so people
recognize how truly awesome it is :/

~~~
vmchale
Plus affine types have gone mainstream. Good stuff, but I'd like memory
safety!

~~~
WalterBright
An ownership/borrowing system memory safety is in the works for D. There's a
prototype of it as a Pull Request:

[https://github.com/dlang/dmd/pull/10586](https://github.com/dlang/dmd/pull/10586)

~~~
theredbox
What is the type of apps that one should use D for ? I think this is one of
the main issues with languages that did not gain traction and that is they are
too generic and try to be too many things to too many people.

If i exclude the financial backing i think languages that tried to tackle one
specific thing did rather well. Rust came to be to address the issue with
security and there is not really an alternative. Yes people use it for cli
tools or backend services but that’s just because they are riding the hype
train.

The same with Go.

On the other hand we have things like Dart which did not really try to solve
an issue people felt they have. The same with Crystal. Nobody really needed
faster Ruby that much and if they did they already needed a production ready
solution which was just too hard to deliver.

A language like Nim reminds me of D. Its author is also a brilliant Phd CS
person but I feel like he does not really have a problem to solve. It’s all
just an intellectual challenge. Companies like Status.im ( backer of Nim )
have a problem that they are trying to solve by using Nim. Making the right
and the perfect solutions is hard but this evolutionary approach is really
harming the expansion of the ecosystem. Nim has just too many features and too
many approaches to memory management (recent gc:arc release). But it is all
too half baked and does not support the features Nim advertises that it has.

This is basically the same issue i have with D. I have no idea what I would
use D for. And could i rely on D in the domain i pick it for ? Eg the same
field where Go excels.

~~~
vmchale
> Rust came to be to address the issue with security and there is not really
> an alternative. Yes people use it for cli tools or backend services but
> that’s just because they are riding the hype train.

I like Rust for CLI tools because it takes some nice ML features and it
handles strings sensibly.

~~~
jane_red
Last time I tried to install a Rust-based cli network tool it took literally 4
min to compile it! Seriously, 4 minutes for something that monitors your
network load. If this is what it takes to make a cli tool, I'd rather do it in
plain BASH :)

------
Google234
It's cool to see D on hacker news but isn't more interesting content related
to D that could have been linked instead? The table of contents to the spec is
pretty bland.

------
joecool1029
My only experience with D is getting the free onedrive client to run on
linux[1]. What's more frustrating than the small ecosystem is the fact that
the reference compiler, DMD, is limited to x86/x86_64 and you need a working D
compiler to compile the primary alternative, LDC2 which can't bootstrap
itself.

In order to get something like that to compile for aarch64, you have to build
a recent GCC with the very old dmd frontend enabled, and then you can compile
LDC2. This all to use one app!

[1]
[https://github.com/abraunegg/onedrive/](https://github.com/abraunegg/onedrive/)

~~~
ben-schaaf
Why would you have to bootstrap the compiler to simply install an app?

~~~
joecool1029
Because nobody had a binary of the app for my architecture?

------
edflsafoiewq
Does D have something like Rust's #[derive(Debug)] or #[derive(Hash)]?

~~~
Neku42
Standard library doesn’t provide similar functionality but it’s trivial to
implement a mixin template that would implement print or hash function for any
type

That being said standard formatting function can automatically print most
types including user types. This eliminates necessity for automatic formatting
implementation in majority of situations

------
crazypython
You can help D's ecosystem by contributing a CTFE that frees memory as it
executes, and by implementing struct postblits.

~~~
mhh__
> and by implementing struct postblits

Eh?

------
lokar
There's no weekend warriors on the D. You're either on it... or you haven't
tried it.

------
rambojazz
Is there a reason for posting this link? Like the specs has just been
published or something?

I wish people gave some context of why they post links without context and why
I should be interested in the link.

------
svnpenn
Has anyone had luck building a D program with static cURL? The D distributions
ive seen only supply a DLL, and I have messed with some compiler flags but it
always wants to search for a DLL.

------
rsstack
(2001)?

~~~
giancarlostoro
If it's an article that hasn't been updated since 2001 sure. But this has been
updated fairly recently, in this year.

~~~
laurentlb
What are the biggest recent changes?

~~~
WalterBright
Plenty of action going on:

[https://dlang.org/changelog/2.090.0.html](https://dlang.org/changelog/2.090.0.html)

~~~
qznc
DIP1021 is one step toward a larger goal outlined in the blog post 'Ownership
and Borrowing in D'. What are the next steps?

[https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1...](https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md)

~~~
WalterBright
A prototype for the O/B system:

[https://github.com/dlang/dmd/pull/10586](https://github.com/dlang/dmd/pull/10586)

~~~
giancarlostoro
This is really fascinating, are there some benefits you foresee of this
addition to D? I know the O/B system has been popularized by Rust, but have
not really thought about it outside of Rust, is this an efforts towards
-betterC or will it be used towards those efforts?

~~~
WalterBright
An O/B system is a way to:

1\. eliminate double frees 2\. eliminate use-after-free 3\. eliminate memory
leaks 4\. using undefined pointers

when using explicit memory management like malloc/free. Any D application,
including DasBetterC, that uses explicit memory management can benefit from
it.

------
ossworkerrights
D is by far my favourite niche language, due to its clean syntax and ease of
use. I am surprised it’s not gaining traction.

~~~
ncmncm
D is not different enough from C++.

It's like C# to Java, which has traction only through relentless flogging by
Microsoft. There's nobody to flog D.

~~~
DrBazza
D today is C++2040.

~~~
mlyle
Nah, because C++40 will just accumulate more and more unpredictable cruft
while D is clean.

~~~
qznc
D is not clean. It already has some cruft. For example, there should be no
"@safe" annotation but an "@unsafe" one. Unfortunately, D picked the wrong
default back then.

Ok, "in relation to C++" it is clean. :)

Edit: There is a proposal to fix it:
[https://github.com/dlang/DIPs/blob/master/DIPs/DIP1028.md](https://github.com/dlang/DIPs/blob/master/DIPs/DIP1028.md)

~~~
teleforce
Pardon the pun, but @safe is a safe choice. IMHO, for general language it is
more productive by having low hanging fruits as the default. The popularity
follows consumer->enterprise->military->aerospace, and safety gets more
critical up the systems food chain. That's propably the main reason Ada is not
a common or popular programming language since it is for higher end of the
food chain.

~~~
wwright
This makes more sense as an argument for dynamic typing or GC by default than
a “safe” keyword, imo.

From my experience with Rust, there’s basically _never_ any cost in sticking
to safe code. The standard library and crates pretty much always give you
enough tools.

Unsafe is really only ever needed if you’re implementing the core of an
abstraction, which is probably not something that’s going to deter “casual”
users imo.

The borrow checker and and type system definitely can be thorny at times,
though. Other times they’re very easy to work with! But having a more
ergonomic way to fall back to Java-like behavior, if only for debug builds,
would make languages like Rust _much_ more accessible.

~~~
WalterBright
D's nascent ownership/borrowing checker will operate at the function level. So
you can incrementally use it as it suits your application.

