Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you are writing CPP, rust is a godsend. Many pitfalls/code review debates/wtf moments simply don’t happen in the language. There are huge cpp code bases in the wild which need help.

However rust string handling is barely a step above c’s, there are a variety of datastructures c engineers dislike simply because of the memory management constraints. Getting 2x better performance than Java is a marginal gain for many environments.

I really hope rust takes a bent towards ease of use. Stabilizing a rust gc arena would be hugely impactful, or simply revisiting the string api.



I've found Rust is also far better than weakly typed and dynamically typed languages as well.

> However rust string handling is barely a step above c’s

How so? Personally I've found it very good.


Having 3 separate string types commonly used across the standard library is a huge friction.

For beginners, it’s impossible to write a common program for doing some basic string manipulation without reading 3/4 of the Rust book and waiting through dozens of compilation failures.


Are the three types you refer to str/String, CStr/CString, and OsStr/OsString?

There are trade-offs associated with having multiple string types, but the alternative is worse. It's better to force the developer to handle these things up front than to have bugs down the line.

str/String being UTF-8 is great. Is means that the various standard library functions associated with them have well-defined behavior.

CStr/CString are necessary for FFI, but I wouldn't really say they're commonly used in std.

OsStr/OsString are necessary unless you think the standard library should automatically convert whatever random format the OS uses into UTF-8. Rust's decision to not treat everything like Unix is actually a good thing.

> For beginners, it’s impossible to write a common program for doing some basic string manipulation without reading 3/4 of the Rust book and waiting through dozens of compilation failures.

Personally, I think the standard library makes it pretty easy to learn how to convert between the types.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: