6 ms·
I hear so many great things about D, but I haven't started coding in it yet. A friend of mine has gotten in there, coding up his new trading platform in it. Als
by lordnacho 8y ago
I hear so many great things about D, but I haven't started coding in it yet. A friend of mine has gotten in there, coding up his new trading platform in it. Also virtually all his social media posts are about D, so he's keen.
Suppose I am a c++ guy who does a lot of time sensitive code. Who else has made the leap, and what were your impressions? How often do you turn up nothing on stackoverflow? How often do you find there's no lib where you'd expect to have a few in c++?
- rufius 8y agoThis is sort of a sideways answer... I wrote some D code for a bit and I enjoyed it. The FFI story is solid and that made interop nice. That said, GC may be a concern for timing sensitive code. That said, since Rust hit 1.0 and the language got cleaned up, I’ve stopped writing D at all. Not plugging Rust, just the facts. Better language for my space.
- VHRanger 8y agoYou can link to c++ code in D (you do need to declare function signatures on the D side, etc.) but overall c++ compatibility is good, so it's less of a problem than you'd expect
- lordnacho 8y agoYeah but then I need a compelling reason to glue those things together in a new language?
- johannes1234321 8y agoThe reason is that you are more comfortable or efficient in the new language, but want to access legacy. Having to recreate everything for scratch is a massive effort, however gradually refactoring an application and having access to huge amounts of third-party libs is an enabler. (while all those libs will use non-idiomatic patterns, so it has to be contained)
- WalterBright 8y agoIf you want checkable memory safety, for example.
- mhh__ 8y agoTime sensitive code can be written fully in D. Avoiding the GC is trivial, if you have sensible expectations: The Standard Library (phobos) largely requires it, although it should be said that the D garbage collector currently only runs when (say) explicitly called to allocate memory so it's not as pervasive as Java's (say). Calling C++ directly is very much an option, although interlingual exception handling is a WIP.
- dfox 8y agoGCs that run somehow in background and are not primarily trigerred by allocation are quite rare, IIRC all GCs shipped with LVM are also only triggered by allocation. In fact only two production cases of primarily background GCs that I can think of at the moment are some Lisp Machines (IIRC LMI) with HW assisted incremental copying GC and Azul's GC, which uses quite similar approach.
- dbaupp 8y agoJava also doesn't run collection unless there's interaction with the GC. This is why people put a lot of effort into avoiding allocation in inner loops via primitives and object pools, because doing so ensures that the GC won't cause problems.
- qznc 8y agoThere is this guy who does VST plugins in D and sells them: https://www.auburnsounds.com/blog/2016-02-08_Making-a-Windows-VST-plugin-with-D.html https://www.auburnsounds.com/blog/2016-02-08_Making-a-Window... "This is a touchy topic that already has filled entire blog posts. Virtually everyone in real-time audio is using C++ and it's probably still the sanest choice to make. [...] I worked with both languages for years and felt qualified enough for the inevitable bullet point comparison. The most enabling thing is the D ecosystem and package management through DUB, which makes messing with dependencies basically a solved problem. Development seems to "flow" way more, and I tend to like the end result better in a way that is undoubtedly personal."
- specialist 8y ago"...makes messing with dependencies basically a solved problem." Huh. Now I'm interested. One constant in my professional (and hobby) careers has been "DLL Hell". I'd pretty much do anything to be hassle free. Thanks for the tip.
- p0nce 8y agoOn that point. In the D world there is a habit to use "derelict" bindings which are dynamic loaders for dynlibs. This has the advantage of supporting multiple dynlib versions, and also does not complicate the build with a linking option... If you are making anything cross-platform it is a boon.
- ByThyGrace 8y agoCan you please expand on that? Are there examples to look at of derelict bindings?
- p0nce 8y agoFor example you want to depend on SDL. You add the "derelict-sdl2" package to your DUB dependency list. DUB will download and build that "derelict-sdl2" library. This is a small library that will load functions pointers in the SDL2 dynlib (aka dynamic loading). You'll still have to distribute your cross-platform app with SDL2, however there is no linker option, the linker doesn't need to know about an import library. Voila, same build for all platforms. Conversely in C and C++ you would probably only have static bindings as a choice, and it can be a pain for cross-platform builds. On Linux, it has to be packaged. On Windows, you must find the right .lib. There can be considerable list of libraries in linker settings, essentially because there is no package manager that makes dependencies something _composable_: dependencies would then leak on linker settings across the chain. C++ forums are full of people failing to build, that's not the case with D. Documentation: http://derelictorg.github.io/loading/loader/ http://derelictorg.github.io/loading/loader/
- krylon 8y agoFWIW, I only played around with D briefly (I was not unhappy with D, but I prefer Go for its simplicity), but the community on the D Forums[0] is awesome - very welcoming to newbies and very helpful, too. [0] https://forum.dlang.org/ https://forum.dlang.org/
- bachmeier 8y ago> How often do you turn up nothing on stackoverflow? D's forum/mailing list was established well before SO was a thing, so the answer is "pretty often", but with the addition "you don't need SO because you can talk directly to the D developers". I've not seen another major language where the core developers, and even creators of the language, were so available. https://forum.dlang.org/ https://forum.dlang.org/ Doesn't even require registration.
- p0nce 8y agoBe aware this may ruin you as a C++ programmer, since you'll hardly want to use C++ after. That is pretty common.
- annywhey 8y agoI've evaluated D for games. It's good in terms of giving you a palette of data modelling options from "I don't care yet" to "I need to track every byte", and having the support of multiple compiler implementations gives it a trustworthy "not going to disappear" feeling. You really don't have to lean on the GC given all the other options for memory management, but it is the canonical default and is likely to stay that way unless everyone keeps piling on the -betterC train. However - it's another big language with a lot of accumulated history to it and a lot of stuff that isn't immediately needed in the day-to-day. That makes it intimidating to learn and more geared towards "megacorp" codebases when I really want something small and suitable for hobby/education projects that go near the metal. So I've also searched for a dedicated "better C" which led me to Zig. It's still in its early stages so it doesn't face the tightrope act of D development. And the language is uncomplicated, polishing up pretty much every wart and major source of error that's in C(even manual memory stuff - not by eliminating the footguns, but by making safe usage idioms easy), while playing really well with existing C code.