3 ms·
The main thing that make programming in statically typed languages painful isn't the additional type declarations (which, as you rightly point out, need not eve
by gnosis 16y ago
The main thing that make programming in statically typed languages painful isn't the additional type declarations (which, as you rightly point out, need not even exist in languages that do competent type inference), but with the constant need to wrestle with the type system to get your code to compile at all.
This is made doubly painful by the incredibly obtuse error messages spat out by some compilers, like:
This expression has type ((int * int) * string * string * channel) list
but is here used with type ((int * int) * string * string * channel) list
or even more baroque and confusing monstrosities.
Programming in OCaml made me feel like I'd need to take years of type theory classes in order to feel really comfortable in the language.
In comparison, programming in Lisp is a joy, and very easy.
But, in defense of the modern statically typed languages like OCaml and Haskell, I'll have to admit that once you've finished wrestling with the type system and actually gotten your program to compile, you've probably eliminated whole classes of bugs that might still exist in a similar dynamically typed language program. Not to mention that it will save you the writing a ton of unit tests.
- mquander 16y agoThat's a very optimistic error message! error: conversion from std::_Rb_tree_const_iterator<std::pair< const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > to non-scalar type std::_Rb_tree_iterator<std::pair< const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > requested
- shadowfox 16y agoInterestingly enough, the sort of error messages that you mention in OCaml occurs partly due to the inference itself. Because inference is essentially a unification between implicit constraints, once it finds an anomaly, the engine can't always predict correctly which among the conflicting constraints is the actual error from a user point of view. Anyway just an aside