from Hacker News

Why Rust?

by ned_at_codomain on 8/26/24, 2:45 PM with 5 comments

  • by brainless on 8/26/24, 3:12 PM

    As a solo founder trying again (1) after many failed attempts, I can only say that my investment in Rust is paying off. A lot.

    I have worked with PHP in my early days (2006...), for about 6 years. I wanted to move to a language more structured. When I switched to Python I felt it was worth my investment. Working as a web developer, JavaScript was always there and I could not change that. After working with Python for 11 years, I felt if I attempt to be a founder again, I needed two things from a language - structure in developing my ideas, peace of mind to take a product to users' hands. I was OK to learn syntax, but I can not become a legendary developer with magical knowledge of some language.

    Refactoring the codebase is wildly different since I get so much support from the compiler/type system. And, if it compiles, it will simply not have a class of errors.

    The investment is steep, really steep. I am no distinguished engineer, just another one with average talent. I have been working full-time building my product and I am preparing to launch - multiple products in the next 6-7 months, all on the same core code-base in Rust. I have never felt a language could give me this much.

    1. https://github.com/brainless/dwata

  • by prashantkmrjha on 8/26/24, 2:57 PM

    Great article! The emphasis on safety and performance really resonates with me, especially in domains like systems programming where Rust's memory safety guarantees can prevent a lot of the headaches that come with languages like C or C++. The ownership model is a game-changer, even though it has a learning curve. I also appreciate how Rust balances low-level control with modern language features like pattern matching and an expressive type system.

    However, I’m curious about your thoughts on the ecosystem around Rust for certain domains, particularly in web development or data processing, compared to more established languages. While Rust is making strides, do you think it’s ready to fully replace other languages in these areas, or is it more of a complement to existing tech stacks?

  • by sshine on 8/26/24, 4:07 PM

    tl;dr: Safety, speed, borrow checking, algebraic types and pattern matching, error handling, scoped resource management (the Drop trait), traits, first-class wasm support, tooling.

    What's not explicitly mentioned, but may be implied:

      - Rust got rid of implicit nulls!!!
      - Explicit control of mutability.
    
    An imperative language where you have explicit control of mutability, is a great alternative to a purely functional programming language.

    And yes: it's not simple, compiling takes time, and the syntax is noisy.

    > f32 and f64 does not implement Ord

    Is NaN greater or smaller than -Inf?

    At least Rust is honest about this being nonsense!

    Both f32 and f64 implement PartialOrd, which is even an improvement over Haskell's trait hierarchy:

    https://doc.rust-lang.org/beta/std/cmp/trait.PartialOrd.html...

    I think this is the general thing I like about the Rust ecosystem: You can expect that people seek to model a domain with afterthought. Like not favoring convenience in the common case over saying wrong things at the edge. There is, admittedly, a lot of drive-by coding where some domains are littered with half-done crates nobody pushed to in 5 years.