October 21, 2022

On Friday, 21 October 2022 at 07:37:41 UTC, Stefan Hertenberger wrote:

>

You don't need to reorder, just use references

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

}

Heh. You don't need closures, just use regular functions.

October 21, 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:

>

This is just one of multiple examples I personally encountered where Rust's approach to memory- and thread-safety makes life difficult for its users. On simple cost-benefit grounds, I can see using Rust for writing OS drivers (or even an entire OS) or for use in embedded systems, especially if there's a real-time constraint; in other words, where a GC would be unsuitable. But for ordinary applications on today's hardware? Use of Rust instead of D, Go, Nim, etc. makes no sense to me.

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.

In short Rust is a useless language for embedded and it would take forever to become productive. Also information how to do this in Rust is difficult to find as most of Rust programs are just normal applications and that is also what Rust was originally designed for. I've tried several languages in order to evaluate how it can deal with embedded programs (more advanced than just blinking a LED, real resource handling). I've evaluated Rust, D, Nim, Swift among others and Rust got the place at very bottom by a great margin. There were simply things I couldn't do in Rust and even if it possible it would have taken ages do figure out how to do it. The other languages were more easy, not perfect and you had do deal with some quirks but you understood why and how you could work around them.

...

Useless or not, it is becoming a thing,

https://www.autosar.org/news-events/details/autosar-investigates-how-the-programming-language-rust-could-be-applied-in-adaptive-platform-context/

https://opensource.googleblog.com/2022/10/announcing-kataos-and-sparrow.html

https://azure.microsoft.com/en-us/blog/delivering-consistency-and-transparency-for-cloud-hardware-security/

https://techcommunity.microsoft.com/t5/internet-of-things-blog/previewing-rust-on-azure-sphere/ba-p/3494988

https://github.com/orgs/esp-rs/projects/1

https://www.eenewseurope.com/en/arm-joins-the-rust-foundation/

https://www.phoronix.com/news/Rust-Is-Merged-Linux-6.1

I could keep posting links about Rust's rise on the embedded space, but I think you got the point.

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.

October 21, 2022
On Friday, 21 October 2022 at 07:37:41 UTC, Stefan Hertenberger wrote:
> ...
> You don't need to reorder, just use references
> ...

First of all I don't use Rust, I took a look years ago and I didn't like its syntax, so I don't know how someone could rewrite the case presented in the original post.

But I think people are missing the point of Don Allen, he showed a snipped code and its simplicity, and for it seems it's not easy to do in some languages, at least without changing a lot.

For example, I wrote this a while ago: "The problem that took him 5 years to fix in C++, I solved in a minute with D".

https://forum.dlang.org/thread/oyfejgtjsupbdgckfdjz@forum.dlang.org

Matheus.
October 21, 2022
On Friday, 21 October 2022 at 10:19:13 UTC, matheus wrote:
>
> But I think people are missing the point of Don Allen, he showed a snipped code and its simplicity, and for it seems it's not easy to do in some languages, at least without changing a lot.

I think the point is despite the example is very simple, it's required to have very detailed knowledge about the Rust compiler and its lifetime system in order to understand this problem. Sure you rewrite in some undefined "idiomatic Rust" but is it good language design when such detailed knowledge and order of statements is required?

D is in the other end of this spectrum, it swallows almost anything.

October 21, 2022
On Friday, 21 October 2022 at 10:36:27 UTC, IGotD- wrote:
> On Friday, 21 October 2022 at 10:19:13 UTC, matheus wrote:
>>
>> But I think people are missing the point of Don Allen, he showed a snipped code and its simplicity, and for it seems it's not easy to do in some languages, at least without changing a lot.
>
> I think the point is despite the example is very simple, it's required to have very detailed knowledge about the Rust compiler and its lifetime system in order to understand this problem. Sure you rewrite in some undefined "idiomatic Rust" but is it good language design when such detailed knowledge and order of statements is required?
>
> D is in the other end of this spectrum, it swallows almost anything.

Yeah, but the ecosystem doesn't swallow anything, that is the problem.
October 21, 2022
On Friday, 21 October 2022 at 10:42:52 UTC, Paulo Pinto wrote:
> On Friday, 21 October 2022 at 10:36:27 UTC, IGotD- wrote:
>> On Friday, 21 October 2022 at 10:19:13 UTC, matheus wrote:
>>> [...]
>>
>> I think the point is despite the example is very simple, it's required to have very detailed knowledge about the Rust compiler and its lifetime system in order to understand this problem. Sure you rewrite in some undefined "idiomatic Rust" but is it good language design when such detailed knowledge and order of statements is required?
>>
>> D is in the other end of this spectrum, it swallows almost anything.
>
> Yeah, but the ecosystem doesn't swallow anything, that is the problem.

Yes, the ecosystem is the problem. Not the language
October 21, 2022

On Friday, 21 October 2022 at 10:42:52 UTC, Paulo Pinto wrote:

>

Yeah, but the ecosystem doesn't swallow anything, that is the problem.

Please stop saying it is an ecosystem issue. That is not they key thing that prevents adoption. This is just a sleeping pill that makes people go for apathy believing that they cannot change the trajectory. Which is wrong.

The main issue with D is not lacking an ecosystem, D has an ecosystem that can grow and that allows you to be productive in system level programming. System level programming does not require a gigantic eco system.

But D is adding new stuff to a code base that is difficult to evolve rather than focusing on design issues people complain about. The core difference is that C++ and Rust are clearly showing in their releases that they are working on compensating for design flaws that people care about.

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.

Without a solid strategy you can neither get rid of design issues or grow in a predictable manner. For an outsider D as a project looks more like a one-man-person-with-entourage than a cooperative effort. This does not grow confidence in the project.

Rust and C++ are much less about any singular entity, but more of a collaborative effort. That is good for confidence and for long term viability and evolution.

It is great for D that there is a foundation now, but has it really changed the structure of the project, and how strategies are formed, to any significant degree?

October 21, 2022

On Friday, 21 October 2022 at 10:16:10 UTC, Paulo Pinto wrote:

>

affine type systems have won for low level systems coding.

Not sure it will be Rust though.

In the new native language camp, Jai and Odin makes use of Scala-like "context" pointer passed to each function to pass around an allocator, a logger... being true to the monadic nature of allocation and logging. With an important difference there, Odin apparently uses a fixed context, and Jai a custom one where you can put anything.

Now THAT is an interesting feature to have for embedded.

October 21, 2022

On Friday, 21 October 2022 at 11:54:59 UTC, Guillaume Piolat wrote:

>

On Friday, 21 October 2022 at 10:16:10 UTC, Paulo Pinto wrote:

>

affine type systems have won for low level systems coding.

Not sure it will be Rust though.

It is also not true. C/C++ are still completely dominating. Reactive systems are also done using special tools (functional style). Low level programming is not some narrow field that can be shoehorned into any singular dev environment.

>

nature of allocation and logging. With an important difference there, Odin apparently uses a fixed context, and Jai a custom one where you can put anything.

Now THAT is an interesting feature to have for embedded.

Implicit context pointers have been suggested for Carbon too. (hidden parameter to functions)

October 21, 2022

On Friday, 21 October 2022 at 11:54:59 UTC, Guillaume Piolat wrote:

>

On Friday, 21 October 2022 at 10:16:10 UTC, Paulo Pinto wrote:

>

affine type systems have won for low level systems coding.

Not sure it will be Rust though.

In the new native language camp, Jai and Odin makes use of Scala-like "context" pointer passed to each function to pass around an allocator, a logger... being true to the monadic nature of allocation and logging. With an important difference there, Odin apparently uses a fixed context, and Jai a custom one where you can put anything.

Now THAT is an interesting feature to have for embedded.

None of them have the industry backing at the same scale.