5 ms·
Logged in today and saw this! Walter here, AMA!
by WalterBright 8y ago
Logged in today and saw this! Walter here, AMA!
- klez 8y agoHey, thanks for the opportunity :) Suppose I was writing systems software. Considering I know neither, why would I invest time learning D instead of C++? Does D offer anything in that regard?
- WalterBright 8y agoD has checkable memory safety. In C++, memory safe code relies on following best practices.
- jcelerier 8y ago-fsanitize=address in C++ is pretty much checked memory safety.
- pjmlp 8y agoIn which page of ISO C++ it is described? And on the C++ compilers that support such language extension, how does it work with binary dependencies?
- jcelerier 8y ago> In which page of ISO C++ it is described? why would it matter ? AFAIK D doesn't even have an ISO standard. > And on the C++ compilers that support such language extension, how does it work with binary dependencies? you at least get whole-program safety for libc calls since it works by replacing such calls through dynamic loading
- pjmlp 8y ago> why would it matter ? AFAIK D doesn't even have an ISO standard. Sure it does. D is defined by the DMD compiler as the reference implementation. Whatever DMD allows for minus implementation bugs, is what the D programming language means. C++ is defined by an ISO standard, a document that specifies what every implementation is required to implement. So any D developer can be sure their code is compliant as long as DMD accepts it, while a C++ developer needs to pay attention how close their favorite compiler is to ISO C++. > you at least get whole-program safety for libc calls since it works by replacing such calls through dynamic loading Libc is a very tiny portion of any industrial grade C++ application, and only relevant in open source systems, as it is shipped in binary form in other platforms.
- repsilat 8y ago> any D developer can be sure their code is compliant as long as DMD accepts it, while a C++ developer needs to pay attention how close their favorite compiler is to ISO C++. That's a cute, but if that's "the letter of the law" then Walter can replace DMD with emacs in the next release and it'd still be a conforming implementation, and you'd just have to rewrite your codebase in lisp to keep it functioning. All the options available to the D programmer in that case (like "keep using the previous version") are also open to C++ programmers when their compiler makes a change that breaks their code. In practice everyone cares about stability. The C++ standard provides a signal that "this behaviour is (not) likely to change in the next release". All other features not mentioned in the standard like compiler flags and implementation details like the stack and the heap are on par with features in D when it comes to compatibility from version to version. The C++ programmer who writes "to the implementation," not "to the standard" is in at least as stable and predictable a situation as the comparable D programmer.
- coldtea 8y ago>That's a cute, but if that's "the letter of the law" then Walter can replace DMD with emacs in the next release and it'd still be a conforming implementation, and you'd just have to rewrite your codebase in lisp to keep it functioning. Which is a contrived argument
- atilaneves 8y ago_If_ your test coverage is good. I've seen it fail to catch a few bugs as well.
- kqr 8y agoI think you two may be talking past each other, one speaking of "safety of checked memory access" and the other of "compile-time checking of memory safety".
- wyldfire 8y agoThis is not the case. Not sure what guarantees D's checked memory provides but ASan doesn't offer protection from uninitialized reads. MSan, does, though. Plus: none of the sanitizers offer quite-the-same runtime protections. They're intended for use in testing to flush out bugs, not production for avoiding bugs. As is, MSan and ASan are mutually exclusive.
- keldaris 8y agoWhat's the plan for Phobos (and more generally the ecosystem) to be usable from the betterC subset of the language? In your opinion, how much of the development focus is aimed in that direction? Are there any parts of the language itself that will be made available to betterC that currently aren't?
- WalterBright 8y agoMost of the effort for BetterC has come from myself. Based on the buzz about it, it's usage is steadily expanding in the D community. The idea of BetterC is to not link to the D runtime library at all. So, the parts of Phobos that are usable from it are the parts that: 1. are "header only", meaning all the functions are templates 2. don't use exceptions or the GC 3. don't use OOP classes (which rely on the GC and the runtime) Not much of effort has been expended cataloging this, though.
- giancarlostoro 8y ago> 3. don't use OOP classes (which rely on the GC and the runtime) I was not aware of this at all, do you ever see a time where you could compile D with classes an all with no garbage collection? I am not bothered by the GC coming from C# and Python but it is interesting to know where D is headed since I know there were many efforts at making D compile without any GC. Basically do you think it will ever make sense for D to just compile without GC by passing a compiler flag? Irrelevant of what D features are used, and maybe it can tell you which features cannot be used without GC (sorry if this already is a feature, I use D I'm not a guru yet).
- WalterBright 8y agoThe compiler flag would be -betterC. You can use classes with no GC if you're willing to allocate and initialize them manually.
- keldaris 8y agoThis begs two questions, it seems to me: 1. Would it make sense to work on (for the community in general, not necessarily you personally) a header only standard library, a sane STL if you will, for betterC? 2. Is there any interest in language support for GC and runtime independent classes/interfaces? I understand this is partly doable already by abusing templates, but I imagine the results aren't necessarily pretty or concise. Regardless, thanks a lot for the responses. I haven't managed to write much D beyond small experiments due to ecosystem and related issues, but the ability to incrementally integrate small parts of D in a C++ codebase as freely as betterC lets me is very tempting.
- mpweiher 8y agoHi! I dimly remember a fairly deep analysis/comparison of C++ and D that went into how opaque or transparent abstractions were to the compiler, and what that means for performance (models) and compile times. I thought it was by you, but can no longer find it. Might you be able to point me at it?
- WalterBright 8y agoI don't recall writing such an article. It sounds intriguing, if you do find it, I'd like to see it.
- mpweiher 8y agoSorry! I’ll keep looking.
- ptrott2017 8y agoMight possibly be Andrei Alexandrescu's The Case for D -also in Dr.Dobbs. See here: http://www.drdobbs.com/parallel/the-case-for-d/217801225?pgno=1 http://www.drdobbs.com/parallel/the-case-for-d/217801225?pgn...
- deleted 8y ago[deleted]
- NonEUCitizen 8y agoAre there plans to add a WASM backend?
- WalterBright 8y agoNo, but anyone is free to contribute to one. It's Boost licensed, after all!
- giancarlostoro 8y agoI have not yet looked but have any in the community tried? In your expert opinion would it make more sense for a WASM backend to be part or the DUB build process or embedded into DMD itself? I think Rust has some approaches that let you build as an addon to Cargo (the Rust equivalent to DUB) so maybe a similar path might make sense? I do know there are efforts to bake WebAssembly into Rusts compiler down the road though.
- pjmlp 8y agoYes, via ldc (the LLVM backend for D). https://github.com/ldc-developers/ldc/issues/2144 https://github.com/ldc-developers/ldc/issues/2144 https://github.com/cosinus2/dlang-emscripten-demo https://github.com/cosinus2/dlang-emscripten-demo
- giancarlostoro 8y agoThanks for the links, I only ever used DMD and GDC (when I had some odd issue with DMD on some distros) but never LDC definitely checking it out. I'm glad there's a Snap package for it, seems to be the cleaner approach to installing dev tools for me.
- tmsldd 8y ago“I've never been comfortable programming in a language I hadn't written a compiler for “ That says everything. Thanks for this ;)
- nspattak 8y agoI have been intrigued to learn D for a long time now but I never had the time to tinker with it before learning other languages that are more widely used. Are there any reasons - in your opinion - which should make one start tinkering with D before spending time with rust or go ?
- codyguy 8y agoWelcome back Walter! Which is your favourite D compiler? Do you ever play around with other compilers too and compare the executables?
- m12k 8y agoWhat is your opinion of Rust? It seems D and Rust can both be seen as saner successors to C++, so I imagine they attract a similar crowd, and maybe compete for mindshare. Any ideas from Rust you wish you'd incorporated in D? Any ideas you think Rust ought to borrow from D?