Live data from Hacker News

Reflections on Rust, and the Sand Castle Metaphor

brandur.org

1–10 of 89 posts

Re: Reflections on Rust, and the Sand Castle Metaphor

#4
Very much matches my experience with the last ~2.5 years of Rust.

One of the really eye-opening ones for me was building a UI library on win32 and watching it just work on Linux, OSX, Android and WASM(with some Canvas work). Obviously each platform took some work to build out their respective rendering primitives but the core engine(including embedding Lua via gcc crate) just worked.

As someone who's done x-platform stuff most of their career it was nothing short of incredible.

Re: Reflections on Rust, and the Sand Castle Metaphor

#5
I do think the difficulty of Rust is brushed aside by its proponents. This week I wrote a little script to read an XML file, get a path from it, read a file at that location, do some regexes on it, and then update the XML and write it back to disk.

I'd estimate it took me about 10 times longer to implement in Rust than Python. And I don't exactly know Python well - it wasn't just extra time Googling how to do things.

A lot of it is just how restrictive the borrow checker is. Often you have to structure your code in a really weird way to satisfy it.

Dealing with strings is another pain point. I get why there is `&str` and `String`. But that doesn't explain why I can't add two `String`s together using +.

Another thing I've found is that because of the type inference it often gets really confusing whether a variable is a reference or not. Doesn't help that code completion basically doesn't work at all at the moment.

I wish there were a simpler language, like Rust (no garbage collector, no runtime), but that was a little more helpful and willing to do implicit things even if they are slightly slower than the most optimised code possible.

Re: Reflections on Rust, and the Sand Castle Metaphor

#6
This is indeed very light in content. Also, while Rust fixes a whole set of problems, it doesn't mean that Rust fixes all possible problems.

It is relatively easy to create a situation where you overflow your program. See here: https://github.com/rust-lang/rust/issues/50049

Googling around, there are many situations where bad code can lead to an overflow and your code breaking.

Re: Reflections on Rust, and the Sand Castle Metaphor

#7
post #4

Very much matches my experience with the last ~2.5 years of Rust. One of the really eye-opening ones for me was building a UI library on win32 and watching it just work on Linux, OSX, Android and WASM(with some Canvas work). Obviously each platform took some work to build out their respective rendering primitives but the core engine(including embedding Lua via gcc crate) just worked. As someone who's done x-platform…

I have the same experiences with Go regarding xplat. I was particularly amazed that I could trivially cross compile by simply setting the GOOS and GOARCH env vars to the correct operating system and CPU architecture and then running `go build`.

EDIT: Curious why people are downvoting this. Is it really so taboo to suggest that Go could be nearly as pleasant as Rust at something? Do I really need to roll out my Rust fanboy creds every time I participate in a thread on the language?

Re: Reflections on Rust, and the Sand Castle Metaphor

#8
post #5

I do think the difficulty of Rust is brushed aside by its proponents. This week I wrote a little script to read an XML file, get a path from it, read a file at that location, do some regexes on it, and then update the XML and write it back to disk. I'd estimate it took me about 10 times longer to implement in Rust than Python. And I don't exactly know Python well - it wasn't just extra time Googling how to do things.…

> I'd estimate it took me about 10 times longer to implement in Rust than Python. And I don't exactly know Python well - it wasn't just extra time Googling how to do things.

That doesn't surprise me at all. Writing it in C++ would probably take me a lot longer than writing it in Python too.

Re: Reflections on Rust, and the Sand Castle Metaphor

#9
post #6

This is indeed very light in content. Also, while Rust fixes a whole set of problems, it doesn't mean that Rust fixes all possible problems. It is relatively easy to create a situation where you overflow your program. See here: https://github.com/rust-lang/rust/issues/50049 Googling around, there are many situations where bad code can lead to an overflow and your code breaking.

It's even easier than that:

let buf = [0u8; 810241024];

Re: Reflections on Rust, and the Sand Castle Metaphor

#10
post #5

I do think the difficulty of Rust is brushed aside by its proponents. This week I wrote a little script to read an XML file, get a path from it, read a file at that location, do some regexes on it, and then update the XML and write it back to disk. I'd estimate it took me about 10 times longer to implement in Rust than Python. And I don't exactly know Python well - it wasn't just extra time Googling how to do things.…

> Another thing I've found is that because of the type inference it often gets really confusing whether a variable is a reference or not. Doesn't help that code completion basically doesn't work at all at the moment.

Out of interest what setup are you using? My editor is telling me whether a variable is a reference or not so maybe this is just a plugin you don’t have? I’m currently using Rust Enhanced (with RLS), I believe VSCode shows you this information too.

Post reply on HN