October 22, 2022
On 10/21/2022 6:14 AM, IGotD- wrote:
> Yes, that's my take on it too. The only way out of this is that D is forked.

We welcome DIP proposals from anyone, and once approved, anyone can implement them.

October 22, 2022
On 10/21/2022 3:16 AM, Paulo Pinto wrote:
> Naturally I also agree that systems programming languages with GC should be used, but  unless we have a big name pushing them, affine type systems have won for low level systems coding.

D's gc has turned out to be ideal for CTFE programming.
October 22, 2022

On Friday, 21 October 2022 at 13:14:41 UTC, IGotD- wrote:

>

On Friday, 21 October 2022 at 11:51:46 UTC, Ola Fosheim Grøstad wrote:

>

The main issue for D is a lack of strategy that involves architecting a modern D compiler, that people want to work on, and an objective strategy for selecting design issues that needs to be addressed.
...

Yes, that's my take on it too. The only way out of this is that D is forked.
...

For those with time and a fork-it bent I'd suggest contributing to SDC as an alternative, or prelude, to a complete fork.

October 22, 2022
On Saturday, 22 October 2022 at 01:35:52 UTC, Walter Bright wrote:
> On 10/20/2022 7:46 PM, Don Allen wrote:
>> I've written about 10,000 lines of Rust over several years, revised many times in consultation with a couple of people in the Rust community who were particularly helpful. I've been writing code professionally and otherwise for longer than most of you, since I'm now 80 (first line of code in 1960 -- IBM 1620 assembly language). I understand Rust pretty well at this point, so I don't think the "newcomer" description applies.
>
> I'm glad you wrote this. I thought I was the oldest D programmer! I'm very pleased there are more of us using D! I hope I'm as sharp as you are when I'm 80.

Thank you.

The great comedian Red Buttons, at Sid Caesar's 80th birthday celebration: "When my father turned 80, I asked him "Pop, what does a man of 80 think about? He said '81'".
October 22, 2022

On Saturday, 22 October 2022 at 05:35:22 UTC, victoroak wrote:

>

On Thursday, 20 October 2022 at 13:37:07 UTC, Don Allen wrote:

>
fn main() {
    let mut foo = 5;
    let mut bar = || {
        foo = 17;
    };
    let mut baz = || {
        foo = 42;
    };
    bar();
    println!("{}", &mut foo);
    baz();
    println!("{}", &mut foo);

}

I think the way it would be advised to write it in Rust would be something like this instead of using RefCell:

fn main() {
    struct State {
        foo: i32
    }

    impl State {
        fn bar(&mut self) {
            self.foo = 17;
        }

        fn baz(&mut self) {
            self.foo = 42;
        }
    }

    let mut state = State {
        foo: 0
    };

    state.bar();
    println!("{}", state.foo);
    state.baz();
    println!("{}", state.foo);
}

The problem is that both closures have a mutable reference to the same value and this is not allowed in Rust, you could solve this making the functions get a mutable reference to the variable but using a struct in this case is better IMO.

I think it's clear that my Scheme-ish attempt to use Rust closures was not a good idea. The fundamental problem with using Rust closures in this way is that the borrow-checker thinks any mutable borrows that occur in the closure happen at the time the closure is defined, not when it is called. This is one of those situations where trying to insure safety at compile time can be too conservative, which the Rust folks concede.

Interior mutability and reference counting are both run-time ways to get around the compiler when it prevents you from doing things that are actually safe but can't be proven safe at compile time.

I never actually fixed the code from which my example is drawn, which I wrote quite awhile ago, because at that point I'd reached my personal Rust-pain threshold and moved on to D, returning my blood pressure to normal. But if I were going to fix it, I agree with you that your (very nice) solution is preferable. Avoiding closures and instead using functions/methods results in the mutable borrows occurring at call time, which solves the problem, since my call pattern doesn't violate the "one mutable borrow at a time" rule. I'm sure Refcell would also work, as it did with my little example, but it's messier and introduces a bit of runtime overhead (which I doubt would matter in the application in question running on 4 GHz hardware, so I think the readability issue is primary).

I'd also add that in effect, what you are doing is manually creating closures by using a struct and struct methods (behind the scenes, Rust closures are built by the compiler with structs in much the same way). But by doing it manually, you get finer grained control over how and when the mutable borrows occur, so they happen in a smarter way than what the compiler is doing.

October 23, 2022

I guess, it really depends on what happens in bar and baz but my solution would be something like this.

fn main() {
    #[allow(unused_assignments)]
    let mut foo = 5;
    let bar = || -> i32 {
        // do something here
        17
    };
    let baz = || -> i32 {
        // do something here
        42
    };
    foo = bar();
    println!("{}", foo);
    foo = baz();
    println!("{}", foo);

}

As always one uses the best fitting tool to solve the problem and in your case it was D ?!

October 23, 2022

On Thursday, 20 October 2022 at 14:26:07 UTC, IGotD- wrote:

>

On Thursday, 20 October 2022 at 13:37:07 UTC, Don Allen wrote:

>

[...]

Actually, Rust is even worse for embedded, OS, near hardware programming. The memory model just gets in the way of doing those things. Example of things in OS programming are often intrusive containers, pointers/references pointing in all directions and sometimes even to itself, multiple use of containers for the same object, chicken and egg problems. This is where the memory model of just Rust breaks down. Of course you have to use unsafe everywhere but as soon as you do that, things get ugly very quickly. For these tasks C++ is still the obvious choice. However, this is not normal programming and you have to do tricks that you never usually do in application programming.

[...]

I have also experienced this. We tried using Rust at work for embedded but it slowed us down so much to the point we decided to just do it in C instead.

October 23, 2022

On Sunday, 23 October 2022 at 12:19:24 UTC, Imperatorn wrote:

>

On Thursday, 20 October 2022 at 14:26:07 UTC, IGotD- wrote:
we decided to just do it in C instead.

Sad D-man in BetterC mode

October 23, 2022

On Sunday, 23 October 2022 at 12:23:14 UTC, Sergey wrote:

>

On Sunday, 23 October 2022 at 12:19:24 UTC, Imperatorn wrote:

>

On Thursday, 20 October 2022 at 14:26:07 UTC, IGotD- wrote:
we decided to just do it in C instead.

Sad D-man in BetterC mode

Yup, I'm trying to convince the rest of the team we should go with betterC. But it's hard to get ppl to try new things (except Rust for some reason)

October 23, 2022
On Sunday, 23 October 2022 at 12:44:15 UTC, Imperatorn wrote:
> ...
> Yup, I'm trying to convince the rest of the team we should go with betterC. But it's hard to get ppl to try new things (except Rust for some reason)

Maybe I'm comparing very different things, but for me this Rust trend reminds me something similar to Ruby On Rails.

Some years ago most companies where I live were hiring mostly RoR developers, even the company that I work for, but now at least where I live it's very hard to find a position for RoR, in fact most companies around here are hiring (Mostly) C# developers now.

Matheus.