• traches@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    20
    ·
    6 hours ago

    I don’t get the hatred for types, they have saved my ass so many times and saved so many headaches exactly like what the article describes. I used to write a lot of ruby and after getting decent at typescript I can’t go back.

    It’s not just ceremony, types ensure some level of logical consistency in your app. They reduce how much of the world you need to keep in your head at one time, and they allow you to express your intent far more robustly than comments and naming can. I love rust’s approach of making invalid state not even representable.

  • dohpaz42@lemmy.world
    link
    fedilink
    English
    arrow-up
    13
    arrow-down
    5
    ·
    edit-2
    5 hours ago

    Instead of just doing what I want to do, I’m stuck either doing plumbing work to hold my values and pass them around, or I’m casting things back and forth where I know things are correct but the compiler doesn’t.

    I hate this attitude.

    Instead of doing what you want to do? Dude, unless you’re a hobbyist, you’re being paid to do what your company wants you to do; i.e., it’s not about what you want.

    Stuck doing plumbing work? Yeah, nobody likes plumbing, but we all know it’s necessary. When you’ve got your proverbial shit backing up onto your floor because you cheaped out on plumbing, cry to me then.

    If you’re casting things back and forth, you’re doing it wrong. Spend a day or two and build yourself a solid, consistent foundation, plan ahead, and you won’t be casting things back and forth.

    And no, you obviously don’t know better than your compiler, you arrogant sack of sh…

    Anyway, get over yourself already and just do your damn job better.

  • TehPers@beehaw.org
    link
    fedilink
    English
    arrow-up
    6
    ·
    5 hours ago

    Types aren’t unit tests. Unit tests only test a discrete set of inputs and outputs for correctness, and can miss cases that aren’t tested for.

    In sound type systems, they are closer to formal verification. The compiler guarantees the properties you expect of the type hold.

    As for the rest of the article, do what works best for you in your projects, but if I need to work with you, I’m going to ask for types. I need to know what types the interface expects to receive. Names are not enough. Document them, use type hints, whatever, just put them somewhere because I’m not psychic and I don’t know what you thought about when writing the function.