4 ms·
Unit testing is not mutually exclusive with static typing. Normal statically typed projects have unit tests too. The biggest advantage of static typing, in my
by watwut 9y ago
Unit testing is not mutually exclusive with static typing. Normal statically typed projects have unit tests too.
The biggest advantage of static typing, in my opinion, is that simple refactorings like "rename" or "move method from one class to another class" or "change what method does and then modify all places that call it" are done routinely and very often. Where renaming something in javascript is careful change you do when fully fresh, rested and focused, it is one quick right click when you are lazy and too tired to do real work in statically typed code. Means difference between rarely done and often done.
The other big advantage is when I am learning somebody elses code, all info about who calls who and how is right there.
- flavio81 9y ago>The biggest advantage of static typing(...) or "move method from one class to another class" You are posting about static typing advantages. Please note that the use case you mention would not need too much refactoring in languages like Common Lisp (dynamic language) or Julia (dynamic), because of multimethods and because of the way methods are called. Methods -and method signatures- aren't constrained inside class definitions, they are separated.
- watwut 9y agoJavaScript does not have multimethods and methods are called on objects. It sounds like methods must be purely functional and not use any instance fields. The use case I had in mind was that I delete method from one class and create it in another. Then I go through all red in workspace and modify what is needed - sometimes just call the other place, other times remove the call entirely, yet other times conclude that method needs to go back because that two special places that don't have access to the other class instance. Similar with changing signatures - I add/remove parameters and then go through all reds and decide how to fix them case by case.
- skybrian 9y agoThe kind of refactoring you need to do depends on the language, but it seems like multimethods will have their own issues. I don't have experience with this, but suppose you decide to split a multimethod into two separate operations because on second thought, they shouldn't have the same name after all? How do you fix all the callers?
- zeveb 9y ago> The biggest advantage of static typing, in my opinion, is that simple refactorings like "rename" or "move method from one class to another class" or "change what method does and then modify all places that call it" are done routinely and very often. Note that this is very doable in a dynamic language environment like Smalltalk or Lisp: you're constantly interacting with the running system, and so can easily rename a function or method, update all source locations, update the class of live instances (e.g. UPDATE-INSTANCE-FOR-REDEFINED-CLASS[0]) and even change the class of live instance (e.g. UPDATE-INSTANCE-FOR-DIFFERENT-CLASS[1]). > The other big advantage is when I am learning somebody elses code, all info about who calls who and how is right there. Again, a live environment is capable of tracking all callers & callees. It's pretty awesome, and honestly the only way I'd prefer to develop. [0] http://clhs.lisp.se/Body/f_upda_1.htm http://clhs.lisp.se/Body/f_upda_1.htm [1] http://clhs.lisp.se/Body/f_update.htm http://clhs.lisp.se/Body/f_update.htm