12 ms·
I'm really interested why D doesn't get much love from C/C++ devs.
by k__ 13y ago
I'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.
- eco 13y agoI'm not sure where you got that idea but that's not true. The standard library make heavy usage of the GC. There is talk of implementing ARC to replace or supplement the GC and the standard library will most likely soon start using output ranges to avoid forced GC allocations in many cases but that hasn't happened yet.
- albertzeyer 13y agoFrom Wikipedia: "Memory is usually managed with garbage collection, but specific objects can be finalized immediately when they go out of scope. Explicit memory management is possible using the overloaded operators new and delete, and by simply calling C's malloc and free directly. Garbage collection can be controlled: programmers can add and exclude memory ranges from being observed by the collector, can disable and enable the collector and force a generational or a full collection cycle. The manual gives many examples of how to implement different highly optimized memory management schemes for when garbage collection is inadequate in a program." I wonder if the GC is stop-the-world.
- steveklabnik 13y agoFrom http://dlang.org/garbage.html http://dlang.org/garbage.html : > Stopping all other threads than the thread currently trying to allocate GC memory.
- pcwalton 13y agoIn D the garbage collector is stop-the-world and conservative, last I looked.
- qznc 13y agoThe D community has not found any good alternative yet. The wiki contains a summary: http://wiki.dlang.org/Versus_the_garbage_collector http://wiki.dlang.org/Versus_the_garbage_collector
- 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.