8 ms·
Programming in D – Tutorial and Reference
- Snackchez 11y agoThis might be a silly question: what is D used for? I "scanned" the site fairly quickly and didn't grasp the general application idea behind it.
- CyberShadow 11y agoD is a general purpose compiled programming language. So, it can be used for almost anywhere e.g. C++ can be used.
- pmalynin 11y agoIts like C++, but "better"
- Ace17 11y agoExactly. D is "C++ done right".
- krylon 11y agoI am usually fairly skeptical of "X is Y done right", but in this case it seems to be true. C++ lovers might debate this, but D does take many lessons to heart that C++ programmers have learned the hard way. I also suspect, that C++ is more of a result of design-by-commitee, whereas D is - to a substantial degree - the brain-child of a single person.
- acehreli 11y ago> I also suspect, that C++ is more of a result of design-by-commitee, whereas D is - to a substantial degree - the brain-child of a single person. That's exactly how I see it. However, "single person" era ended long ago. Since 2007, others (especially Andrei Alexandrescu) had influence in the design of the language.
- luismarques 11y agoI used to use D for larger tasks and Python for quicker ones, like processing some text file and so on. One day I realized that I prefered using D even for those smaller tasks, where quick and dirty solutions would do. One thing that helped was that the standard algorithms (from the std.algorithm module) are really useful and compose very well, once you get to know them, and allow solving those kinds of tasks both quickly and efficiently.
- qznc 11y agoFacebook has made a C-Preprocessor. D is great for such command line tooling. The standard library is not as extensive as Python's, but the situation is much better than in C-land. You can also use it as a scripting language. D has a nice framework for servers (vibed.org), so you can write webservices (REST,JSON,etc). There is no great full-stack web framework like Rails or Django though. GUI stuff works in theory, but I don't know any non-toy project. Games (OpenGL,SDL) are possible, but no serious project, yet. Android/iOS does not really work, yet. Same with embedded, standalone, kernel stuff. ARM in general needs more work. For HPC it really depends on the use case (see dlangscience.github.io). Vector support and GPU integration is lacking. I don't know any image, video, or audio processing stuff in D.
- jibalt 11y agoActually, that C Preprocessor was written by Walter Bright for DMC; just about every file has his copyright notice, and no Facebook copyright notice. I think they just translated it from C++ to D.
- acehreli 11y agoI am the author (of the book). AMA. Ali
- deleted 11y ago[deleted]
- ob 11y agoHe means the author of the book, not the programming language.
- claudiug 11y agoWhy do you choose to write a book about dlang? Can you give us us some godo area when dlang can be used? Can we use dlang to build IOS/Android apps? What is the advances of this language over go, python, java, ruby, rust?
- acehreli 11y agoI've discovered D six years ago after reading Andrei Alexandreuscu's article "The Case for D" in one of ACCU's publications. D was a gasp of fresh air especially for people coming from C++ like myself. I used to frequent C and C++ forums on Turkish web sites and was aware of the need for up-to-date software documentation. I saw D as an opportunity to ensure that for once, Turkish documentation would not be behind the English ones. I started writing HTML pages without any idea that they would become a book later on. Then I've decided to use the tool Prince XML (free for personal use) to see the pages in book form. I made that PDF version available as well. I had never thought that my work would be valuable for an English-speaking audience. Then, Andrei and others convinced me that it would be a good idea to translate the book to English as well. I did that, added many more chapters, edited heavily (mostly by Luís Marques), and it worked! As far as I know, the book is the first software documentation that was translated from Turkish to English, as opposed to the other direction. D is a general purpose language. I don't know the status on the IOS/Android front. gdc, the D compiler using GCC back-end; and ldc, the D compiler using LLVM back-end can produce code for the platforms that those compilers support. However, don't take my word on that. I would expect issues. D is a compiled language that is as low as C (and of course inline assembly) and as high as Python and others. One benefit over Go is the fact that D's template support is the best that I know of. When compared to D's C++'s templates are almost unusable; very clumsy. Ali
- omginternets 11y agoSerious question: are D and Rust trying to be the same thing? I'm not asking whether or not their approaches are different, but whether or not they're trying to solve the same problem(s). I get the sense that this is the case; they're both trying to be a "safe C(++)".
- CyberShadow 11y agoNo, but there is some overlap. Generally speaking, Rust puts safety above anything else. D is more pragmatic, expressive, and generally has better performance (e.g. bounds checking is optional). I think D is a better choice anywhere memory safety and deterministic memory management are not the primary concern.
- pcwalton 11y agoBounds checking is optional in Rust too. And I've never seen bounds checks show up in instruction-level profiling of Rust code, due to the way iterators work. Can you elaborate as to other ways Rust has worse performance?
- CyberShadow 11y ago> Bounds checking is optional in Rust too. Could've sworn I've read somewhere the Rust maintainers stated that Rust will never have a switch to disable bounds checking. Has this changed? > Can you elaborate as to other ways Rust has worse performance? I don't know of any other specifics, but benchmarks usually show D outperform Rust (and often enough, everything else), e.g.: https://togototo.wordpress.com/2013/07/23/benchmarking-level-generation-go-rust-haskell-and-d/ https://togototo.wordpress.com/2013/07/23/benchmarking-level... https://github.com/nsf/pnoise https://github.com/nsf/pnoise
- CyberShadow 11y agoHere is the relevant thread: https://mail.mozilla.org/pipermail/rust-dev/2014-March/009214.html https://mail.mozilla.org/pipermail/rust-dev/2014-March/00921... In some cases, bounds checking doesn't make sense, e.g. in video games running on consoles.
- aikah 11y agowhat is D concurrency model ? does it have channels or classic threads ?
- qznc 11y agoD is not really opinionated about concurrency and parallelism. It provides access to the OS mechanisms (pthreads). The standard library also has some task-based stuff. Then there are fibers (user-level threads), which vibed.org makes convenient to use. There is no definitive channel/queue mechanism provided by the standard library so far, but people have implemented them in libraries. tl;dr: With D you use whatever is best for you.
- cooleng 11y agoWhat's the difference between D and C++? What's the difference between D and C#? What's the difference between D and rust? Who(which project or company) is using D? What's D is mainly designed for? I like the syntax of D instead of rust, because it is much more like c++. The syntax of rust is weird to me.