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

Right, but it's also much simpler and faster for the programmer to write one function with one return type, and later modify it to add a return type if the requirements change. I think this is obviously why dynamic languages rose in prominence coincidentally with the rise in rapid prototyping and agile development. That said, this is also why large companies with codebases that need to be maintained over multiple decades will always go with static languages.

What really interests me are languages like Julia or Dart, with their gradual typing, or Clojure and core.typed. You retain the flexibility and speed of development of a dynamic language, with the possibility of later adding type safety guarantees to your code without having to rewrite it from scratch.



> it's also much simpler and faster for the programmer to write one function with one return type, and later modify it to add a return type if the requirements change.

How is this different? When you compile, your compiler will say "Hey, the requirements have changed, your code is wrong here, here, here, and here," and you modify those things, and you're done.


....and then you've forgot what you were actually trying to solve.


What is the alternative? You change the code, the behavior gets changed but the compiler doesn't warn you. At this point you have two possible paths:

1- You wrote tests which start failing. You must now spend time changing them. You don't manage to avoid working in order fix your safety net (be it static type checking or your test suite).

2- You didn't write the right tests, and don't notice the change in behavior. The program later fails in production.


Why? Aren't you trying to solve the change in interface? And wouldn't you be making the same changes in a dynamically typed language?


I find the type system a great help with remembering what I was actually trying to solve. I can "start at the end" and then work backwards, solving one compile error at a time until there aren't any left, at which point I'll know I've done what I wanted to.




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

Search: