News for hackers. Stuff that matters.
Re:Why Crystal Is My Next Language by kazinator on Monday June 11, 2018 @10:43PM (#17290315)
I recently refactored my fork of the linenoise library (written in C) from char to wchar_t. C being statically typed made it easy to find all the places that need to be updated if some declaration is changed from the one type to the other. The editor gathers the compiler errors and takes you to all of them. The result was broken though. For instance, in some places I replaced strcspn (complemented span) with wcsspn instead of wcscspn. It has exactly the same signature. This was caught by testing all the edit operations, and a very careful diff review.

Type checking only works when you make a mistake which breaks a type signature. You can call entirely the wrong function with the right type signature. You can call sin instead of cos, or forget to take a log of something. You an swap the arguments to a subtraction: both are floats. Think of all the numeric code in which lots of variables, arguments, array elements and so on are all of the same type. Or string code in which there are numerous strings. Or OOP code where you have two or more objects in the same scope of exactly the same class, which can get mixed up.

The idea that you do not need a comprehensive test suite because you have static types is horribly wrong.

Re:Why Crystal Is My Next Language by atombender on Tuesday June 12, 2018 @06:24PM (#17298629)
C is not a great example here, because it's somewhat weakly typed. But it's true that typing doesn't fix the identical-arguments problem.