digitalmars.D.learn - Some impressions/notes from a new D programmer
- mark (70/70) Feb 12 2020 I've been learning D for a few weeks now.
- Dennis (11/20) Feb 12 2020 Can you elaborate a bit on this?
- mark (10/32) Feb 12 2020 Maybe I'm just used to the Python docs, but I find them a lot
- Anonymouse (7/11) Feb 12 2020 There is 'dub run someapp', which is good enough for some cases,
- user1234 (4/9) Feb 12 2020 It could just create some shortcuts in ~/bin. AFAIK this special
- Adam D. Ruppe (8/10) Feb 12 2020 Have you seen my fork?
- mark (14/25) Feb 12 2020 Yours is *much* clearer.
- Adam D. Ruppe (6/11) Feb 12 2020 The search is in the upper right.... unless you resize the
- mark (7/18) Feb 12 2020 Please mention when you've fixed the search on this list since
- Adam D. Ruppe (10/13) Feb 12 2020 ooooh it isn't a bug i just forgot to update the file! that
- Steven Schveighoffer (7/8) Feb 12 2020 FYI, dlang.org has a secondary version of the docs which splits the
- Sebastiaan Koppe (7/16) Feb 12 2020 There is also devdocs.io
- bachmeier (19/27) Feb 12 2020 It's a bug if something isn't properly documented, whatever the
- Jan =?UTF-8?B?SMO2bmln?= (2/4) Feb 12 2020 I made exactly the same experience in December.
I've been learning D for a few weeks now. I'm an experienced programmer in other languages (esp. Python, but also Rust and C++). Here're some *early* impressions and notes. D Tour I found the D Tour, esp. "D's Basics" to be very helpful. Each part is short and in most cases understandable. Being able to run and edit the code is a real help for learning. D Playground The D playground https://run.dlang.io/ is very useful for trying out snippets and generally learning, so I use it a lot. (I still haven't worked out how to save a URL to my code though.) Library Reference Documentation The Library Reference documentation seems to be a mixed bag. Often I've found a good overview at the start, but then few or no examples in the docs for classes and methods (see e.g., https://dlang.org/phobos/std_zip.html#.ZipArchive). I don't find the presentation of the member properties and methods very easy to read, but the worst aspect is the lack of examples. Standard Library The library itself "feels" a bit incomplete, which is surprising given how long D's been around. To give just two examples: The lack of set and B-tree types is disappointing (esp. considering that the much younger Rust has them). I'm using rbtree for sets but that imposes a requirement that my items support < (rather than the == or hash I'd expect for a set). The fact that the return value of std.file.getAttributes() means completely different things on POSIX and Windows. That's fair enough, but there ought to be a platform-neutral equivalent for those writing cross-platform applications that returned, say, a struct or tuple with the common subset of attributes normalised. (And if there is such a function, why isn't it cross-referenced.) There seems to be a curious mixture of functions which are POSIX- or Windows-specific and those which are platform neutral. The D Language The D language seems to be a "kitchen sink" (i.e., has everything) like C++, Rust, (and nowadays, Python). This makes it big and a *lot* to learn. However, I managed to create a little library that used template types (with some help from this forum), and I _understand_ the templates. This is a huge improvement over C++ or Rust. And to my surprise, so far my D programs have about the same line counts as the Python versions. Also, I've found building much easier than C++. However, dub doesn't seem to be competitive with Rust's cargo. Getting fast statically built (no dependency) executables is really nice. GUI Programming I've tried a number of D GUI libraries, and all bar one have been problematic. To my surprise GtkD was easy to install on both Linux and Windows and getting "hello world" to build and run was fairly easy. The documentation doesn't seem that easy to use, but I'll start with Ron Tarrant's https://gtkdcoding.com/ and see how I get on from there. D Books I find Ali Çehreli's book (http://ddili.org/ders/d.en/index.html) more suited to complete beginners, but I am skim reading it and finding it useful here and there. The main books I'm reading are Mike Parker's Learning D and Adam Ruppe's D Cookbook, both of which I think are pretty good. (However, I hope both will produce more up-to-date and improved second editions with a better publisher.) Learn D Forum People on this forum have always provided polite and helpful answers. This is a very important intangible benefit of the language. Conclusion My hope was that D would offer a sweet spot between Python's ease and speed of development and Rust's performance. And so far this looks like being the case.
Feb 12 2020
Thanks for your perspective. Just a few things are unclear to me: On Wednesday, 12 February 2020 at 10:39:06 UTC, mark wrote:I don't find the presentation of the member properties and methods very easy to readCan you elaborate a bit on this?The lack of set and B-tree types is disappointing (esp. considering that the much younger Rust has them). I'm using rbtree for sets but that imposes a requirement that my items support < (rather than the == or hash I'd expect for a set).This confuses me. So there is std.container.rbtree, but you don't like that the element type needs to have an order defined? How can Rust do binary search in a tree that has no order? If you are looking for a hashset, you can use an associative array for that.However, dub doesn't seem to be competitive with Rust's cargo. Getting fast statically built (no dependency) executables is really nice.I've heard good things about cargo, but haven't used it myself yet. Do you have a specific thing dub can improve the most on?
Feb 12 2020
On Wednesday, 12 February 2020 at 11:46:02 UTC, Dennis wrote:Thanks for your perspective. Just a few things are unclear to me: On Wednesday, 12 February 2020 at 10:39:06 UTC, mark wrote:Maybe I'm just used to the Python docs, but I find them a lot easier to read.I don't find the presentation of the member properties and methods very easy to readCan you elaborate a bit on this?Naturally a tree needs <. But I want a set and since D doesn't have one I can either use an AA or an rbtree and I was advised that an rbtree is better for this purpose.The lack of set and B-tree types is disappointing (esp. considering that the much younger Rust has them). I'm using rbtree for sets but that imposes a requirement that my items support < (rather than the == or hash I'd expect for a set).This confuses me. So there is std.container.rbtree, but you don't like that the element type needs to have an order defined? How can Rust do binary search in a tree that has no order? If you are looking for a hashset, you can use an associative array for that.Some cargo packages are applications. If I do 'cargo install someapp' it will be installed in $HOME/.cargo/bin. So by simply adding that to my PATH, I can easily use all installed rust apps. But dub doesn't appear to have an equivalent of this.However, dub doesn't seem to be competitive with Rust's cargo. Getting fast statically built (no dependency) executables is really nice.I've heard good things about cargo, but haven't used it myself yet. Do you have a specific thing dub can improve the most on?
Feb 12 2020
On Wednesday, 12 February 2020 at 13:36:13 UTC, mark wrote:Some cargo packages are applications. If I do 'cargo install someapp' it will be installed in $HOME/.cargo/bin. So by simply adding that to my PATH, I can easily use all installed rust apps. But dub doesn't appear to have an equivalent of this.There is 'dub run someapp', which is good enough for some cases, like digger[1]. But no 'dub install someapp', no. Maybe there are some hard design decisions again $HOME/.dub/bin, unsure. It might be difficult to globally pull off if programs expect the binary to be placed in the source tree (for resources). [1]: https://github.com/CyberShadow/Digger
Feb 12 2020
On Wednesday, 12 February 2020 at 15:28:57 UTC, Anonymouse wrote:Maybe there are some hard design decisions again $HOME/.dub/bin, unsure. It might be difficult to globally pull off if programs expect the binary to be placed in the source tree (for resources). [1]: https://github.com/CyberShadow/DiggerIt could just create some shortcuts in ~/bin. AFAIK this special folder got automatically added to the $PATH in RH and deb distributions. The less obvious solution is for Windows systems.
Feb 12 2020
On Wednesday, 12 February 2020 at 10:39:06 UTC, mark wrote:Library Reference DocumentationHave you seen my fork? http://dpldocs.info/experimental-docs/std.zip.ZipArchive.html for exampleThe documentation doesn't seem that easy to useI generated docs for this too http://gtk-d.dpldocs.info/gtk.AboutDialog.AboutDialog.html though since it is generated from C source ultimately the samples there are still C! But you can navigate members somewhat well.
Feb 12 2020
On Wednesday, 12 February 2020 at 14:15:40 UTC, Adam D. Ruppe wrote:On Wednesday, 12 February 2020 at 10:39:06 UTC, mark wrote:Yours is *much* clearer. However, if you compare: http://dpldocs.info/experimental-docs/std.zip.html vs https://dlang.org/phobos/std_zip.html Yours rolls the two examples into one and doesn't show the Standards or Usage sections. But the official page doesn't have the Bugs section. I also think you split into more HTML files which I prefer. OTOH yours doesn't have the search box. Given how new I am to D, I really need to be able to search.Library Reference DocumentationHave you seen my fork? http://dpldocs.info/experimental-docs/std.zip.ZipArchive.htmlfor exampleI hadn't seen this and it does looks easier to navigate. I've bookmarked it. Thanks.The documentation doesn't seem that easy to useI generated docs for this too http://gtk-d.dpldocs.info/gtk.AboutDialog.AboutDialog.html though since it is generated from C source ultimately the samples there are still C! But you can navigate members somewhat well.
Feb 12 2020
On Wednesday, 12 February 2020 at 15:52:35 UTC, mark wrote:Yours rolls the two examples into one and doesn't show the Standards or Usage sections.Weird, that's a legit bug in there. I'll fix them.I also think you split into more HTML files which I prefer. OTOH yours doesn't have the search box. Given how new I am to D, I really need to be able to search.The search is in the upper right.... unless you resize the window, then it disappears. lol another bug, how did I not notice that before? well I'll fix those in a little bit.
Feb 12 2020
On Wednesday, 12 February 2020 at 18:20:47 UTC, Adam D. Ruppe wrote:On Wednesday, 12 February 2020 at 15:52:35 UTC, mark wrote:Please mention when you've fixed the search on this list since then I can switch to using your version of the docs. In my browser I can only see your search box if I expand the window to full screen which is wider than I need (I have a 1920x1200 monitor, so only have the browser window 1200x1100.)Yours rolls the two examples into one and doesn't show the Standards or Usage sections.Weird, that's a legit bug in there. I'll fix them.I also think you split into more HTML files which I prefer. OTOH yours doesn't have the search box. Given how new I am to D, I really need to be able to search.The search is in the upper right.... unless you resize the window, then it disappears. lol another bug, how did I not notice that before? well I'll fix those in a little bit.
Feb 12 2020
On Wednesday, 12 February 2020 at 18:20:47 UTC, Adam D. Ruppe wrote:Weird, that's a legit bug in there. I'll fix them.ooooh it isn't a bug i just forgot to update the file! that version i had was over a year old. so that's fixedThe search is in the upper right.... unless you resize the window, then it disappears.so what happened here is it wraps to the next line if the window is too small. i fixed it basically, i don't love it (need to use flexbox instead of this old float crap, i wrote most this css years ago) but eh you should be able to see the search box consistently now at least.
Feb 12 2020
On 2/12/20 10:52 AM, mark wrote:I also think you split into more HTML files which I prefer.FYI, dlang.org has a secondary version of the docs which splits the documents up more: https://dlang.org/library/index.html I can't find a link to it directly from the main page though... This version is based on ddox (http://code.dlang.org/packages/ddox) -Steve
Feb 12 2020
On Wednesday, 12 February 2020 at 18:39:36 UTC, Steven Schveighoffer wrote:On 2/12/20 10:52 AM, mark wrote:There is also devdocs.io It has many languages and frameworks. The beauty is that it caches in local storage so searches are super fast and it is also available offline. Their d version lags a tiny bit, but that is fine.I also think you split into more HTML files which I prefer.FYI, dlang.org has a secondary version of the docs which splits the documents up more: https://dlang.org/library/index.html I can't find a link to it directly from the main page though... This version is based on ddox (http://code.dlang.org/packages/ddox) -Steve
Feb 12 2020
On Wednesday, 12 February 2020 at 10:39:06 UTC, mark wrote:Library Reference Documentation The Library Reference documentation seems to be a mixed bag. Often I've found a good overview at the start, but then few or no examples in the docs for classes and methods (see e.g., https://dlang.org/phobos/std_zip.html#.ZipArchive). I don't find the presentation of the member properties and methods very easy to read, but the worst aspect is the lack of examples.It's a bug if something isn't properly documented, whatever the flaw may be. It's gotten a lot better in the time that I've been using D, but there are still a few rough spots. My strategy has been to ask for an example in the forum. I then click "Improve this page" in the upper right corner and it's a simple process to create a PR with the example added. Most of the documentation PRs I've created have been merged within a fwe hours. If you don't want to do that, you can create an issue in Bugzilla, with a detailed explanation of what you were doing and what the documentation should show instead. It would be nice for this to already be done, and while it's generally good by the standards of programming languages, there are still some weak spots. Anyone can help fix them. In some cases when I've reported missing documentation, there actually *was* documentation but it wasn't getting added to the website for some reason. Nobody will know until it's pointed out. And nobody's going to shout at you for filing too many documentation bugs or creating too many PRs to fix documentation bugs.
Feb 12 2020
On Wednesday, 12 February 2020 at 10:39:06 UTC, mark wrote:I've been learning D for a few weeks now. ...I made exactly the same experience in December.
Feb 12 2020