No, they're just the kind of logic errors you get while trying to really understand the problem you're dealing with. |
Ok, agreed. These errors are unavoidable. I was speaking of "the code doesn't do what I think it does" kind of bugs. It is just nice to have some classes of bugs made impossible. Impossible is still better than infrequent (however I still claim that typing bugs are quite common - my compiler catches me quite often - probably some of these bugs would be ok, but some of them would manifest themselves in the least excpected moment).
The fact that you don't get the error until you try to run the code is not much of a problem if you keep your unit tests up to date, which you should anyway |
This is nice in theory. But I have yet to see a project that has up to date unit tests with good code coverage after a year or two since its start. ;) Anyway, static types help not only with catching bugs. Some other reasons for static typing are:
1. IDE autocompletion support
2. Performance
3. Documentation
Don't get me wrong: I find Python a great scripting tool for administrative tasks or smaller projects, however for larger things that have to scale with respect to number of modules and programmers engaged, I prefer something statically typed. Scala and Clojure have almost all advantages of Python (except fast startup), you write the code just as fast, it is just as short, but you additionally have all benefits of static typing.
@Rapidcoder, it is slightly faster to get the job done in java, but you're code will be slightly slower at run time |
Yes, but this
usually doesn't matter as much as getting job done faster. Also, getting job done faster means more time and budget for code optimisation, like employing harder to write but better algorithms.
A simple example: Bekeley SPICE simulator, written in C, builds a Jacobian matrix for equations created from the circuit. Then it inverses this matrix for every sample, which costs about O(n^1.2). We work on a piece of software written in Java that analyses the circuit symbolically and builds a matrix only for the part that could not be symbolically reduced. This is of course lot faster than SPICE, because the matrix is much smaller. Probably our matrix inversion code is slower than the C-version for the same matrix, but it is given a 3 times smaller matrix and it wins.
Back to the original topic: I think that you can learn a lot from trying to optimise some larger piece of code, but without breaking its readability (no manual loop unrolling or things like that allowed). By doing this, you often come the conclusion, that the most clear design was also the easiest to make fast. At least I came to such conclusion many times...