Re: Vision document for H1 2017

2017-01-12 Thread Mark via Digitalmars-d-announce

On Sunday, 8 January 2017 at 00:15:23 UTC, Seb wrote:

On Saturday, 7 January 2017 at 23:33:45 UTC, Benjiro wrote:
Maybe something to add ( for new users ) is something similar 
to:


http://rustbyexample.com/

Easy to use, lots of information, simple tasks that involve 
interaction for the user, feedback on success.


Do you know about the existing Dlang Tour?

https://tour.dlang.org

PRs/Issues to improve it are welcome

Its translation into a couple of languages is WIP:

https://github.com/dlang-tour


I think the "D for C++ programmers" page could use a revamp:

https://dlang.org/cpptod.html

At the moment it mainly explains where and how D differs from 
C++. Whoever reads it may be ready to write C++ code in D, but 
this seems pointless and may give the impression that D is just 
C++ with a different syntax plus a few minor features (strong 
typedef and the scope statement). The page doesn't mention D's 
dynamic arrays, associative arrays, ranges, UFCS, function 
attributes and so on). The tour does mention these features 
(under "D's gems") so maybe some of its contents can be used to 
extend the "D for C++" page.


One idea on my mind is providing various (honest, not 
specifically tailored) examples of C++ code that aims to solve a 
certain problem, and how the same problem can be solved in D in a 
better way (in some sense). I've seen this done effectively with 
Java vs. Scala.


Re: Alexa Skill written in D

2017-01-12 Thread Chris via Digitalmars-d-announce
On Wednesday, 11 January 2017 at 19:26:06 UTC, Walter Bright 
wrote:

On 1/11/2017 2:09 AM, Chris wrote:

On Sunday, 8 January 2017 at 22:54:58 UTC, Walter Bright wrote:

Yes. I can't because anything I post gets autobanned.

Why is that?


Probably because I posted links to articles I wrote myself. I 
didn't know at the time it was against their rules.


In that case it might help to talk to them and explain that you 
weren't aware of that rule at the time. It will also clear your 
name in case anyone wants to attack you personally ("Walter 
Bright how got banned from ...").


Re: Vision document for H1 2017

2017-01-12 Thread Nick Treleaven via Digitalmars-d-announce

On Thursday, 12 January 2017 at 09:54:08 UTC, Mark wrote:

I think the "D for C++ programmers" page could use a revamp:

https://dlang.org/cpptod.html

At the moment it mainly explains where and how D differs from 
C++. Whoever reads it may be ready to write C++ code in D, but 
this seems pointless and may give the impression that D is just 
C++ with a different syntax plus a few minor features (strong 
typedef and the scope statement). The page doesn't mention D's 
dynamic arrays, associative arrays, ranges, UFCS, function 
attributes and so on).


It's intended to help C++ programmers switch to D, not as a 
comparison. It also links to:


https://dlang.org/ctod.html

which does mention arrays and various other small things.

(I noticed some minor things to fix and submitted a pull request).

One idea on my mind is providing various (honest, not 
specifically tailored) examples of C++ code that aims to solve 
a certain problem, and how the same problem can be solved in D 
in a better way (in some sense). I've seen this done 
effectively with Java vs. Scala.


Sounds good. I think this thread is for big issues that need core 
focus though, anyone here can and should submit documentation.


Re: Vision document for H1 2017

2017-01-12 Thread Guillaume Chatelet via Digitalmars-d-announce
On Saturday, 7 January 2017 at 15:58:43 UTC, Andrei Alexandrescu 
wrote:

On 01/04/2017 08:06 PM, Dibyendu Majumdar wrote:

C++ integration has disappeared? Is this now "done"?


We have a student on that. I've added a line for that to the 
doc. -- Andrei


I did a lot of work on C++ name mangling for D so feel free to 
introduce me to the student. I can probably save her/him a lot of 
time.


After *many* attempts it seems the only way to get this right is 
to look at how clang does it and replicate the logic (starting 
point 
https://github.com/llvm-mirror/clang/blob/google/stable/include/clang/AST/Mangle.h)


The state of my research on mangling so far are summed up here
https://github.com/gchatelet/gcc_cpp_mangling_documentation

I also have a bunch of failed experiments branches:
- https://github.com/gchatelet/dmd/tree/new_cpp_mangle
- https://github.com/gchatelet/dmd/tree/new_cpp_mangle2
- https://github.com/gchatelet/dmd/tree/new_cpp_mangling2
- https://github.com/gchatelet/dmd/tree/more_mangling_tests

Unfortunately I couldn't spend more time on this :(


Re: Vision document for H1 2017

2017-01-12 Thread Andrew Browne via Digitalmars-d-announce
On Wednesday, 4 January 2017 at 19:22:33 UTC, Andrei Alexandrescu 
wrote:
We release a brief Vision document summarizing the main goals 
we plan to pursue in the coming six months. This half we are 
focusing on three things: safety, lifetime management, and 
static introspection.


https://wiki.dlang.org/Vision/2017H1


Andrei


Is there a design document for how D will achieve safety with 
nogc?
How does D plan to prevent leaks, use-after-free, double-free 
bugs when not using the GC?


Will @nogc also have first class support in the language?
Afaik the GC is currently needed for language features like array 
concatenation. Will features like array concatentation still work 
with @nogc?
GC allocations have a keyword 'new' (afaik 'new' currently never 
means anything other than GC allocation). Will we be able to do 
@nogc allocations by the 'new' keyword?


Is the same code always expected to work with/without @nogc?


Re: Vision document for H1 2017

2017-01-12 Thread Jonathan M Davis via Digitalmars-d-announce
On Thursday, January 12, 2017 21:57:37 Andrew Browne via Digitalmars-d-
announce wrote:
> On Wednesday, 4 January 2017 at 19:22:33 UTC, Andrei Alexandrescu
>
> wrote:
> > We release a brief Vision document summarizing the main goals
> > we plan to pursue in the coming six months. This half we are
> > focusing on three things: safety, lifetime management, and
> > static introspection.
> >
> > https://wiki.dlang.org/Vision/2017H1
> >
> >
> > Andrei
>
> Is there a design document for how D will achieve safety with
> nogc?
> How does D plan to prevent leaks, use-after-free, double-free
> bugs when not using the GC?

Part of the reason that we have the GC in D is because of the safety
guarantees that you can have with a GC that you can't have with mechanisms
like malloc and free. Some amount of @nogc code can be @safe, but some of it
will never be able to be @safe. e.g. the very nature of malloc and free
makes @safe impossible in the general case. It's trivial for a piece of code
to free something that's currently in use by other code. If they're
constrained within a ref-counting system, then @safety becomes more
possible, but even then, when you have to start worrying about stuff like
weak references in order to get around circular reference problems, it gets
dicey if not impossible to make it fully @safe. It might be possible to
guarantee safety if you have a whole bunch of extra constraints like Rust
does with its borrowing stuff, but we're not going to add something like
that to D, because it's too complicated on top of everything else that we
already have.

I fully expect that certain idioms will be in place to help maintain @safety
in @nogc code, but to some extent, by abandoning the GC, you're abandoning
@safety - or at least you're making a lot more of your code need to be
@trusted, and you can rely less on the compiler to guarantee @safety for
you. Taking the freeing of memory out of the hands of the programmer like
happens with the GC is _huge_ in guaranteeing the memory safety of code.

> Will @nogc also have first class support in the language?

And what do you mean my first class support? Some features require the GC,
and I wouldn't expect it to ever be otherwise. Giving up the GC means giving
up on certain features. We don't want that list to be longer that it needs
to be, but some stuff fundamentally needs the GC to do what it does.

> Afaik the GC is currently needed for language features like array
> concatenation. Will features like array concatentation still work
> with @nogc?

I don't see how it possibly could given how dynamic arrays work in D. It
would have to have some sort of reference counting mechanism, which would
likely be a nightmare with slicing and certainly does not at all play well
with how low level D arrays are. We may very well get some sort of
ref-counted array type that has concatenation, but it would be a library
construct rather than in the language, because it doesn't need to be in the
language, and the built-in arrays would not be affected by it.

> GC allocations have a keyword 'new' (afaik 'new' currently never
> means anything other than GC allocation). Will we be able to do
> @nogc allocations by the 'new' keyword?

I very much doubt it. Constructing objects into memory is done via emplace,
which is a library construct, and there's really no need for it to be in the
language. As it is, if we were doing things from scratch, new probably
wouldn't even be a keyword. It would likely be a library construct in
druntime, because D is powerful enough that new doesn't need to be in the
language to do what it does. And in general, at this point, Walter and
Andrei don't want to put stuff in the language unless it actually needs to
be there. If it can be done with a library, it will be done with a library.
The only reason that they decided that we needed some sort of ref-counting
mechanism in the language is because they decided that it wasn't actually
possible to make it fully @safe without it being part of the language. And
even then, I'm not sure that the intention is that the ref-counting
mechanism use anything other than the GC. It's not yet clear what it's going
to look like, but previously, the talk was using the GC to take care of
circular references, which would mean that the memory was still GC-allocated
even if it were ref-counted. We'll have to wait and see though.

> Is the same code always expected to work with/without @nogc?

That would depend entirely on the code. std.experimental.allocator has a GC
allocator. So, code that is designed around it could work with the GC or
without. But the whole mechanism of newing something up and then not
worrying about ownership which happens by default with the GC doesn't play
at all nicely with how memory has to be managed via other mechanisms like
malloc and free. I don't think that it's at all reasonable to expect that
code that is written with the idea that its memory will be managed by the GC
will also work without the GC

Re: Vision document for H1 2017

2017-01-12 Thread Chris Wright via Digitalmars-d-announce
On Thu, 12 Jan 2017 20:02:38 -0800, Jonathan M Davis via
Digitalmars-d-announce wrote:
> I don't see how it possibly could given how dynamic arrays work in D. It
> would have to have some sort of reference counting mechanism, which
> would likely be a nightmare with slicing

On that topic, D's arrays would play nicer with both refcounting *and* 
modern garbage collectors if they were structured as base, offset, length 
instead of start, length. You could put metadata just before the start of 
the array, including the reference count.


Re: Vision document for H1 2017

2017-01-12 Thread Jonathan M Davis via Digitalmars-d-announce
On Friday, January 13, 2017 05:33:07 Chris Wright via Digitalmars-d-announce 
wrote:
> On Thu, 12 Jan 2017 20:02:38 -0800, Jonathan M Davis via
>
> Digitalmars-d-announce wrote:
> > I don't see how it possibly could given how dynamic arrays work in D. It
> > would have to have some sort of reference counting mechanism, which
> > would likely be a nightmare with slicing
>
> On that topic, D's arrays would play nicer with both refcounting *and*
> modern garbage collectors if they were structured as base, offset, length
> instead of start, length. You could put metadata just before the start of
> the array, including the reference count.

It's actually really nice as well as performant for D's dynamic arrays to be
the way that they are. Adding any kind of reference count into them would
add overhead as well as not play nicely when you're doing stuff like slicing
pointers or static arrays, which should definitely not be ref-counted. If
you're willing to use the GC, they way that D's dynamic arrays work right
now is fantastic. And even if you're not willing to use the GC, the way they
work is great if you have other code managing their memory appropriately and
just don't use the concatentation or appending operations. Plenty of code
would not want any ref-counting to be going on when passing a dynamic array
around.

Having a ref-counted object that's like an array in addition to D's current
dynamic arrays would be fine and great for some programs, but I sure
wouldn't want to lose what we have now.

- Jonathan M Davis