Sponsored Link •
In Python variables are never explicitly typed. I consider this a Very Bad Thing.
There is a belief floating around that implicit typing makes programming easier to do and learn. I think this is rubbish. In order to explain why the following Python code is bad to a beginner you still have to explain the concept of types:
>>> x = 12 >>> y = "13" >>> x + y TypeError: cannot concatenate 'str' and 'int' objectsThe error message is hard for a new programmer to understand because str and int aren't tangible. My next beef is that accidental type conversions is one of the most common error I see programmers make while developing code in implicitly typed languages like VBScript and Python. It is inefficient to have to track these down by first running the program, and having to test every single corner of the code. Static typing eliminates the need for type testing. In the end I see absolutely no advantage circumventing the few keystrokes it takes to explicitly write:
string x = "12" int y = 13
Now when the programmer writes: x + y the inevitable type-error message that results is no longer something cryptic.
In the relatively rare case a programmer truly needs a variant type, it is easy enough to just use something like the object type in Heron, the cdiggins::any type in C++, and so on.
Anyway that forms the basis for my justification for explicit typing in HeronScript, and why I wouldn't teach an implicitly typed Python as a first language.
|Christopher Diggins is a software developer and freelance writer. Christopher loves programming, but is eternally frustrated by the shortcomings of modern programming languages. As would any reasonable person in his shoes, he decided to quit his day job to write his own ( www.heron-language.com ). Christopher is the co-author of the C++ Cookbook from O'Reilly. Christopher can be reached through his home page at www.cdiggins.com.|