February 19, 2017
On Saturday, 18 February 2017 at 21:09:20 UTC, ag0aep6g wrote:
>> 5. Supposing I devote the time and energy and get up to speed on D, would the core language team be welcoming if I feel like I can contribute?
>
> Absolutely. Anyone is welcome to contribute. D is very much a volunteer effort. Also don't hesitate to point out (or even fix) any stumbling blocks you may encounter when starting out.

I can't add more to this than two pointers:

https://wiki.dlang.org/Starting_as_a_Contributor
https://wiki.dlang.org/Get_involved
February 19, 2017
On Saturday, 18 February 2017 at 22:17:30 UTC, berni wrote:
> I'm new here too (never heard of D before 2017).

Glad to meet someone else new here! :-)

>> c). The whole community seems infused with both the Feminism/SJW
>
> I didn't tried out Rust, but that would draw me away too. (Incidentally it was a comment on alternatives for Rust, that pointed me to D.)

Absolutely! At first it didn't bother me so much, but when I started hanging out of the Rust user groups, I saw the evil side of this. People who raised this issues were being castigated and publicly ridiculed. That was too much even for me (I'm usually the "live and let live" kind of person) because it showed that the community over there appeared more interested in such side issues than focusing on building up a community based on technical sharing and solving technical problems. Very offputting.

>> 2. I am also curious as to what would be the best path for a complete beginner to D to learn it effectively?
>
> I started with the online version of the book of Ali Çehreli but after a while I decided to buy it and was impressed on its size (more than 700 pages!). Meanwhile I'm halfway through.

Hehe. I'm also doing the same... a few chapters in and it's smooth sailing so far!

> At the same time I'm working on a project of mine, which I just started writing in C++ last december, because I couldn't find a better language and thought I had to bite the bullet. Meanwhile it's completely rewritten in D (but two lines of C code that I need to use a C-libraray). Whenever I came across a new concept in the book I tried to refactor that project using this concept.

Very nice! :-)

> This approach worked very well for me. (And I appreciate this Learn-forum, because else I'd not dare to ask my seemingly silly questions.)
>
> You wrote:
>> ... area thoroughly!The introspection ...
>
> I just realised, how much I'm thinking in D allready when I saw this: At first glance I wondered, what this thoroughly-template is about... ;-)

Hahaha!
February 19, 2017
On Saturday, 18 February 2017 at 21:51:34 UTC, Daniel Kozak wrote:
> Dne 18.2.2017 v 21:15 timmyjose via Digitalmars-d-learn napsal(a):
>
>> [...]
> Hi, welcome in D community

Thank you! I'm glad to be part of this excellent community!

>>[...]
>
> Yes, by default D use GC. And yes there is a some part of D standard library which uses GC. But it is something you can avoid if you want. I am using D for many years and for almost anything and never have issue with GC.
>
>> [...]
>
> D stability is good, really good, for many of us too good :P. I have been using D for many years (five or six). And right now there is a big effort to never break anything until it makes really sense.

That makes sense.

> OTOH D development is quite fast. So there are many improvements with every release

That sounds very good indeed!

>> [...]
> I can't help here because I am using D for a long time, so I do not remember how I have learned it.

Hahaha! Yes, thanks for the honesty. It does make sense because once you've been working in some field for some time, it does make it harder to explain how exactly you reached that level. In that regard, comments from fellow newbies (such as berni) have been quite helpful since they're at the same stage as me.

>> [...]
>
> It is maybe not small-scale but idiomatic D code is in phobos itself.

Interesting! I checked out the link that ag0aep6g had shared, and I realised that Phobos is the name of the standard library itself. It should make for some interesting reading once I get the basics down.

>> [...]
> I do not know Lisp macros, but AFAIK there are not semantically similar. OTOH D metaprogramming is really powerful and there has been some proposals to improve that https://wiki.dlang.org/DIP50

Indeed. I'm very much looking forward to learning this powerful template system very well!

>> [...]

February 19, 2017
On Saturday, 18 February 2017 at 21:58:15 UTC, ketmar wrote:
> timmyjose wrote:
>> Thanks for the very comprehensive response! I think most of my doubts are cleared now. You're right though that I'm probably worrying too much about GC with my current use case.
>
> i can tell you that i'm doing things like, for example, ZX Spectrum emulator and hobbyst videogames (everything in D, even low-level gfx), i never really cared about "avoiding GC", and i can maintain solid 35/50/60 FPS (depending of my needs) with my code.
> i.e. that "GC-phobia" (i'm not talking about you specifiallly, of course, sorry) is mostly based on nothing. as GC will never fire "on it's own", and you can control it, avoiding GC is not unnecessary (except some very special cases, of course ;-). the key tech here (as usual) is to not allocate in tight loops, plan your memory discipline and such. nothing new for people used to systems languages. ;-)

No, you're quite right indeed! First of all, those sound like very interesting project! :-), and you're right about the GC part. I have some experience in systems programming in C++ and also application development in Java. Java's GC never really bothered me so much, but it's quite intriguing that you (and one more person before) mention that the GC does not fire on its own. So a couple of questions here (might be a bit premature, but I'm interested!):

a). So the GC is part of the runtime even if we specify @nogc

b). Do we manually trigger the GC (like Java's System.gc(), even though that's not guaranteed), or does it get triggered automatically when we invoke some operations on heap allocated data and/or when the data go out of scope?

c). Does Rust have analogues of "new" and "delete", or does it use something like smart pointers by default?

> sure, you can stop worrying about that and use D as some kind of scripting language too, and still have all the features like type checking. for things like IRC or email client i absolutely don't care about allocations (i.e. doing it left and right) and just letting GC to do it's work. my usual IRC client uptime is several monthes (after that it runs out of memory, but this is 'cause it never does any cleanup on it's data, keeping all logs and db in memory. i am too lazy to finish it. note that is it not a GC fault, it is my code. ;-).

I could not agree more about the type checking bit. It's bitten my backside more than I care to remember (even though LLVM and Clang do produce better warnings than gcc IMO), and so a stronger type checker is always welcome! :-)

Fascinating reading about the various use cases that you and others have put D to. It does give me a lot more contextual understanding now. Thank you!
February 19, 2017
On Sunday, 19 February 2017 at 11:51:02 UTC, timmyjose wrote:
> On Saturday, 18 February 2017 at 21:58:15 UTC, ketmar wrote:
>> [...]
>
> No, you're quite right indeed! First of all, those sound like very interesting project! :-), and you're right about the GC part. I have some experience in systems programming in C++ and also application development in Java. Java's GC never really bothered me so much, but it's quite intriguing that you (and one more person before) mention that the GC does not fire on its own. So a couple of questions here (might be a bit premature, but I'm interested!):
>
> [...]

Oops! I meant D, of course. Sorry, still recovering from that drug. Heh!

>> [...]
>
> [...]

February 19, 2017
On 02/19/2017 12:51 PM, timmyjose wrote:
> a). So the GC is part of the runtime even if we specify @nogc

Yup. @nogc is per function, not per program. Other functions are allowed to use the GC.

> b). Do we manually trigger the GC (like Java's System.gc(), even though
> that's not guaranteed), or does it get triggered automatically when we
> invoke some operations on heap allocated data and/or when the data go
> out of scope?

You can trigger a collection manually with GC.collect [1]. Otherwise, the GC can do a collection when you make a GC-managed allocation. If you don't make GC allocations, e.g. because you're in @nogc code and the compiler doesn't allow you to, then no GC collections will happen.

> c). Does Rust have analogues of "new" and "delete", or does it use
> something like smart pointers by default?

D, not Rust, right?

D uses `new` for GC allocations. `new` returns a raw pointer or a dynamic array (pointer bundled with length for bounds checking).

There is `delete`, but it's shunned/unfashionable. Maybe it's going to be deprecated, I don't know. You're supposed to let the GC manage deletion, or use `destroy` [2] and GC.free [3] if you have to do it manually.

Of course, you can also call C functions like `malloc` and `free` and do manual memory management.

Regarding smart pointers, I'm not up to speed. There's std.typecons.Unique [4], but I don't know how it compares to other languages.


[1] https://dlang.org/phobos/core_memory.html#.GC.collect
[2] https://dlang.org/phobos/object.html#.destroy
[3] https://dlang.org/phobos/core_memory.html#.GC.free
February 19, 2017
On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote:
> My rudimentary knowledge of the D ecosystem tells me that there is a GC in D, but that can be turned off. Is this correct? Also, some threads online mention that if we do turn off GC, some of the core std libraries may not fully work. Is this presumption also correct?

The topic is complex, there are a lot of mitigation techniques.

A - for most real-time programs, you may want to keep the GC heap under 200kb. A combination of GC profiling, using values types, and manual memory management can get you there. @nogc also helps.

B - some real-time threads don't like to be paused (audio). You can unregister them from the runtime which means the GC won't stop them on collection. On the other hand this thread won't be able to "own" collectable things.

C - finally you can either disable the runtime/GC altogether, or not link with it. This create the most effort but with a guarantee of not having a GC over the whole application. In most cases it's _not worth it_.

The hard part about GC is understanding reachability, but unless you are doing very systemy, this can be safely ignored.

You will be just fine.

> Secondly, how stable is the language and how fast is the pace of development on D?

Language doesn't break nowadays, very stable apart from dreaded regressions with the DMD backends.

http://erdani.com/d/downloads.daily.png

> 2. I am also curious as to what would be the best path for a complete beginner to D to learn it effectively?

"Learning D" book seems fitting.

> 3. Are there some small-scale Open Source projects that you would recommend to peruse to get a feel for and learn idiomatic D?

I run https://p0nce.github.io/d-idioms/ to get up to speed with the weird idiosyncrasies fast. But the above book is way better.
February 19, 2017
timmyjose wrote:
> a). So the GC is part of the runtime even if we specify @nogc
yes. GC is basically just a set of functions and some supporting data structures, it is compiled in druntime. @nogc doesn't turn it off, if says that compiler must ensure that *your* *code* doesn't allocate, at compile time. i.e. @nogc code with GC allocations won't compile at all.


> b). Do we manually trigger the GC (like Java's System.gc(), even though that's not guaranteed), or does it get triggered automatically when we invoke some operations on heap allocated data and/or when the data go out of scope?
GC can be invoked *only* on allocation. as long as you don't allocate GC data, GC will not be called. of course, things like array/string concatenation (and closure creation) allocates, so you'd better be careful with your code if you want to avoid GC in some critical part. or you can call `GC.disable()` to completely disable GC (and `GC.enable()` later, of course ;-).


> c). Does Rust have analogues of "new" and "delete", or does it use something like smart pointers by default?
`new`. no `delete`, tho, as it is not necessary with GC. actually, there is `delete` thingy, but it is deprecated, and you'd better not use it unless you are *really* know what you're doing and why. i.e. don't prematurely optimize your code, especially without good understanding of D's GC.


> Fascinating reading about the various use cases that you and others have put D to. It does give me a lot more contextual understanding now. Thank you!
you're welcome.

as for me, i am using D exclusively for *all* my programming tasks (including writing simple shell scripts ;-) for years. and i don't want to go back to C/C++ or switch to some [new] hyped language. i have 20+ years of programming expirience, and i feel that D is the best language i ever used. don't get me wrong, tho: it doesn't mean that D is the best language on the planet. what i mean is that D has a best balance of features, warts, libs and so on *for* *me*. easy C interop allows me to use all the C libraries out there; C-like syntax allows me to port C code (i did alot of C ports, including NanoVG, NanoSVG, Tremor Vorbis decoder, Opus decoder, etc.); great metaprogramming (for C-like language) allows me to skip writing boilerplate code; and so on. ;-)

also, dmd compiler is easily hackable. trying to even compile gcc is a PITA, for example. and dmd+druntime+phobos takes ~1.5 minutes to build on my old i3.
February 19, 2017
timmyjose wrote:
>> I can't help here because I am using D for a long time, so I do not remember how I have learned it.
> Hahaha! Yes, thanks for the honesty. It does make sense because once you've been working in some field for some time, it does make it harder to explain how exactly you reached that level. In that regard, comments from fellow newbies (such as berni) have been quite helpful since they're at the same stage as me.
as for me, i basically just jumped into D and started to code. sure, i read a little about modules, GC, slices, and such basic things, but then i just started to writing my code in D. one can use libc from D (with some care), so it allowed me to write in D as in "C dialect", and then gradually make my code more "D-like", as i learned more and more things.
February 19, 2017
On 2017-02-19 13:45, ketmar wrote:

> nogc doesn't turn it off, if
> says that compiler must ensure that *your* *code* doesn't allocate,

Just to clarify, allocate using the GC. It's perfectly fine to allocate using malloc in a @nogc function.

-- 
/Jacob Carlborg