6 ms·
> For things that don't need classes (and there is a lot of code) I stick to C. I'd use D anyway just for the GC or whatever, less compiler fighting, betterC e
by petre 7y ago
> For things that don't need classes (and there is a lot of code) I stick to C.
I'd use D anyway just for the GC or whatever, less compiler fighting, betterC etc. Procedural, OOP, functional, yay.
- rowanG077 7y agoReally? For me the presence of a GC disqualifies D as the main replacement for C and C++.
- mhh__ 7y agoHow much software genuinely requires not having a GC? If you don't want it, don't use it, but using it can make your software completely safe and fast (Garbage Collection is often faster than RC as long as pause times are acceptable, and added memory use). A lot of the standard library ranges are inherently lazy and therefore require no interaction with the GC. Exceptions are also nogc now.
- quicknir 7y agoIf you can tolerate GC then like 20 languages (as or less obscure than D) enter the conversation. If you can tolerate GC and the performance implications that go with it, then using C or C++ is rarely a good choice to begin with (well, other than legacy, which is a valid and common reason).
- mhh__ 7y agoD isn't defined by performance or memory management, however. There are many D features which are just blisteringly professional in how they approach software development: Using D is conducive to writing good software. Metaprogramming, for example, in D is obvious and almost fun. The compile times are ridiculous compared to C++, i.e. I can build the main D compiler in three different configurations in about 5sec on my machine.
- quicknir 7y agoI'm not saying that D is defined by that. I'm simply saying that if you're comparing to C or C++, you are talking about use cases that are defined by performance and/or memory management (or else, they are being used for legacy reasons). If you have a green field project that doesn't have massive performance concerns, and doesn't have to be specifically in C or C++ for other reasons (toolchain availability, available developer resources, etc), you probably aren't using C or C++. Some people would argue that you can use D for equally high performance things to C++, and make sure you use the GC very selectively, etc. However, you don't appear to be making that argument. If you aren't, then there's just no real point comparing C++ and D. If you don't have any of those requirements, and you are ok with obscurity, you have much stiffer competition from many other languages like Haskell, Kotlin, etc.
- WalterBright 7y agoThere are people who specifically use D for writing high performance applications. They find it faster than C++ for a rather subtle reason - D code is more plastic, meaning it is easier to refactor D code trying out different algorithms looking for a faster one.
- quicknir 7y agoI'm sure these people exist but they're the exception rather than the rule. The two biggest industries in SG14, the C++ low latency study group, are games and HFT. In both these areas, D penetration is pretty much zero. And in HFT at least while many features would be nice (especially reflection), I can't imagine it would be anything but a performance hit. Just the fact that the best D implementation for performance is llvm based, and most people do not find that llvm produces assembly as good as gcc or icc, is already an instant global hit.
- WalterBright 7y agoD reflection is at compile time, not runtime, so no performance hit.
- newacct77 7y agoThe garbage collector in D can be disabled, so what exactly is your point? Or are you just spouting out bullshit?
- dang 7y agoPlease don't be rude or aggressive in HN comments. It only makes this place worse, and we're trying to have a forum that doesn't go down in flames. https://news.ycombinator.com/item?id=20340078 https://news.ycombinator.com/item?id=20340078 was much better. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- umanwizard 7y agoI’ve seen large, poorly written Java programs[0] where an entire core at 100% is dedicated to the GC. I have never seen that behavior for things like ~shared_ptr in C++ or similar languages. Then again, OOMing due to leaks is something you’re more likely to see in poorly-written systems in non-GC languages (Objective-C, C, C++, etc), so there are certainly trade offs. [0]: Maybe “poorly written” is unfair. Perhaps “written by people who are unaware of how to write code that performs well in a GC system”.
- krzat 7y agoProbably the most important usage of C are shared libraries. How well it will work if I have D library with it's own GC, another Go library with second GC and app written in C# with yet another GC?
- jcelerier 7y ago> Garbage Collection is often faster than RC as long as pause times are acceptable I have never in my life worked in any kind of software where this was remotely acceptable
- rowanG077 7y agoYou are right most software it doesn't matter if you have a GC. However then D is not competing against C and C++ it's competing against almost every other language.
- newacct77 7y agoD's garbage collector can be disabled, so would you mind elaborating?
- CameronNemo 7y agoHow well is that supported by the ecosystem?
- rowanG077 7y agoYes and then you can't use most of the nice features of D. Forget about libraries.
- nicwilson 7y agoMere presence shouldn't. If you never allocate from it (which is able to be verified very easily with the @nogc attribute), it will never trigger. You can disable it and trigger when you feel it is needed. You can choose to just leak. The default GC is OK, but not great. However it recently was made multithreaded in the mark phase so it is much faster than it used to be. There is a fork based (on linux only IIRC) GC, used by several companies for hard realtime systems, that marks and sweeps in a separate process with CoW pages.
- WalterBright 7y agoThe -betterC switch to the compiler compiles a D subset that doesn't have a GC.
- edwintorok 7y agoWhat makes you choose it over Rust or Go?
- 6thaccount2 7y agoNot OP, but I can guess. D has a built-in GC by default and doesn't force you to manage memory like Rust. Also, the author mentioned that D is pretty straightforward to anyone with some basic programming knowledge (think C, C++, Java, and C# which fits the majority of coders). Rust is very different from those languages. My main goto language is Python and I can understand D a lot more than Rust which confuses me to no end (disclaimer: I'm a total noob). Go is probably as easy to read as D if not more and is also GC and fast. It is also very spartan. I bet D has a lot of additional features.
- petre 7y agoWith Rust I always find myself fighting the compiler just like with C, it's very strict about everything, no GC, steep learning curve. Go is okay but you can't get clever with it. You're productive from the start butit becomes routine quite fast and at a certain point there isn't anything new to learn. Error checking is also quite annoying. D has the best of both worlds and it also plays nicely with C/C++, something that the author of Zig also understood is a must have in any language that aims to be a better C/C++. In D one is productive from the start and there's always something new to learn. And one learns it as they code, without having to first read Programming in D by Ali Çehreli to make any sense of the language. I also tried Crystal and liked it but one is more productive in D and Go without any prior knowledge of those languages. I was kind of annoyed by the fact that Crystal removed the for loop, which works perfectly fine in Ruby.
- edwintorok 7y agoYou can opt-in to a Gc with Rust via Rc<> and Arc<>: https://words.steveklabnik.com/borrow-checking-escape-analysis-and-the-generational-hypothesis https://words.steveklabnik.com/borrow-checking-escape-analys... Don't get me wrong, I like a language with a Gc by default, my favourite language is OCaml, but I can't claim it to be a drop-in replacement for C projects. Go, Rust (or D) stand a better chance at that.