Hacker News new | ask | show | jobs
by neuralquantum 1538 days ago
Rust is becoming a primary language for modern blockchains and hence the roadmap should account for their demands as well, particularly three of them:

1. Readable and debuggable macros. Blockchain devs use them heavily, and it's virtually impossible to understand what's going on for a person, who wasn't involved in the development of that code with macros.

2. Floating point operations reproducibility across environments. When it comes to finding and hashing the consensus among many machines about floating point calculations, Rust gets ugly: in fact, as a developer, you'll have to use either integers or a made up fixed point numbers instead of floats to ensure that calculations are identical on different machines. You need that because hash function will be completely different for two numbers, which are even slightly different.

3. Zero-exception safety mode checking at compile-time. Blockchain code should run forever and never halt. Because if it does, the whole blockchain is at risk of stopping, and some chains may never recover from that. So, just as good as Rust prevents poor memory management, there should be a special optional compile-time check, that prevents runtime exceptions and halts, and forces the developer to wrap all possible points of exceptions in nice workarounds.

Blockchain devs are the best Rust adopters out there, we're excited to see how the language is becoming defacto a standard for web3 development.

1 comments

> Readable and debuggable macros

I agree this is a concern. However, proc-macro errors can be improved, and the people that should (and can) do so are their developers, not the compiler developers (although if they can it will be good, but I doubt it).

> Floating point operations reproducibility across environments.

I'm not proficient with blockchain, but Rust's floating point is and will always be what the hardware provides. Libraries can provide custom float types.

> Zero-exception safety mode checking at compile-time.

This is what `Result` is for. If you want to also catch panics, you can use `std::panic::catch_unwind()`. There is no good way to prevent them at compile time, and cannot be without major changes to the language (though see https://github.com/dtolnay/no-panic).