May 27, 2022
On 27/05/2022 5:06 PM, Walter Bright wrote:
>> I want users of my libraries to be able to use my code without caring about stuff like memory lifetimes and be strongly likely to never hit an issue even with concurrency. I want the average programmer to be able to use my stuff without having to care about the little details.
> 
> The garbage collector does this famously.

I forgot to mention this in my other reply, when I talk about lifetimes I am not meaning about memory allocation/deallocation. That's a solved problem even if reference counting is not available on classes (we should do this but for other reasons).

What I care about is escape analysis, to make sure say an owning container, does not have a member of it escape its lifetime. Which of course would be bad, due to the fact that the data structure can deallocate it.

The problem I'm interested in here, is that the compiler guarantees that the order of destruction happens in the right order. This is something the GC does not do, but one that the compiler can and should be doing.

On that note, I've become quite a big fan of GC's for application code after studying memory management. For that reason I *really* want to see write barriers implemented as opt-in so that people can play around with implementing far more advanced GC's (since we are almost maxed out on what we can do without it).
May 27, 2022

On Friday, 27 May 2022 at 05:06:54 UTC, Walter Bright wrote:

>

Rust is famous for forcing programmers to not just recode their programs, but redesign them from the ground up. How they managed to sell that is amazing.

They sold it to a small percentage of devs. That is sufficient since Rust is the only wellknown language with a borrow checker.

Rust is not a good language for most devs, the ones Rust is good for are already using it.

Go instead with optimization hints and checks on that, with static analysis that tells the programmer what has to be changed to get better performance.

A good type system cannot easily be evolved. It has to be built, bottom up, on a theoretical foundation. This is why the @live approach is unlikely to succeed.

May 27, 2022
On Friday, 27 May 2022 at 05:06:54 UTC, Walter Bright wrote:
> On 5/26/2022 8:07 PM, rikki cattermole wrote:
>> I want lifetime checks to work,
>
> So do I. But nobody has figured out how to make this work without strongly impacting the programmer.
>
>
>> I want users of my libraries to be able to use my code without caring about stuff like memory lifetimes and be strongly likely to never hit an issue even with concurrency. I want the average programmer to be able to use my stuff without having to care about the little details.
>
> The garbage collector does this famously.
>
>
>> DIP1000 so far does not appear to be working towards a design that meets these goals.
>
> Rust is famous for forcing programmers to not just recode their programs, but redesign them from the ground up. How they managed to sell that is amazing.

By being *focused* on being the best language on a very specific domain, thus Rust is now the best mainstream implementation of affine types, and their official roadmap has plans to still improve that experience.

The 1% use case that works as stepping stone for adoption.
May 27, 2022

On Thursday, 26 May 2022 at 14:35:57 UTC, deadalnix wrote:

>

Fantastic. Every single one of them is a false positive so far. I now face the situation where I will have deprecation warning forever, or add attribute soup to the program.

Can you briefly highlight what those false positives are?

>

I'd be happy to add attributes for something that could actually track ownership/lifetime. DIP1000 is not that. Adding attributes for that is not worth it.

Would having attributes be inferred for non-templated functions alleviate some these problems? Or isn't that possible because a definition might have forward declarations with qualifiers needing to be in sync with the definition?

May 27, 2022

On Thursday, 26 May 2022 at 14:35:57 UTC, deadalnix wrote:

>

This is the opposite of progress. Stop it.

I'd be happy to add attributes for something that could actually track ownership/lifetime. DIP1000 is not that. Adding attributes for that is not worth it.

Despite quoting Amaury, my reply is aimed at everyone here.

DIP1000 is sure a difficult concept to learn, and I agree it's onerous to migrate code to use it and it does not discover that much flaws in existing code. But there is one imperative point that I haven't seen mentioned here.

There was a fundamental design flaw in @safe, and DIP1000 is the solution to it. It's not just about enabling new paradigms, it's about plugging a hole in existing one. These compile without the DIP, but are detected by DIP1000:

@safe ref int oops1()
{ int[5] arr;
  int[] slice = arr[];
  return slice[2];
}

@safe ref int oops2()
{ struct AnInt
  { int here;
    int* myAddress()
    { auto result = &here;
      return result;
    }
  }

  AnInt myInt;
  return *myInt.myAddress;
}

If you're against DIP1000, you have to either:

  • Say that we should resign the purpose of @safe eliminating undefined behaviour from the program. I'd hate that.

  • Say that we should simply disallow slicing static arrays and referencing to address of a struct member from a member function in @safe code. That would break a LOT of code, and would force @safe code to resign quite a deal of performance. I'd hate that.

  • Come up with a better idea for escape checking. For one, I cannot.

One thing I want to mention is that you only need scope if you're going to work with data in the stack. Often it's more pragmatic to just allocate stuff on the heap so you don't have to fight with scope checks.

DIP1000 is currently only scarcely documented. I'm considering doing a series of blog posts to the D blog about DIP1000, that would probably help.

May 27, 2022

On Friday, 27 May 2022 at 08:53:29 UTC, Dukc wrote:

>

DIP1000 is currently only scarcely documented. I'm considering doing a series of blog posts to the D blog about DIP1000, that would probably help.

Personally I haven't heard about DIP1000, nor used it, and only will when it becomes default. Reading this makes me anxious how much the work will be.

May 27, 2022
On Thursday, 26 May 2022 at 22:54:22 UTC, deadalnix wrote:
>
> If immutable instead meant immutable in most places, you you can mutate it with this weird construct, then it is effectively useless as a language construct, because it restrict my expressiveness on one axis without granting me greater expressiveness on another.

scope actually does allow that. Any local heap allocation only passed to scope parameters can be allocated on the stack instead of the heap.

void f(scope T);

T v = new T; // can be stack allocated
f(v);
May 27, 2022

On Friday, 27 May 2022 at 08:53:29 UTC, Dukc wrote:

>

On Thursday, 26 May 2022 at 14:35:57 UTC, deadalnix wrote:

>

DIP1000 is currently only scarcely documented. I'm considering doing a series of blog posts to the D blog about DIP1000, that would probably help.

Why exactly is DIP1000 talked about as inevitable when it never completed the DIP process? Or was never accepted? It just seems like Walter has decided that's what should happen? Or have I missed something?

May 27, 2022

On Friday, 27 May 2022 at 10:05:15 UTC, claptrap wrote:

>

On Friday, 27 May 2022 at 08:53:29 UTC, Dukc wrote:

>

On Thursday, 26 May 2022 at 14:35:57 UTC, deadalnix wrote:

>

DIP1000 is currently only scarcely documented. I'm considering doing a series of blog posts to the D blog about DIP1000, that would probably help.

Why exactly is DIP1000 talked about as inevitable when it never completed the DIP process? Or was never accepted? It just seems like Walter has decided that's what should happen? Or have I missed something?

The DIP1000 name is somewhat unfortunate for this reason.

May 27, 2022

On Friday, 27 May 2022 at 10:05:15 UTC, claptrap wrote:

>

On Friday, 27 May 2022 at 08:53:29 UTC, Dukc wrote:

>

On Thursday, 26 May 2022 at 14:35:57 UTC, deadalnix wrote:

>

DIP1000 is currently only scarcely documented. I'm considering doing a series of blog posts to the D blog about DIP1000, that would probably help.

Why exactly is DIP1000 talked about as inevitable when it never completed the DIP process? Or was never accepted? It just seems like Walter has decided that's what should happen? Or have I missed something?

That's the D-ictatorship for you