20 ms·
Facebook is using D in production starting today
- ferd 13y ago> 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 13y agoThe way I read it is that he added some D code to an existing C++ project's repo.
- speg 13y agoIt was probably in a personal or team repo.
- ryanSrich 13y agoI read it as the facebook repository, the live site. They'd been using it on other internal projects which I'm sure were under source-control.
- asdasf 13y agoThe project was in C++, in source control, and under heavy use. Now it is in D.
- k__ 13y agoI'm really interested why D doesn't get much love from C/C++ devs.
- arte2k 13y agogarbage collector
- k__ 13y agoso the GC isn't optional in D?
- arte2k 13y agonot as far as I know. while having garbage collection was an asset when java was created, currently with ubiquitous RAII usage in c++ it's just a hindrance.
- deleted 13y ago[deleted]
- eco 13y agoThe GC is optional in D (parts of the standard library use it so you'd have to avoid those). D uses RAII when it makes sense too.
- Pxtl 13y agoIt is, but the standard library uses it so you have to avoid them if you want no GC.
- CountHackulus 13y agoThat's changing. The standard library is almost entire GC-free now.
- he_the_great 13y agoThat's a little adventurous. std.algorithm is known to only have one function which allocates. The rest of Phobos is being looked at, but to this point I don't think it has been combed thoroughly enough to say "almost entire."
- jmdavisProg 13y agoYeah. The "almost entire" applies to std.algorithm. How much allocation goes on elsewhere depends on what module you're talking about. Some definitely avoid it, whereas others definitely require it. That will be (and has been) changing though. The main thing is probably going to be making much heavier use of output ranges rather than automatically allocating arrays/strings. We'll get there though, because there's clearly a lot of interest in doing so, and there's no fundamental reason why we can't.
- speeder 13y agoMaking history short: because the first time it took off it ended having two incompatible "standard" libraries that were so competitive that even bad blood happened.
- albertzeyer 13y agoI was mostly not interested by it because the reference implementation is not open source. I checked, to get the facts straight: DMD is the reference implementation. The frontend is under GPL but the backend (optimizer and codegen) is not. The source code is available but you are not allowed to redistribute it. https://github.com/D-Programming-Language/dmd/blob/master/src/backendlicense.txt https://github.com/D-Programming-Language/dmd/blob/master/sr... (I wonder if you are allowed to fork it on GitHub.)
- samuell 13y agoYeah, but there are the GDC [1] and LDC [2] implementations, which AFAIK uses their respective (open source) backends, so that should really not be a problem IMO ... [1] http://gdcgnu.sourceforge.net/ http://gdcgnu.sourceforge.net/ [2] https://github.com/ldc-developers/ldc https://github.com/ldc-developers/ldc (In my tests, they are also mostly the fastest ones, especially LDC ... see for example my comparisons in http://saml.rilspace.org/moar-languagez-gc-content-in-python-d-fpc-c-and-c http://saml.rilspace.org/moar-languagez-gc-content-in-python... ... D with LDC is among the top contenders, together with various optimized C versions ...)
- steveklabnik 13y agoOver various points in the lifetime of D, GDC was dead, then LDC was dead, then GDC was alive again, then...
- sol1684 13y agoLooking at the commit history, GDC has been in steady development since about 4 years now after a pause and LDC is being steadily developed since its beginnings (with changing main authors). Both have very active maintainers these days.
- Keyframe 13y agoThings might've changed now, but Steve is right. there used to be a sense of dread with other compiler directions. Last time I was in, GDC was about a year without any serious updates. DMD on the other hand didn't have support for 64bit, which was imperative for my usage at the time. All this talk about D got me nostalgic about great group of people and a sense of accomplishment being made (with language and libraries) when I was using it. It makes me want to have another go, almost.
- kybernetyk 13y agoI'm a C++ dev. For me it's: - C++11 is good enough (and a little better than that) - The eco system. Yes, I can use C libs from dlang but managing extra bridges/headers is too much overhead if the alternative is just to throw them into my C++ project and use them without writing any glue code. - The garbage collector. (RAII fan here) - Tooling. Are there any good dlang IDEs with mature refactoring support and code completion? For the tasks I'm using C++ for, C++11 is more than sufficient. For more abstract/high level stuff where I don't particularly care about top performance/memory layout I don't need another C++ contender but can use higher level languages/scripting languages. D would look more tempting if there was no C++11 but for now for me I'm perfectly happy with C++.
- k__ 13y agosorry, I killed your 1337 karma.
- kybernetyk 13y agoYeah, I already planned to create another account, upvote me once and never comment again ;)
- alecbenzer 13y agoWhat exactly is the argument for garbage collection over RAII-style freeing? Even in garbage-collected languages, you still need to do things like close file objects; the runtime doesn't do so automatically when it detects that there are no stack references to the file. Same goes for unlocking mutexes, or any of the other things that RAII tends to address. Is it just that maintaining ownership semantics for heap memory tends to be more complicated than doing the same for file objects (much more rarely shared, I'd guess) or mutexes (not sure if "sharing" is even sensibly defined here).
- crawshaw 13y agoIt is hard to manage ownership when allocations are passed around between concurrent threads. Garbage collection in Go makes goroutines and channels easy.
- Keyframe 13y agoI kind of bet hard on D, and I know people that bet even more. Last time I used it was 4 years ago. I was using the other standard library (yeah, there were two, kind of), there were bugs which weren't resolved for years, there were issues with people camping on both sides of standard libraries, there was development stagnation because D2 was being pushed hard... but it all boils down to preference. D1 (with Tango) to me was like a really really good blend of C with classes and modern stuff in it (mixins for example). I was happy with it, but then D2 started to emerge which was more templatey than I was comfortable with. I have accepted, long ago, that I am a C programmer, not C++, by heart. Ultimately following factors threw me away from D altogether: - my code isn't an island, I leverage a lot of libraries, and for each and every one I had to use I had to either make my own bindings or rely on somewhat unstable other people's bindings. I accepted the reality of it, but it wasn't something I wanted to waste my time on. - D2 - it just didn't feel the same - Lack of tools. DMD compiler, while somewhat working, was a lackluster (to be polite) compared to what I was used to in C world. There was a GDC frontend for gcc which, at the time, wasn't actively developed, there was an attempt to make a LLVM thing.. but if you wanted to work with D, at that time, you pretty much had to use DMD - several bugs which were ignored in core development which were uncomfortable for my use. I didn't have the expertise at the time to help with resolving that. Coincidentally just yesterday I received an update from bug tracker that bug I reported four years ago is still in. - Development of D pretty much relied on one man alone - out of frustration and a tight deadline, I developed something in C at that time and came to a realization that "it just works". I was able to concentrate on my task at hand instead of tackling various gotchas and doing extra amount of work that I had to with bindings etc. D is more than 10 years old. Honestly, I think it has good ideas, I really liked the approach of D1, but I think it will never catch on en masse.
- steveklabnik 13y agoMy friends and I implemented an operating system in D back in college, and I just want to say that I agree entirely with this post. It's mostly why I went into Ruby instead of staying in D, and why I'm doing Rust now instead of D today. That said, D has a lot of promise, and a lot of these issues have been worked out, but I feel like there are many people like you and I...
- scott_s 13y agoI think that D2 is really interesting. But I think it doesn't get as much traction because it was an improvement over C++03, but there was no fundamental change in how one developed. I think people switch languages when there's a huge change in how they develop programs - such as a new abstraction that opens up a new programming model. Many, smaller improvements don't seem to add up quite the same way. Now, I'm less clear on how D2 compares to C++11. Certainly some of the smaller improvements matter less, as C++11 has them.
- sol1684 13y agoMy feeling is that you really have to try it out for some time to see why it really makes a difference* . And, although C++11 indeed has caught up in some areas, there are in fact many smaller and some larger things that still do make a big difference in practice. But in general the fact that it's not just one or maybe a few primary features indeed probably makes it more difficult to judge the actual benefits from the outside. The drawbacks today are in my eyes mostly the relatively minimal support for non-PC platforms and that a number of language features are not yet completely finished. But if the main target are x86 based systems and the use of cutting edge features is not the primary concern, D2 is a great development tool today. * I can only really talk about my experiences going from C++ -> D, but it was a long process where my way of designing systems and solving problems was gradually altered in many areas - much to the better. And the immediate reward of course is the extreme gain in productivity due to concise syntax, fast compilation times and, last but not least, the lack of a need for header files.
- he_the_great 13y agoMuch of the initial design come from improving the language grammar and syntax. That limited improvement didn't last long, but it was an initial motivator (Walter being a compiler writer and C++ being horrible language to parse). The D community has greatly pushed D away from this initial improvement. In C++ there is a separation of the developer tools and the library writer tools. I think that separation still exists in D, but it is in an area even library writers don't/can't reach for in C++. Ultimately D doesn't force a fundamental change, but as one learns to use the language, the result is a fundamental change.
- d0m 13y agoI 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 = {}
- dleimbach 13y agoWhy not: using namespace std; map<int, vector<int>> whatever; It's a lot shorter, actually correct, and it's totally cool to import whole namespaces in a .cpp implementation file where you're likely to actually declare something like that. If you're going to critique the language you should try to learn it first.
- subb 13y agoWell to be honest, d = {} is absolutely not equivalent to a map of int to a vector of ints. Sure in javascript, you can indeed use an object as a map, but you are lacking the type safety that the C++ version provide and all the nice API. Also, in C++11, you can shorten it with auto : auto whatever = new std::map<int, std::vector<int>>(); and to be fair with the js, if you want it as short as possible, you could use a using namespace statement for std (although not really recommended) : auto whatever = new map<int, vector<int>>(); or maybe not use new : map<int, vector<int>> whatever; I don't think it's that bad. But sure, any dynamic language will be less verbose that a static language because, well, you are removing information...
- zokier 13y agoC++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.
- WalterBright 13y agoAbout half of D developers (according to an informal poll) come from a C/C++ background.
- yarrel 13y agoIt's the Opera of programming languages.
- rickjames28 13y agoI'll interject at this point for a bit of my philosophy on language adoption. There's something called time-to-market in the business world. D and Scala have seemed to have missed it. It has nothing to do with technical excellence, but with tech-cultural perception. D gets alot of play over at /r/programming but it's going nowhere. It's been around for a long time and the systems that are naturally conducive to D have been evolved to the amazing re-invigoration of C++. Jim, it's dead.
- telephonetemp 13y agoBetween D, Nimrod and Julia it looks like there's a resurgence of fun in (JIT) compiled languages.
- deleted 13y ago[deleted]
- pjmlp 13y agoAll 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-components-postattachments/00-10-32-72-38/Ext_2D00_VOS.pdf http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-co...
- rbehrends 13y agoAll available D compilers generate native code directly, there is no JIT involved. I think that's why the GP has the JIT in parentheses (to account for Julia's implementation, which does use a JIT-compiler, as opposed to D and Nimrod)
- pjmlp 13y agoFair enough, it wasn't clear to me.
- Jtsummers 13y agoSometimes 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?
- 13y ago
- Sathi 13y agoReally 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 13y agoAndrei 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.
- X8FntewI 13y agoThere is another project at facebook which uses Haskell [1]. It's a DSL that replaces an interpreter which was written in C++. Performance was one of the reasons for replacing it, and the talk includes an comparison of the performance of the two approaches. [1] http://skillsmatter.com/podcast/home/simon-marlow http://skillsmatter.com/podcast/home/simon-marlow
- deepvibrations 13y agoFacebook loves the D
- boduh 13y agoI 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 :)
- lclemente 13y agoFor anybody wondering how D compares to Go, have a look at http://stackoverflow.com/questions/3554956/d-versus-go-comparison http://stackoverflow.com/questions/3554956/d-versus-go-compa...
- pjmlp 13y agoEasy, 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.
- judk 13y agoThe Go core devs have said they are targeting Python devs now who want more stability and performance for heavy applications.
- enneff 13y agoNo we haven't. We're targeting programmers who want to write software. (Sounds glib, but it's true.)
- asdasf 13y agoExcept 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 13y agoI 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.
- knodi 13y agoBiggest advantage of D synchronized functions as a lang feature.
- vvnraman 13y agoFor 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
- swah 13y ago(extra dot in the end of the URL)
- mcav 13y agoPSA: The best way to delimit URLs is to enclose them with angle brackets (< and >) as per < http://www.ietf.org/rfc/rfc2396.txt http://www.ietf.org/rfc/rfc2396.txt >. However, like many flaws with HN's underdeveloped software, you can't actually do that on HN because the parser includes the trailing > in the URL. So your best bet here is with whitespace.
- leoedin 13y agoI'd argue that the world has moved on since 1998. We live in a world full of URL parsers of various abilities, and doggedly enclosing URLs in angle brackets because of a memo written so long ago it also references gopher seems stubborn to no obvious gain. Given the state of the modern internet, I definitely wouldn't consider angle brackets to be the best way to delimit URLs.
- smrtinsert 13y agoAnd yet hashtags exist and lisp is cycling back yet again. I don't know if there's a convention, might as well re-explore it.
- dangayle 13y agoI think most of us are more used to delimiting urls using [markdown syntax](http://daringfireball.net/projects/markdown/syntax http://daringfireball.net/projects/markdown/syntax)
- smrtinsert 13y agoFacebook 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.
- warmwaffles 13y agoSeeing D in production is a good thing. Google picking up a language doesn't prove anything. Seeing a language in production in a high volume setting is impressive.
- jmdavisProg 13y agoHaving 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 13y agoMight have as much to do with the persuasive powers of Andrei Alexandrescu as the maturity of D.
- utopkara 13y agoDoes D have anything to do with the client-side? All this morning, the browser tab keeps crashing whenever I load facebook in chrome.
- utopkara 13y agoSafari seems to load fine. I have a OSX 10.8.4 and Chrome 27.0.1453.110
- WalterBright 13y agoFor 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 13y agoThe 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 13y agoWell, 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 13y agoBBSs 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.
- Erwin 13y agoThe forum sends back a simple preformatted chunk of HTML which is then inserted at a certain spot. It does not send a complex JSON object that is then marshalled into some kind of Angular-Knockout-Backbone framework of the day where complex magic creates views, links and templating language formats objects into HTML created via DOM. As JS in the browser speed up, all those framework find some way of using it. Sure, your 5-item TODO list app looks good...
- WalterBright 13y agoThe D project code is entirely on github: https://github.com/d-programming-language https://github.com/d-programming-language Naturally, contributors are welcome!
- freyr 13y agoApple 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 13y agoOne of these languages is not like the others.
- garg 13y agoNone of these languages are like the others.
- nollidge 13y agoI believe they're referring to syntax, in which case, Go is rather unlike the others.
- seabrookmx 13y agoNo, 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 13y ago> 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=52716 http://research.microsoft.com/apps/pubs/default.aspx?id=5271... 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.
- shawn-butler 13y agoCongratulations. What is the status of workable compiler and standard library on ARM?