News for hackers. Stuff that matters.
Re:Safety: A comparaison between Rust, C++ and Go by CrendKing on Saturday July 30, 2022 @08:18AM (#32286215)
The fact that you may know that make_appender definition being bad does not mean every C++ user knows as well. It's also impossible for you to know ALL the possible bad, UB leading C++ code out there.

I think the point the author tries to make is that, while C++ and Rust are probably "the same" for the most skillful and disciplined programmers (such as you), for average human, Rust just catches way more errors they make for them early. An extreme analogy would be trying to climb Everest all by yourself vs with a professional guide.

Re:Safety: A comparaison between Rust, C++ and Go by benreesman on Saturday July 30, 2022 @08:29AM (#32286269)
Not to disagree necessarily, but if you (give me a little rope) bucket languages that are hard to get past the compiler but more often correct when you do (Rust, Haskell), and languages where it's pretty easy to get something past the compiler and tweak it until it works well enough for your purposes (JS, C/C++), the tweak-it-until-it-kinda-works languages are fucking killing it on adoption.
Re:Safety: A comparaison between Rust, C++ and Go by davedx on Saturday July 30, 2022 @10:47AM (#32287200)
I dunno man. I've done C, C++, JavaScript and TypeScript professionally for significant chunks of my career, and the trend that I've observed has overwhelmingly been towards stricter compilers. For example in the front-end world, TypeScript has absolutely exploded in adoption. Everyone could be still using JavaScript, but companies from startups to huge corporates have explicitly decided they want compile type safety -- often in "only" front-end code.

I suspect that the adoption of Rust as a system language is going slower because that's just the natural pace of embedded/systems development, not because of anything intrinsic to Rust. There are now 30k+ lines of Rust code [1] in the Linux kernel. C++ can't claim that.

[1] https://www.phoronix.com/news/Rust-v6-For-Linux-Kernel

Re:Safety: A comparaison between Rust, C++ and Go by benreesman on Saturday July 30, 2022 @11:12AM (#32287403)
Oh I think we probably see largely eye-to-eye. My weapon of choice when there are no other constraints is Haskell, and one reason I really like Rust is that I can get a lot of the Haskell features I like in a highly-performant setting. Most of the C++ I maintain these days is in whole or in part generated by Haskell. And if I have to write something fast by hand and it doesn't need to link to stuff I need, I reach for Rust generally.

I was also unaware that Rust has such significant penetration in the Linux kernel, and that's a place where I can see it really shining.

My first comment in this thread was something to the effect that Rust has tons of great stuff to offer, and that the memory safety argument is actually weaker than people think and probably not the only thing people should talk about.

The resulting gang-tackle is just one more data point that the community is still too small and evangelical for me to want to get involved past my proprietary Rust stuff.

Re:Safety: A comparaison between Rust, C++ and Go by davedx on Saturday July 30, 2022 @02:05PM (#32288897)
Ha, Rust community is very energetic, but IMHO they largely put that energy to good use!

I’m using it for a new project and honestly I’m using it more for the modern tooling and easy C interop than the safety features, but I’m a fan overall. Think it’s a really good language.

Re:Safety: A comparaison between Rust, C++ and Go by unsafecast on Saturday July 30, 2022 @01:09PM (#32288388)
> Most of the C++ I maintain these days is in whole or in part generated by Haskell

Can you expand on that? I'm currently researching something similar but lower level & lisp instead of Haskell. It would help to see some existing examples to figure out if it's worth it or not.

Re:Safety: A comparaison between Rust, C++ and Go by benreesman on Saturday July 30, 2022 @01:45PM (#32288740)
Ideally we'll just be able to open source it soon!

Basically we have a nice Haskell DSL for generating arbitrary C++, and we deal with lots of code you wouldn't want to write by hand (big nested switch statements and other kinds of state-machine logic, choices about loop unrolling, lots of template overloads, SIMD intrinsics that require immediate values, etc. etc.) so we write Haskell that generates C++ and feeds it to e.g. `clang`.

Some of this is directly in Haskell, and some of it is little compilers mostly done using Megaparsec. It's a really nice approach where it fits!

Re:Safety: A comparaison between Rust, C++ and Go by unsafecast on Saturday July 30, 2022 @03:42PM (#32289660)
Sounds great, that's what I was imagining too. Is there a way I can find it when/if you open the source?
Re:Safety: A comparaison between Rust, C++ and Go by benreesman on Saturday July 30, 2022 @11:27PM (#32292873)
Drop me a line at [email protected] and I'll let you know when we can open-source some of it.

None of it is really all that magical btw, so you should take a whack at it yourself!

One thing that wouldn't have occurred to me that one of the Haskell geniuses I work with identified to use is the notion of a "free"/"operational" monad: https://apfelmus.nfshost.com/articles/operational-monad.html.

Re:Safety: A comparaison between Rust, C++ and Go by unsafecast on Sunday July 31, 2022 @01:19AM (#32293377)
Thanks a lot.

> None of it is really all that magical btw, so you should take a whack at it yourself!

Of course! It's always good to see how other people approach it though.

Re:Safety: A comparaison between Rust, C++ and Go by zozbot234 on Saturday July 30, 2022 @10:21AM (#32287013)
> it's pretty easy to get something past the compiler and tweak it until it works

That's just as true of Rust if you use clone(), Rc<> and RefCell<>. You just have to familiarize with a few boilerplate patterns, and the best part is you're only trading off a modicum of performance while preserving safety. But Rust can work quite well as a language for exploratory programming.

Re:Safety: A comparaison between Rust, C++ and Go by grumpyprole on Saturday July 30, 2022 @10:10AM (#32286934)
> the tweak-it-until-it-kinda-works languages are fucking killing it on adoption.

Industry clearly prioritises speed of delivery above all else. Security, reliability and maintenance are future problems (that would be nice to have).

However, in order to gain the power to reason about our code and be able to prove the correctness of various properties (what a typechecker does), we have to program with more restrictive models. This has been argued many times before (e.g. Dijkstra's structured programming). Haskell and Rust are just two of many examples. My favourite is regular expressions, choose actual proper regexes and you have guaranteed O(n) execution, choose Perl/Python "Regex" and you have a potential security hole.

Re:Safety: A comparaison between Rust, C++ and Go by gmnash on Saturday July 30, 2022 @01:54PM (#32288804)
JS and C++ are killing it on adoption because they had near monopolies for an extended period of time in their respective areas (browser, native higher level language). They are popular despite their obvious (some in hindsight) shortcomings due to lack of alternatives in the same categories.
Re:Safety: A comparaison between Rust, C++ and Go by bhaak on Saturday July 30, 2022 @10:51AM (#32287227)
Javascript‘s adoption has much less to do with its language features but with its unique positioning.

There was (and still isn’t) a competitor that can compete on the same level with Javascript in the browser.

Re:Safety: A comparaison between Rust, C++ and Go by ncmncm on Saturday July 30, 2022 @06:12PM (#32290875)
Literally anybody can turn on warnings and heed the results.