Hacker News new | ask | show | jobs
by nemothekid 897 days ago
This feels like a personal statement of familiarity rather than looking ahead to designing a language that has to be taught to next generation of software engineers. AFAIK, the only operator Rust introduces over C++ is the try operator (aka. ?) and match statements. Furthermore I can't imagine how someone could prefer

    &&auto my_closure = [&](int x, int y) { return x + y }
to just

    let my_closure = |x: int, y: int| { x + y }
C++ is the one that tries hard to standout.
2 comments

> This feels like a personal statement

Because it is. And is a statement I agree 100% being a +20-years C developer with a hardwired C parser in my brain: Rust, Zig and some (most?) newer C++ syntax is contorted at minimum (to my eyes).

I wish the only difference were about just new operators, but just the fact that the type has to come after the variable declaration is awful to me (also for returning types in functions declarations). One can tell me 100 reasons why Rust does it this way and they'll probably be all true and right, and you can call me all sort of things but this kind of new syntax puts me off right away.

The difference is negligible in real syntax:

    auto my_closure = [](int x, int y) { return x + y; };

    let  my_closure = |x: int, y: int| { x + y }
and frankly, the option of an explicit capture-list with aliases and mixing moves and copies is a benefit:

    int sum = 0, diff = 0;
    
    auto adder = [&sum](int num) {
        sum += num;
    
        // compilation error, author didn't
        // mean to capture diff.
        diff -= num;
    };