News for hackers. Stuff that matters.
Re:Static search trees: 40x faster than binary search by jltsiren on Wednesday January 01, 2025 @10:27AM (#42566561)
I think it's almost irrelevant how good Rust is as a language. Rust is winning in many contexts, because you can use it to replace C++, but the standard library and tools are substantially better.
Re:Static search trees: 40x faster than binary search by nostradumbasp on Wednesday January 01, 2025 @02:52PM (#42568734)
The entire user experience is so much nicer that even if Rust was slightly worse I would prefer it. I don't miss header files, makefiles, not having a package manager, maintaining all the crazy code people wrote themselves as pet projects instead of using an existing project in an ecosystem. Thankfully its not worse, so I don't even have to weigh the odds.
Re:Static search trees: 40x faster than binary search by tomcam on Wednesday January 01, 2025 @05:02PM (#42569689)
Wait isn't cargo a package manager? Not a rust expect so I'm probably missing something
Re:Static search trees: 40x faster than binary search by Tanjreeve on Wednesday January 01, 2025 @05:47PM (#42569953)
I think their point was that Rust has a batteries included package manager (cargo). Another advantage of which being that all rust projects are pretty standard in that particular aspect.
Re:Static search trees: 40x faster than binary search by nostradumbasp on Wednesday January 01, 2025 @07:16PM (#42570421)
That is correct.
Re:Static search trees: 40x faster than binary search by amelius on Wednesday January 01, 2025 @06:23PM (#42570150)
Without makefiles, how do you do projects with multiple languages or code generators like lex and yacc?
Re:Static search trees: 40x faster than binary search by nostradumbasp on Wednesday January 01, 2025 @07:39PM (#42570559)
Well, I don't use makefiles to deploy software with Rust. I also have never used lex or yacc, but I bet there are similar tools in the ecosystem, or wrappers for those. That would obviate what I will offer below.

Often a new language in a project would define an application boundary. So those would be different containers or services. I may deploy via container images, or an OS specific installer, etc. If we aren't crossing an application boundary I may use FFI. Sometimes I use https://rust-lang.github.io/rust-bindgen/ to smooth that over for C dependencies. There is also a nice concept called a build.rs file: https://doc.rust-lang.org/cargo/reference/build-script-examp.... There's also tools like: https://github.com/casey/just and https://sagiegurari.github.io/cargo-make/

I rarely use multiple languages with Rust. A lot of interpreted languages have bindings through crates and can go in to a project through Cargo. If it involves JS/TS on desktop, I'm usually using Tauri for that. Guess it depends on the system?

Hopefully that helps. You can also still use a Makefile if you want I just haven't dealt with one in a long time.

Re:Static search trees: 40x faster than binary search by eslaught on Wednesday January 01, 2025 @08:21PM (#42570786)
If you're embedding, say, a C library inside of Rust, you can do so via a so-called "build.rs" script [1]. These run at build time so you can do pretty much whatever you want. They're not necessarily pretty, but given that Cargo isn't going to support other languages natively, it's often a less-evil option.

Then there are build systems that natively support Rust in addition to other languages and know how to plug them together [2] [3] [4]. If you're already using one of these existing tools, then you don't need to roll your own, you can plug it into your existing project.

Of course if you really are using Makefiles in C you're already living in the wild west, so it's on you to figure out how to add Rust to your projects in that case (or switch to a better build system).

[1]: https://doc.rust-lang.org/cargo/reference/build-scripts.html

[2]: https://bazelbuild.github.io/rules_rust/

[3]: https://buck.build/rule/rust_library.html

[4]: https://mesonbuild.com/Rust.html

Re:Static search trees: 40x faster than binary search by richrichie on Thursday January 02, 2025 @02:02AM (#42572384)
Rust is great for pet projects. Otherwise, it is a big security risk for large commercial projects, since it lacks a useful standard library and any non trivial program needs to download a thousand crates to work.
Re:Static search trees: 40x faster than binary search by alfiedotwtf on Thursday January 02, 2025 @07:49AM (#42573973)
What languages are you thinking of that have all the libraries you could ever possibly need for a commercial project built-in?
Re:Static search trees: 40x faster than binary search by richrichie on Thursday January 02, 2025 @09:08AM (#42574529)
Go and C++ have pretty decent standard libraries, for example.
Re:Static search trees: 40x faster than binary search by alfiedotwtf on Friday January 03, 2025 @09:50AM (#42586090)
Apart from `simd`, and if you allow us to embelish by using Tokio and I'll ignore the C++'s reliance on Boost, there's not really much I can see from C++'s standard library that's anyhow wildly different from Rust.

What in particular do you see lacking in Rust that you can do in C++?

Re:Static search trees: 40x faster than binary search by uecker on Friday January 03, 2025 @04:05PM (#42589456)
Also from legal and liability point of view it opens a can of worms.
Re:Static search trees: 40x faster than binary search by alightsoul on Monday January 06, 2025 @11:01AM (#42611653)
Yeah. Too much stuff to manage
Re:Static search trees: 40x faster than binary search by nipah on Monday January 06, 2025 @10:41AM (#42611463)
This is pure bs considering the massive amount of large commercial projects written in C# that depends on a lot of community-made packages.
Re:Static search trees: 40x faster than binary search by alightsoul on Monday January 06, 2025 @11:00AM (#42611645)
C# and other high level languages like Java are much safer than any low level language including Rust, in those languages you don't even have an unsafe mode
Re:Static search trees: 40x faster than binary search by neonsunset on Monday January 06, 2025 @01:46PM (#42613810)
.NET languages have always had access to unsafe feature subsets at multiple levels of abstraction with varying degrees of "unsafety". .NET has also been slowly leaning more into its systems-programming side. It is now at a strange crossroads where it is not like C or C++, or as a much better replacement, Rust but not like Java or Go either.
Re:Static search trees: 40x faster than binary search by debrutal on Monday January 06, 2025 @02:25PM (#42614425)
Have you ever heard of Java native Interface or Java native abstractions? Thats unsafe AF. Same goes for native implementations. Whenever something needs to be done fast, the jvm implements native code. Have you ever debugged that magic bs? Guess why people chose a high level language, because they don't want to bother with complicated stuff. Still those abstractions on these languages are not better, even worse considering their APIs, than rusts. Working with thread locals or synchronized keywords, non atomic members and all the bad concurrency mechanisms inside Java is unsafe shy default.

Runtime exceptions is what I consider a bad practice and it's spread everywhere in Java... Also the language evolutions are not really that good. So bringing errors/exception to the compilation time is a safety net.

Despite the fact that languages with managed memory safety bring a lot of potential for abusively high memory consumption, random GC stop the world situations and worse like oom.

Whenever I had to analyze a memory issue with an application it was no fun at all, despite the challenge.

The jvm specifications are so flawed considering security... Creating classes at runtime from a stream using reflections, which is totally spec compliant gave us log4shell. Why even load serialized classes from remote?! Fail by design.

So safety is still context sensitive and depends on the requirements. If you write bad software you can ignore some of the mentioned aspects, though it still lacks of 'security'

Just my 2 cents here

Re:Static search trees: 40x faster than binary search by nipah on Tuesday January 07, 2025 @12:37PM (#42625053)
C# absolutely have an unsafe mode, basically since version 1. You can use pointers, deal with stackallocated memory and all of that, in recent versions you can even natively allocate and deallocate memory using the `NativeMemory` type. Of course, it is harder to cause problems and the `unsafe` isolated areas provide a similar unsafety abstraction mechanism as Rust does, but it is still possible. And in the edge, both C# and Java have FFI and can call directly into C/C++ (or basically any native language) code, so you can still open a big security hole in your application (and nuget makes it very convenient to even ship native binaries in your packages, as you can see with the many wrappers around things like libsodium, raylib, windows/linux API's and more).

In the end of the day, C# had the same ideas of isolating unsafety that Rust has, and provides many safe wrappers around good libs, like Skia (SkiaSharp, very famous and widely used) for example. So those ideas are kinda market proven as well.