Live data from Hacker News

Why you should, actually, rewrite some of it in Rust

unhandledexpression.com

1–10 of 300 posts

Re: Why you should, actually, rewrite some of it in Rust

#6
post #5

If you are really worried about the security of old C code, then the safest, most portable thing to do is re-write in modern C++. This is sane and doable in a short period of time. Rust is not.

Why not Rust? Given that you aren't very familiar with niether C++ nor Rust, I'm not convinced that C++ is saner or faster.

Re: Why you should, actually, rewrite some of it in Rust

#7
post #3

C can be safe if you use Turing incomplete libraries that have been verified. It's the YOLO ad hock parsers that get you in trouble.

I am not sure if you are serious or not.

How does verification prevent buffer overflows? It can reduce their frequency, but you can never know you got them all. They find issues in libCURL and openSSL that have existed for years. Very few people are better than the people working on those libraries.

It is better to be safe by default then add risk only when you need it. I say this as a C++ developer, I think const should be the default state of all variables and one should have to opt out of that, and Rust did that right and C is so far from that I see no reasonable way to use plain old C safely. At least with C++ I can hide my stuff in classes and verify one thing at a time.

Re: Why you should, actually, rewrite some of it in Rust

#8
You can also rewrite to C++, OCaml, Go... Each language has benefits and drawbacks, and there is good reason for each them to exist.

Would your project benefit a lot from algebric datatypes -> OCaml is a great fit!

You want to port as soon as you can: C++ is your friend.

You plan to write HTTPS service nodes: Go has the best standard library out there.

Re: Why you should, actually, rewrite some of it in Rust

#9
post #4
post #2

Or even better, Haskell!

If you rewrote only part of a large C++ project in Haskell, is there a way to link it back in again?

Call Haskell from C (not C++) seems pretty easy:

- [Calling Haskell from C - HaskellWiki](https://wiki.haskell.org/Calling_Haskell_from_C)

And the FAQ on the Haskell wiki directly addresses this too:

- https://wiki.haskell.org/Introduction#I_already_have_a_large....

So apparently it is doable!

Re: Why you should, actually, rewrite some of it in Rust

#10
post #5

If you are really worried about the security of old C code, then the safest, most portable thing to do is re-write in modern C++. This is sane and doable in a short period of time. Rust is not.

Or just rewrite it in modern C. This is sane and doable in a short period of time. You just have to make sure it's modern C.

(no true Scotsman)

Post reply on HN