News for hackers. Stuff that matters.
Re:Code is Engineering, Types are Science by kortex on Sunday June 27, 2021 @03:24PM (#27654446)
Taking the opportunity to point out, with most inferred type languages (mypy python, go, TS, rust, scala), you often don't have to write variable types at all, only functions. Gone are the days of `Foobar foob = new Foobar`, heck C++ has had `auto` for a decade.

So have your dynamic language functions you have to document (you do document your code right?), why not just use types instead? I'd far rather see

    def frob(data: np.ndarray) -> float:
      <code with no docstring>

than

    def frob(data):
      """takes an array and frobs it to give the frobitude score"""
Like, idk about you, but the former is way better at "self documenting" and you can do all kinds of automatic operations on it. If things are ill-defined and quickly shifting, I can mypy and flake my way to make sure the stack works without bricking something. If I have human docs, that's far more likely to drift out of date.
Re:Code is Engineering, Types are Science by aYsY4dDQ2NrcNzA on Sunday June 27, 2021 @05:08PM (#27655373)
At least call it frob_score.