|
|
|
|
|
by d0mine
2049 days ago
|
|
A dynamic language is not just a statically-typed language where all type labels are removed -- it is the wrong mindset -- don't try to write Java programs using Python syntax. On type safety: Python is a strongly typed language unlike e.g. C: >>> "%d+%d=%d" % (2, '2', 4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: %d format: a number is required, not str
vs: #include <stdio.h>
int main(void)
{
return printf("%d+%d=%d\n", 2, "2", 4) < 0;
}
|
|
Also, is sprintf-style string formatting the best example here? I think that feature is type strict in a lot of languages, after all you are declaring the types you want in the formatting string. I imagine most implementations of % in dynamic languages pass to sprintf internally?