3 ms·
"Unit-Testing" became popular about the time of Extreme Programming. The reason I think it became so popular was that its proponents programmed in dynamically t
by galaxyLogic 2y ago
"Unit-Testing" became popular about the time of Extreme Programming. The reason I think it became so popular was that its proponents programmed in dynamically typed languages like Smalltalk, and later JavaScript. It seems to me that synamic languages needs testing more than statically typed ones.
- Jtsummers 2y agoBeck's first xUnit framework was SUnit, for Smalltalk, but Beck's second take was JUnit, which is for Java. Java was and still is a statically typed language. Tests are there to detect logical correctness of the unit under test, very few type systems can catch errors like using - instead of + in a mathematical formula, for instance. You either need to go into dependently typed languages or languages that otherwise permit embedding proofs (SPARK/Ada).
- YZF 2y agoIn dynamic languages tests also tend to fill the role of the compiler is I think the parent's point. Dynamic/interpreted language code might have syntax errors or be otherwise incorrect (including type errors) and you often don't find those until they code is run.
- dgb23 2y agoThat’s a fair point. However dynamic languages tend to have very good linting that catch many basic type errors. They can also run way more often during development, down to the function/expression level.
- igouy 2y agoWhen this buggy method is compiled (not run) with Smalltalk, errors and warnings are shown. The code cannot be run because it failed to compile. hnQuestion | list max | list := #(1 8 4 5 3). ! Syntax Error: Nothing more expected 1 to: list size do: [:i | max < (list at: i) ? Uses ifTrue:/ifFalse: instead of min: or max: ifTrue: [max := (list at: i)]. ifFalse: [max := max]. ].
- Izkata 2y agoFor future reference, indent with 2 spaces to get code formatting. https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc
- igouy 2y agoFor future reference, does "code formatting" provide a way to distinguish list := #(1 8 4 5 3). from ! Syntax Error: Nothing more expected as-well-as from comment text ?