HNHacker News
TopNewBestAskShowJobs

throwaway234232

28 karma · joined July 8, 2022

submissionscomments
throwaway234232··on Pipenv: Promises a Lot, Delivers Little (2020)
I agree, but they also include hashes.
throwaway234232··on Pipenv: Promises a Lot, Delivers Little (2020)
https://github.com/pypa/pip/issues/4732
throwaway234232··on Pipenv: Promises a Lot, Delivers Little (2020)
You don't need virtual environments when using npm or composer or cargo.

They also create lock files with hashes by default.

pip still doesn't use lock files. It's subpar compared to other ecosystems.

throwaway234232··on Rust should not have provided `unwrap`
Your example doesn't help your argument here, as square should be taking `T` instead of `Option<T>`, a good use case for `Option::map`.

But if you are speaking about ergonomics of handling Options, it is being improved upon with the usage of try operators with Options as well as possibly seeing try expressions in the near future.

I don't think lack of ergonomics is a good justification for usage of unwrap, but that is entirely subjective. However, I do see the misappropriation of `unwrap` as a signal that the ergonomics in Rust are lacking and it's something that needs to be addressed, so again I do sympathize.

throwaway234232··on Rust should not have provided `unwrap`
This is a good use case for let-else, however I won't agree with you here on usage of unwrap for the sake of brevity. I will opt for `?` or match instead.
throwaway234232··on Rust should not have provided `unwrap`
The footgun here is that `unwrap` may be used inappropriately, and from what I see using github code search it's used inappropriately quite often.
throwaway234232··on How I went about learning Rust
You can still use a null, however the point being made here is that null was failed to be included at type level.

See these for reference

* https://kotlinlang.org/docs/null-safety.html

* https://dart.dev/null-safety

* https://docs.microsoft.com/en-us/dotnet/csharp/nullable-refe...

An orthogonal approach would be using a data type such as Maybe or Option, but ergonomics depends on language.

throwaway234232··on Functional programming is finally going mainstream
I've ran into this before, but to be fair I was using Monad Transformers.
throwaway234232··on Beginner's guide to error handling in Rust
> Usually people recommend crates designed to make the experience better but that's a failure in my opinion.

I agree, I love Rust, but I'd like to see error handling ergonomics improved.

I'd like to see error handling become more like Zig or Swift.

Until then, I cope with the `anyhow` and `thiserror` crate :|

throwaway234232··on Beginner's guide to error handling in Rust
> I would think the Err(err) => return Err(err) line needlessly constructs a copy of result

It sounds like this is coming from a C++ bias? So please forgive me if this is wrong.

Rust, in my experience, favors move semantics first, then copy semantics after.

I know in C++, we had implicit copy constructors, with move semantics after with rvalue references, where you need to use `std::move` in a lot of cases.

So what helps, in my opinion, is to think of Rust as using `std::move` as a default.

throwaway234232··on Go generics are not bad
I think this may be good reference material: http://learnyouahaskell.com/types-and-typeclasses

Basically I'm encoding this approach in Java.

throwaway234232··on Go generics are not bad
This is good news.

My wishlist for Java is for null to be illegal for all types unless they are encoded as nullable such as `T?`.

Until then, I just use Kotlin and/or Scala when I require JVM.

throwaway234232··on Go generics are not bad
Right, you can't overload the + operator, and primitives can't be used in generics.
throwaway234232··on Go generics are not bad
I think in Java, you would need to do a type-class approach.

    interface Numeric<T> {
        T zero();
        T add(T a, T b);
    }

    static <T> T sum(Numeric<T> n, T[] v) {
        T summer = n.zero();
        for (int k = 0; k < v.length; k++) {
            summer = n.add(summer, v[k]);
        }
        return summer;
    }