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.

Cause Go uses a GC and there's no way around GC related spikes in Go. Rewriting programs in Rust to avoid the GC is actually a thing.

Rust features actually complement each other. Things like ImportC, const, dip1000, and @live don't complement the language. Dip1000 and @live just don't make sense and their design is flawed on top of that. You keep saying it's optin when it adds complexity to the language, that's not optin. It seems they are just trying to copy Rust due to its success, without understanding why Rust is successful.

May 27, 2022

On Friday, 27 May 2022 at 10:45:21 UTC, mee6 wrote:

>

Cause Go uses a GC and there's no way around GC related spikes in Go. Rewriting programs in Rust to avoid the GC is actually a thing.

Isn't that exactly what Discord did, actually? I remember reading their latencies went from milliseconds to microseconds

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.

Rust is designed for performance and safety, and people have confidence that the language design and compiler, actually accomplishes this.

You don't have to 'opt in'. Instead, you have to consciously opt out. This principle is really important for the future of programming lanaguages.

So in that sense it's not at all surprising that people would want to recode for performance and safety.

What is surprising, is that they're willing to do it in Rust (given it's syntax is so cognitively demanding).

But that's what happens when academics get involved in language design ;-)

Going from C, C++, C#, Java .. to D, is relatively painless.

This simply cannot be said, when going to Rust.

This is the lesson the designers of Rust should have taken from D.

Imagine how popular Rust would be now, if they had done that.

These forums would be pretty quiet indeed, if that had happened.


May 27, 2022

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

>

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.

Yes, but allocating on the stack is an optimization. So, for @safe code just let all memory be managed by the compiler and add hints where you desire memory optimization. Then let the compiler decide and report what the layout is and why.

I want a reason to not use C++20. I want less manual memory management constructs. I want smarter memory management. And I generally dont want to think about it or see it in my algorithms.

DIP1000 doesn’t provide that, neither does free/malloc or stop-the-world GC.

May 27, 2022
On Friday, 27 May 2022 at 12:27:00 UTC, forkit wrote:
> 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.
>
> Rust is designed for performance and safety, and people have confidence that the language design and compiler, actually accomplishes this.
>
> You don't have to 'opt in'. Instead, you have to consciously opt out. This principle is really important for the future of programming lanaguages.
>
> So in that sense it's not at all surprising that people would want to recode for performance and safety.
>
> What is surprising, is that they're willing to do it in Rust (given it's syntax is so cognitively demanding).
>
> But that's what happens when academics get involved in language design ;-)
>
> Going from C, C++, C#, Java .. to D, is relatively painless.
>
> This simply cannot be said, when going to Rust.
>
> This is the lesson the designers of Rust should have taken from D.
>
> Imagine how popular Rust would be now, if they had done that.
>
> These forums would be pretty quiet indeed, if that had happened.

One thing people here seem to miss is that Rust isn't just a memory safety thing anymore.

The memory safety is still a very big draw, yes obviously, but the language as a whole has a lot of goodies that draw people to it.

I know a handful of rust programmers, most of them don't really care about the memory safety primarily but rather memory safety *and* all the "functional" stuff it inherited from ML.

For example doing things like sum and product types as a library whether it be C++ or D just looks incredibly tired and banal compared to doing it properly and cohesively (pattern matching for example) in the language. This can be rectified in D, we just need to actually do it. Tuples have been on the cards for years.
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.

I think it's because they don't focus on interop with other languages, especially other than C. It's "my way or the highway". And Rust provides many benefits over C/C++ making people willing to make the complete switch.

In comparison, D is trying to be a language that can partially replace and interact with existing C++ codebases, even adding language features to support such workflow.

Not arguing whether one behavior is better than the other, but it's easier to force programmers to redesign their programs if they don't have an easy transition path. If it's a hard transition path, might as well, do the redesigns at this point.
May 27, 2022

On Friday, 27 May 2022 at 13:06:46 UTC, max haughton wrote:

>

For example doing things like sum and product types as a library whether it be C++ or D just looks incredibly tired and banal compared to doing it properly and cohesively (pattern matching for example) in the language. This can be rectified in D, we just need to actually do it. Tuples have been on the cards for years.

Bjarne suggested pattern matching for c++ in 2014, and there is a proposal from 2020 numbered 1371. I doubt it will make it, but who knows?

May 27, 2022
On Friday, 27 May 2022 at 09:43:02 UTC, Nick Treleaven wrote:
> 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);

To finish my point, scope allows using `new` in @nogc functions. And it enables allocation optimizations, so scope can't just be for a static analyzer.
May 27, 2022
On 27.05.22 07:25, rikki cattermole wrote:
> 
> A question Timon came up with that I answered:
> 
> ```d
> int[][] func(int[] a, int[] b){
>      return [a,b];
> }
> ```
> 
> (for return value): ``// ownership: [first argument, second argument]``

(What I don't like about this is that it conflates ownership for different levels of indirection, the memory of the resulting array is actually GC-owned.)
May 27, 2022
On Friday, 27 May 2022 at 06:14:53 UTC, rikki cattermole wrote:
> 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.
>

The reason you can't do RC on classes, at least safely, is BECAUSE there is no escape analysis.