3 ms·
> Folks who prefer dynamically-typed languages are generally of the opinion that working with compiler error messages sucks. I think a big factor here is dynam
by seanwilson 4y ago
> Folks who prefer dynamically-typed languages are generally of the opinion that working with compiler error messages sucks.
I think a big factor here is dynamic languages can show concrete variable instantiations to help you understand what went wrong so it's less abstract e.g. the code `plus x y` might give the runtime error "x was 'abc' which is type String and not type Number" vs something more abstract and confusing like "x is type String and not type Number" that you tend to see in compile-time errors.
Are there any languages that give concrete variable instantiation examples as part of compile-time error messages? For instance, example values could be generated from the types, come from previous program runs, or supplied by the coder somewhere.
When errors get tricky, you tend to start plugging in concrete values or stepping through the program manually so compilers could definitely help more here.
- ygaitonde 4y agoIn OCaml, if your pattern match is non-exhaustive, then the compiler generates example patterns that you aren't accounting for in addition to showing the missing type. Here's an example: https://stackoverflow.com/questions/22737031/this-pattern-matching-is-not-exhaustive-in-ocaml https://stackoverflow.com/questions/22737031/this-pattern-ma...