
Facebook is using D in production starting today - chmike
http://forum.dlang.org/thread/l37h5s$2gd8$1@digitalmars.com
======
vvnraman
For an excellent discussion between the philosophies that went into the design
of D and how they compare to Go, visit

    
    
      https://groups.google.com/forum/#!topic/golang-nuts/8k59RgkeJ6s
    

The discussion between Andrei Alexandrescu (Facebook) and Ian Lance Taylor
(Google) is highly intellectual, especially the part about how each language
addresses concurrency.

EDIT: Removed dot at the end of the URL

~~~
acqq
The most important Andrei's quote:

"D has resolutely exited C++'s shade because it is good at things C++ is not
good at, in addition to being good at things C++ is good at. Also, Go would be
tenuous to frame as a better C because it cannot do everything C does - e.g.
unsafe memory access and manual memory management, which are needed in certain
systems - and it interoperates poorly with C."

In short, he states that D can do unsafe memory access and manual memory
management. Go can't.

~~~
derefr
Sounds like D would be better-compared to Rust, then.

~~~
luikore
D is more like C++ without macro and with GC plus some engineering features
(unit test is a language feature? weird). Rust looks different and does
different. For example, idiomatic foreach block in Rust is a syntax sugar of
passing lambda, which is more friendly to parallelism. While in C++/D it is a
syntax sugar of classic for-loop with iterator, which is more efficient in
unparalleled environment.

~~~
dbaupp
_> For example, idiomatic foreach block in Rust is a syntax sugar of passing
lambda, which is more friendly to parallelism_

This changed with the recent 0.8, `for` is now syntax sugar for using the
Iterator trait, which optimises exactly like C++ (the vector iterator even
vectorises when LLVM can do it).

Rust has actually moved to have iterators that are very similar to (a subset
of) D's ranges.

------
WalterBright
For one example of a D program in production use, check out
[http://forum.dlang.org](http://forum.dlang.org). The forum software is
entirely written in D (written by Vladimir Panteleev).

(Although due to this announcement, the site is being slammed at the moment.
It's a single server hosting dlang.org, not a farm.)

~~~
jkn
The responsiveness of this forum is amazing. Is the client side doing some
pre-fetching?

I remember finding the website disturbingly fast on my first visit. I wonder
if it is just me being so used to loading delays, or if there is a point were
you can be so fast that it is detrimental to the user experience. The latter
doesn't sound like it makes sense so it must be of matter of getting used to
it.

~~~
dscrd
Well, a forum is essentially the same thing as BBSs were in the 80s but now we
have computers that are several thousand times faster. I find it much more
"amazing" that the other forums are so slow.

~~~
bad_user
BBSs in the 80s / 90s were operated by users in their own homes and usually
weren't allowing for multiple connections. The software itself was pretty dumb
and slow.

Forums these days need to allow for multiple users to log in, read content and
post messages. I'm pretty sure that the link above received several hundreds
or thousands of users in a single hour. Forums these days also use database
systems (or other services external to the process) that represent a big
bottleneck. Then you've got the issue of static assets, like CSS, Javascripts,
images and so on.

As a general rule of thumb, if you want scalability, you have to trade some
throughput for it, as scalability concerns hurts performance.

That said, popular open-source web software, in general is awful in terms of
everything.

------
WalterBright
The D project code is entirely on github:

[https://github.com/d-programming-language](https://github.com/d-programming-
language)

Naturally, contributors are welcome!

------
smrtinsert
Facebook seems to use any language they want to at any time. I don't consider
it a major endorsement that it appears in production, it just lets me know its
on their radar.

If Google picked up D I would be much more interested as to why.

~~~
jmdavisProg
Having D used in production in a big company like Facebook is a big deal. No,
it doesn't mean that D has taken over the programming world or anything like
that, but it shows that the language is maturing and that real companies are
now willing to use it in the real world - and it's a pretty major company at
that.

So, this is just one step forward, but it's a big one and exciting to the
folks who are fans of D - especially those who have put a lot of time and
effort into it.

~~~
warmfuzzykitten
Might have as much to do with the persuasive powers of Andrei Alexandrescu as
the maturity of D.

------
k__
I'm really interested why D doesn't get much love from C/C++ devs.

~~~
d0m
I knew when I was a C++ dev that any "other languages" was just not serious.
Lots of friends who are master in C++ call everything else than C and C++
"scripting languages". I was in that closed-mind ecosystem of C++ elitist but
then, luckily, I learned about Python and it caught my interest.. and then
from there I've learned Lisp, Ruby, Javascript, etc etc. And I haven't touched
C++ after that.

Note that I live in a startup environment all the time and the time and cost
to develop in C++ is just _too damn high_ for me. Also, the verbosity and its
philosophy kills me.

What was it?

    
    
        std::map<int, std::vector<int>> whatever = new std::map<int, std::vector<int>>();
    

Why not

    
    
       d = {}

~~~
zokier
C++11 brought type inference so these days it would be either

    
    
        auto whatever = new std::map<int, std::vector<int>>();
    

or

    
    
        std::map<int, std::vector<int>> whatever;
    

depending on if you want heap or stack allocated variable, stack allocation
usually being preferred as the default solution (and thus being the tersest
form).

But lets look a bit deeper why C++ is more verbose in this case. One central
reason is the idea that standard library should not be special/privileged in
the language syntax. The upside from that is that almost all syntax sugar can
be applied to user defined types. A relevant example would be uniform
initializer lists in C++11, which allow you to write eg.

    
    
        std::vector<int> foo {1,2,3};
    

but also

    
    
        MyFunkyDatastructure bar {1,2,3};
    

as long as suitable constructors are defined. In comparison afaik in Python
you can not define a class that can be initialized with sugared syntax.

The theme of non-privileged standard library also extends to global namespace
pollution. In C++ stdlib does not get to reserve names at global namespace,
which leads slightly increased verbosity (std:: -prefixes or using-
statements).

So when you ask why you cant make a map/dict in C++ with just 'd = {}', know
that there are actually good reasons for (some/most) of the verbosity. The
tradeoffs might make it less suitable in your usecases, but there is no
absolute/general superiority in either way.

~~~
d0m
>> know that there are actually good reasons for (some/most) of the verbosity.

This is why I talked about the philosophy of the language. I wasn't arguing
about whether it was good or bad.

That being said, for my own use cases, verbosity is a big deal.

>> In C++ stdlib does not get to reserve names at global namespace, which
leads slightly increased verbosity (std:: -prefixes or using-statements).

I understand and agree, but you'd have to agree with me that if you start
naming your classes Map and Vector, you're looking for problems ;-)

------
Sathi
Really interested to know what other compile-to-native-code languages that
they evaluated and why they chose D over other alternatives. Anyone knows if
such comparison is available?

~~~
steveklabnik
Andrei is a well-known member of both the C++ and D communities; he's probably
#2 after the language's creator, Walter Bright.

So I'd imagine it has something to do with said expertise.

------
boduh
I remember having a chat with Andrei, one of D's creators, almost one year ago
and saying: "If you want D to be more popular, maybe you should make an
announcement about Facebook using D internally". Seems that day is here :)

~~~
progx
But 1 year ago, facebook was popular than today ;-)

------
lclemente
For anybody wondering how D compares to Go, have a look at
[http://stackoverflow.com/questions/3554956/d-versus-go-
compa...](http://stackoverflow.com/questions/3554956/d-versus-go-comparison)

~~~
pjmlp
Easy,

Go is targeted for developers that can move out of C in their use cases.

D is targeted for developers that can move out of C++ in their use cases.

~~~
asdasf
Except that the go developers explicitly stated their design goal was to
replace C++ for their needs, not C. And that completely failed, and now the
focus is on pulling in python devs.

~~~
pjmlp
I jumped into Go bandwagon early on, even tried to do some initial
contributions. Mostly because Go has an Oberon feel to it. A GC enabled
systems programming language I used for a while in the mid-90's.

However, I quickly became disappointed with Go's spartan design, given my
broad experience across languages and paradigms.

That is why somehow I feel it is more indicated for C developers, that could
live with a GC enabled language.

As they would mostly getting type safety and a few more features, whereas
developers from other languages are mostly giving away features.

------
ferd
> Today I committed the first 5112 lines of D code to Facebook's repository.

> The project is in heavy daily use at Facebook

So, they had code under heavy use which was not under source-control?

~~~
guelo
The way I read it is that he added some D code to an existing C++ project's
repo.

------
telephonetemp
Between D, Nimrod and Julia it looks like there's a resurgence of fun in (JIT)
compiled languages.

~~~
pjmlp
All available D compilers generate native code directly, there is no JIT
involved.

Sometimes I wonder how computing would look like if the default
implementations of Java and C#[1] were available from the start as native
compilers, instead of VM environments.

[1] Funny enough, the precursor of .NET was native and COM based, similar to
what is now WinRT, more info here,

[http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-
co...](http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-
postattachments/00-10-32-72-38/Ext_2D00_VOS.pdf)

~~~
Jtsummers
_Sometimes I wonder how computing would look like if the default
implementations of Java and C#[1] were available from the start as native
compilers, instead of VM environments._

At least with Java that would defeat one of the main intents of its
development. What would you think would be gained by having non-VM based
implementations of these by default?

~~~
Touche
Start up time. You can't write cli programs if the JVM takes 100+ms to start
up.

~~~
judk
How do webservers solve this problem and why can't CLI programsw do the same?
Invoking a Java program could connect to a running jvmd daemon

~~~
Jtsummers
They "solve" it by being long running applications. When GP says CLI they
likely mean things like grep or cat or other command line tools, not just
interfaces, that tend to run in a very short time. A Java implementation would
see a lot of extra time spent on just the startup. Consider writing a bash
script that calls out to grep for each of a bunch of different files (an
example, better ways, but go with it). Say it ran grep 100 times, jgrep at
100ms startup time would take 10s longer just on the java startup time,
ignoring any other performance differences.

------
knodi
Biggest advantage of D synchronized functions as a lang feature.

------
freyr
Apple has Objective-C, Mozilla has Rust, Google has Go, Microsoft has C#. I
wonder if Facebook was feeling a little left out of the post-C++ language
party?

~~~
andralex
One of these languages is not like the others.

~~~
garg
None of these languages are like the others.

~~~
nollidge
I believe they're referring to syntax, in which case, Go is rather unlike the
others.

~~~
seabrookmx
No, I think he's referring to C# which runs on a VM.

You couldn't write an operating system, or realtime code in C#.

It's not even in the same league as the other three, and would be better
compared to Java.

~~~
pjmlp
> No, I think he's referring to C# which runs on a VM.

This is not true. The CLR is just one of many C# implementations.

Mono provides a native compiler for C#.

Bartok is a native compiler for C# from Microsoft Research.

> You couldn't write an operating system, or realtime code in C#.

Except people have already done it in the past.

[http://research.microsoft.com/en-
us/projects/singularity/](http://research.microsoft.com/en-
us/projects/singularity/)

[http://research.microsoft.com/apps/pubs/default.aspx?id=5271...](http://research.microsoft.com/apps/pubs/default.aspx?id=52716)

[http://singularity.codeplex.com/](http://singularity.codeplex.com/)

[http://cosmos.codeplex.com/](http://cosmos.codeplex.com/)

> It's not even in the same league as the other three, and would be better
> compared to Java.

Similarly to Modula-3, C# has all the required low level capabilities for
systems programming with unsafe blocks and annotations.

It should be compulsory for everyone to learn about compiler design, before
comparing programming languages.

~~~
seabrookmx
Fair enough. I should have specified CLR instead of C# in general.

That said, I stand by my argument that it is better compared to Java, though
the later revisions have been adding more C++-esque low level features. I find
C# a good compromise.

> It should be compulsory for everyone to learn about compiler design, before
> comparing programming languages.

My oversight, and difference of opinion with you does not mean I'm an
uneducated idiot. I wrote a (limited) C compiler in my undergrad and
programming languages was large mandatory portion of 4th year. If you rear-
ended somebody on your morning commute, I'm not going to assume you're a
dangerous driver and should be pulled off the road.

This is Hacker News - not Reddit. The least we can do is act like that means
something.

------
utopkara
Does D have anything to do with the client-side? All this morning, the browser
tab keeps crashing whenever I load facebook in chrome.

~~~
utopkara
Safari seems to load fine. I have a OSX 10.8.4 and Chrome 27.0.1453.110

------
shawn-butler
Congratulations. What is the status of workable compiler and standard library
on ARM?

------
deepvibrations
Facebook loves the D

