Hacker News new | ask | show | jobs
by openasocket 3774 days ago
The strong vs. weak typing axis is a more of a spectrum. Virtually every language has some form of weak typing, especially with the numeric types. I guess the litmus test for whether or not a given operation allows weak typing is if it is equivalent to implicit coercion. Languages like Java allow the operation "one" + 1, which is equivalent to "one" + (1).toString() (basically, you'd have to box the integer first to actually make this compile), so it is performing an implicit coercion, and thus an example of weak typing. In the same situation Python would throw an error, and is thus an example of strong typing.

That litmus test is probably not enough to make a true formal definition, but does allow you to make objective comparisons between languages for certain operations.

1 comments

By this definition, Julia is as strongly typed as possible: no automatic promotion or conversion is ever done for anything, including numbers. What appears to be "weak typing" is a clever application of multiple dispatch system with built-in fallback methods for numeric operations. See

http://docs.julialang.org/en/latest/manual/conversion-and-pr...