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

That method signature is not that bad to be honest, I actually feel this a bit better than Rust. (Though it might have helped if you added a newline in the middle of that signature). Maybe you're complaining more about the complexity of the type system rather than the syntax.

Or maybe because I'm saying this because I'm already acquainted to the evil monstrosities of C++. Here's the same function: (and this is even with C++20 concepts on):

    // Yes, you need to include some headers to get even the most basic features! Typical C++.
    #include <type_traits>
    #include <optional> 

    template <Collection Elements, Equatable Element,
              typename = std::enable_if_t<std::is_same_v<typename Elements::Element, Element>>>
    std::optional<typename Elements::Index> index(Element element, const Elements& collection) {
        // Function body
    }



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: