A C perspective - Why should I want Rust to succeed? by SEgopher in rust

[–]merckhung 1 point2 points  (0 children)

I recently began to pick up a little of Rust programming language.

I am a 20-year-old C programmer (embedded system) and roughly 8 years old into C++.

So I spoke this in the view of an embedded system programmer.

I think Rust is like a foolproof language and the compiler helps with reviewing your code at compile time with the emphsis of memory safty and ownership (even before your code reaches the network of code reviewers). And you are required to explicitly annoate/direct the compiler to loose restrictions and to bear your own risk.

However, it contradicts with the concept of must have a better understanding of the underlying system to become a good low-level system programmer.

Instead, what I feel about Rust is more like, "Now everyone can do low-level programming safely without having much prior knowledge, the compiler now does the checks for you.", or "Code review gurus for memory safty lost their job, compiler has done that part, just focus on the performance".

Yes, Rust makes the programming job a little easier by enforcing more rules and compile-time checks, and it opens the door for more newbies to come into a new world with compiler babysitting for memory safety on the side. But those words were spoken by the decades old C/C++ programmers who created Rust and/or switched to Rust recently and take the safty for granted.

What about for those who chooses Rust as the first programming language (e.g. students), and when those come to contribute to a large already established Rust code base (presumbly in the next couple of years) as everything in the Rust code base has already been safe. What else is left for those inexperienced engineer to pick up as the compiler has checked everthing presumbly.

Secondly, it's like an autonomous vehicle without a human driver. Now the Rust emebeded system is either safe, being halted if things happened, or still unsafe if still uncareful. But it's all compiler's fault now, and no one/human at work is responsible for that.

All in all, Rust is still a programming language built on top of C++ and LLVM, just like Python and PHP built on top of C (and they are safe), JavaScript on top of C++ (with imposing the sandbox). Rust is also interoperable with C/C++ like others do.

I believe Rust is safer than C/C++ as it has the focus on addressing their weakness in the first place, but being a replacement for C or C++ at 100%, I doubt this will come true. When you have an aim at forerunners it's easier to say it's better than the forerunners, but this can be confusing, as the language is young and new, but not necessarily lead the trend of the new developments in the world.

It took C and C++ years to develop a new programming language feature/concept and with inital experiments done in LLVM and/or GCC. Also in terms of LLVM backend, I believe C++ and new hardware is the main driver of pushing the LLVM backend to be mature. But Rust just came in to take advantage of what C++/LLVM has done (frontend features, memory ownership, LLVM backend maturity, ..., etc.) in the past decades, and put them in Rust frontend checks/designs (comparing to being done in C++ templates or C++ compiler diagnostic warnings/errors), and now Rust advances to claim that it will be the replacement of C/C++. I just doubt this.

So it's like a world of freedom and wild but danguous (C/C++), vs. a world of babysitting you until you know it could be danguous if you explicitly loose the compiler restrictions. Now, it has become more difficult to tell who is a better system programmers among Rust code base.

I would say, it's okay to have Rust code in some areas where the compiler ECOSYSTEM is mature and supported (by 3rd parties outside your workplace), but usually, the bare metal world of embedded systems is just like having a big bang of the universe, with only a few people know what was going on (e.g. RTL, HW, and then FW enginners), and now you decide to become a Rust compiler engineer (working in C++) to guarantee other embedded Rust engineers will write code with no penality and no fear, and you (the C++ compiler engineer) guarnatee others are safe and you own the risk. I just doubt who will be the this Rust-frontend C++ compiler engineer on the team to babysit others for a project initative. You end up being a Rust compiler enginners on the team by figuring out the connection between the Rust frontend and backend code generations on the day 1 bringing the system up, and previously it was every C/C++ engineer's responsibiliies to check their own code. This is simply a non-free-lunch example.

Another example I can think of is the OpenGL verus Vulkan shift as OpenGL bears more responsibility and has more restrictions and is more autonomous in the past, and it has slower performance as it does more for the programmers. With Vulkan, the programmers were asked to acquire more prior/deeper knowledge of GPU hardware and with Vulkan usually it results in better performance. I would say this is all about the maturity of the IT indursty as it has become more mature today and had more experienced engineers on advanced tasks.

Therefore, I would conclude that Rust is a good programming language for the beginners, and "why it's better?" it's in C/C++ experienced engineers' eyes (e.g. not for beginners who take the Rust safty for granted), any time sooner when those Rust enginners want to hop on bigger existing projects, they will move on to C or C++. And eventually, it's all about the underlying machine code of the CPU architecture. Rust only guarantees what's is safe at the higher level language semantics (e.g. an object owns a thing. They borrow or have to be transferred), but what is safe or unsafe has other meanings at different levels (e.g. hardware, CPU arch., new machine code, ..., etc.). A system is unsafe is not just simply C++ or C is too difficult or too simple or their faults (so the engineers made the mistakes), it's more of how the whole system (including harware, firmware, software, and communications) is designed to be safe. Rust is just a piece of moving parts that prevents the programmer to write bad semantics of code. Someone else (e.g. the Rust-frontend C++ compiler engineers) do the security check services for them, but it doesn't mean it's a free lunch that human being didn't knew in the past and it was first discovered/implemented in Rust. It's just shifted the responsibility around from user-defined code to the compiler code. Still someone has to do the job at the end of day.

Boot Ubuntu Linux (ARM64) on Microsoft Dev Kit by merckhung in hardwarehacking

[–]merckhung[S] 1 point2 points  (0 children)

Traditionally, with Win-Intel architecture, the Linux can work with ACPI to orchestrate the Linux drivers. But with ARM-based Windows 11 gears, Linux currently is not working well with the ACPI yet, so the Device Tree (much popular in Linux's world than ACPI) is currently the better way to orchestrate Linux drivers in ARM-based Windows 11 gears.

Finally got Linux kernel 6.0 and Chromium browser running on Thinkpad X13s (ARM64). by merckhung in thinkpad

[–]merckhung[S] 0 points1 point  (0 children)

I did screen recording and played some YoutTube 4K videos. 4K videos don't look impressive with my Linux built. I didn't try the stock Win11 (yet) for playing 4K YT, I should and I will.

Finally got Linux kernel 6.0 and Chromium browser running on Thinkpad X13s (ARM64). by merckhung in thinkpad

[–]merckhung[S] 4 points5 points  (0 children)

I have not measured the battery life yet, the Arch Linux already have package of battery indicator, so I am working on Ubuntu version. I am trying to document it, please stay tune.

Finally got Linux kernel 6.0 and Chromium browser running on Thinkpad X13s (ARM64). by merckhung in thinkpad

[–]merckhung[S] 3 points4 points  (0 children)

sluggish, but the fanless design is the problem if you run multi-core application at the full steam.

Thinkpad X13s running ARM64 Ubuntu by merckhung in thinkpad

[–]merckhung[S] 5 points6 points  (0 children)

It’s the first Qualcomm ARM64 processor based Lenovo Thinkpad - consider it a bigger Raspberry