As another example, Java may let you get NullPointerException, but FindBugs detects a lot of those.
Depending on your editor of choice, you can get integrated pyflakes/pyling/flake8, e.g. I use vim and the syntastic plugin which is great.
This way, you get a bit of on the fly static checking without needing to remember command line tools/using vcs hooks, which is much more productive.
Thanks again.
> we've had runtime errors in Python code, due to [...]
> type error, something a compiler would have caught
Are wrongly spelled variable names and type errors the only runtime errors that you get? If not what percentage are they?Personally, I think that people tend to obsess about the specific type of errors because the 'solution' (static-typing) is something that already exists, whereas there is not easy solution to other types of flaws.
Missing imports and redundant imports also go away.
Lots of lots of invariants in the program can be encoded as types, too, so any bugs relating to them go away too.
When you want parallelism, you get useful guarantees about not changing the deterministic result you had before you added parallelism.
I used to use Python, but after Haskell, there's no way I'd go back...
> "NoneType has no attribute '...'"
C is statically typed, but I can still attempt to dereference a null pointer. Static typing doesn't save me here, nor does the compiler, as it's possible for these issues to happen at runtime.This may be something that Haskell doesn't allow, but it's not something inherent to static-typing.
But I totally agree, static typing is no cure for a wrong program. With power/expressiveness also comes a great ability to goof up.
On top of this, the C type system is not really about correctness at all. My understanding is that it primarily helps with performance, memory management (e.g. you know the size of stuff) and not accidentally using a non-pointer as a pointer. I'm not a C person, but C does not give off a vibe of caring about correctness.
In fact, C is particularly unsafe: you can get all sorts of fun things like bus errors and segfaults that are basically impossible in other languages. C definitely has a place, but only if correctness is much less important than performance.
You can ultimately come up with a sufficiently bad language for anything.
Also, the way Haskell avoids null errors like this is with the static type system. So while it's certainly not inherent to all static type systems (then again, nothing has to be inherent to static type systems except being verified at compile time), it is a property of the type system.
My original point was that it's possible that we (programmers) focus more on issues that could be with static typing (of some implementation) just because it seems like a group of problems that could be 'easily' solved. I.e. 'the grass is always greener'
The problem with C is that nullability is not statically typed.
I'm reasonably convinced that once my program has passed the typechecker, it is logically correct
Yup, this is one of my favorite things about Haskell, that's how I know that http://bpaste.net/show/32033/ is a totally correct program.Just as you should write good tests, that actually test for useful properties, so you should write good types -- and get useful proofs back from the compiler as a result.
[1] Isn't the old joke in Haskell "If your program compiles it probably does something someone would find useful, but not necessarily the useful thing you want"
Your point taken, but that is a problem in programming language X, which has Y type system, for all permissible values of X and Y.
In Google, in my project, we've had runtime errors in Python code, due to wrongly spelled variables(although that is a different problem), and type error, something a compiler would have caught.
Strong type checking is something that I truly like about Haskell and OCaml, I'm reasonably convinced that once my program has passed the typechecker, it is logically correct. Though debugging in Haskell is truly a different ballgame altogether (I'm a Haskell noob).
I'll stop here lest this turns into a flame war.