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

Yes, static typing provides a(n incomplete) form of testing. But the other thing that static typing provides is documentation. Compare these method signatures:

    def distance(a, b)
vs

    def distance(a: string, b: string): decimal
Would you have guessed from the first signature that I'm calculating the distance between two strings rather than the distance between two points? Or the fact that the returned distance can be decimal rather than strictly integral?

Yeah, I could name my function

    distance_between_strings_where_decimal_distances_are_allowed(a, b)
but it's more concise, just as effective, and compile-time-checked to write

    distance(a: string, b:string): decimal



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: