News for hackers. Stuff that matters.
Re:I think C++ is still a desirable coding platform compared... by Kelteseth on Wednesday November 22, 2023 @09:08AM (#38379320)
Yeah, that's a no from me. I'm a full time C++ dev and every time I code in Rust it is harder for me to switch back. The author has pointed to some issues regarding performance. In the end, you can always rewrite your code to generate other/better assembly, if you really need the speed. I would argue Rust is so much more that just Rust itself. Like many others after noted, it is not only the language, but the whole ecosystem and oh boy is cargo a joy to use. Yes, CMake works ok with vcpkg, but good luck integrating something that is not CMake. Code style, build script/system and different bugs from different compilers do not make my life easier. In addition, we still have old features we cannot repair because of ABI. It is an endless mess.
Re:I think C++ is still a desirable coding platform compared... by skywal_l on Wednesday November 22, 2023 @09:28AM (#38379633)

    rustup target add wasm32-unknown-unknown
    cargo build --target wasm32-unknown-unknown

    rustup target add x86_64-unknown-linux-musl
    cargo build --target x86_64-unknown-linux-musl

    rustup target add x86_64-pc-windows-gnu
    cargo build --target x86_64-pc-windows-gnu
Boom, killer feature right there.
Re:I think C++ is still a desirable coding platform compared... by sapiogram on Wednesday November 22, 2023 @09:36AM (#38379752)
Well, sometimes. God help you if your project needs to use TLS, for instance.
Re:I think C++ is still a desirable coding platform compared... by synergy20 on Wednesday November 22, 2023 @10:44AM (#38380741)
there is another key difference between rust and c++, rust by default bundles its stdlib into the executable, which make each executable kind of a static binary, they add up fast.

c++ uses shared libraries, smaller in size for the whole system, and, you can upgrade a library separately too.

on embedded systems where storage space is restricted, rust is simply a no-go.

Re:I think C++ is still a desirable coding platform compared... by steveklabnik on Wednesday November 22, 2023 @11:10AM (#38381091)
You absolutely can get Rust codegen down to as small as you’d ever need: https://news.ycombinator.com/item?id=34032824
Re:I think C++ is still a desirable coding platform compared... by synergy20 on Wednesday November 22, 2023 @11:39AM (#38381500)
that's for MCU and yes, as it does not use rust's stdlib.

there are lots of embedded systems that run with glibc or musl shared libraries, if rust is used there, it will blow up the storage space with just a few executables due to the static stdlibs.

Re:I think C++ is still a desirable coding platform compared... by steveklabnik on Wednesday November 22, 2023 @12:12PM (#38381934)
I don’t understand why techniques valid in small spaces aren’t also valid in slightly larger spaces.

If you don’t have the budget for the standard library, don’t use it. If you somehow have the budget for glibc and not the rust standard library, call into glibc instead of the rust standard library.

Re:I think C++ is still a desirable coding platform compared... by synergy20 on Wednesday November 22, 2023 @12:57PM (#38382586)
glibc can be shared by 20 c executables.

rust stdlib will be bundled with those 20 rust executables, they blow up quickly.

mcu does not use stdlib of rust, it uses no-std, c++ has its own nonstdlib as well, on mcu they're similar.

Re:I think C++ is still a desirable coding platform compared... by steveklabnik on Wednesday November 22, 2023 @01:32PM (#38383134)
Yes, I understand what you're saying. I am saying that if you find yourself in that situation, don't use the Rust standard library. Your Rust programs can share glibc with your C programs just fine. This isn't a disqualifying situation for Rust. Heck, when you use the Rust standard library, dynamically linking to glibc is the norm!
Re:I think C++ is still a desirable coding platform compared... by simon_void on Friday November 24, 2023 @09:41AM (#38404423)
maybe OP doen't know about #![no_std] !? You can not (as far as I know) have the Rust std lib as a dll, but you can chose to not use/include the std lib: https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/sh...
Re:I think C++ is still a desirable coding platform compared... by steveklabnik on Friday November 24, 2023 @02:20PM (#38407209)
Just FYI, these docs are very old. They’re for rust 1.25.0. Since rust is stable that means they’re still accurate, just not complete.
Re:I think C++ is still a desirable coding platform compared... by synergy20 on Friday November 24, 2023 @05:00PM (#38408852)
of course I knew no_std, it's for MCUs, similar to c++'s nostdlib, I'm comparing rust's stdlib to libstdc++ though, but the former is not shared-lib friendly to say the least.
Re:I think C++ is still a desirable coding platform compared... by skywal_l on Wednesday November 22, 2023 @10:45AM (#38380761)
Use LTO if that's a problem.

    [profile.release] # A profile to try to minimize the size
    panic = "abort" # Abort on Panic
    strip = true
    opt-level = "z" # Optimize For Size
    lto = true # Enable Link Time Optimization (LTO)
    codegen-units = 1 # Reduce Parallel Code Generation Units to Increase Optimization
Re:I think C++ is still a desirable coding platform compared... by synergy20 on Wednesday November 22, 2023 @10:59AM (#38380950)
it helps, I tried 'how to make rust the minimal in size', but still, it's like 10x of the size comparing to c++ with shared libraries.
Re:I think C++ is still a desirable coding platform compared... by eternityforest on Wednesday November 22, 2023 @08:28PM (#38388011)
Flash storage is getting cheap. There is some places where it matters.... but on everything else.... I am really not a fan of dynamic linking.

Linux has proven for a very long time that if you have 100 programs, and they each have 100 dependencies, you'll probably see an occasional issue related to incompatibility.

It seems like it's suited to the mindset of unique systems maintained by sysadmins, with every app being a part of the system, quite possibly built locally just for your task.

The modern way seems to be disposable installs that cab be recreated automatically if some probably-not-worth-fixing thing happens, made of reusable multipurpose software made by people who have never heard of your application, and a bit of local code, which might be intended to someday become one of those mega-frameworks.

Even windows used to always have hassles with some visual C++ runtime or other.

Although the standard library of C isn't a big issue since it's not in the habit of breaking things, but I'd imagine Rust might want to make bigger changes since it's so new.

Re:I think C++ is still a desirable coding platform compared... by ostenning on Thursday November 23, 2023 @12:31AM (#38389675)
All embedded applications and libraries can be declared with no_std, removing the std dependency and heap allocation.

Shared libraries are also possible.

Re:I think C++ is still a desirable coding platform compared... by synergy20 on Thursday November 23, 2023 @04:03PM (#38397506)
well without stdlib, there is not much I can do on non-mcu devices it's like I have c++ but no libstdc++ for a smart tv device development
Re:I think C++ is still a desirable coding platform compared... by hdjdkdbdbe on Friday November 24, 2023 @05:46PM (#38409220)
You have the ability to remove the stdlib if needed...
Re:I think C++ is still a desirable coding platform compared... by hdjdkdbdbe on Friday November 24, 2023 @05:45PM (#38409208)
Recovered c++ dev here. I started with rust in 2016 and never looked back!!

I started in my own time and even back then it was superior...

People like c++ for the language features... I dislike it because of all the defensive programming one must do....