Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't know Haskell, but I do know OCaml, a strongly, statically-typed language with type inference. OCaml does avoid a lot of the pitfalls of C++, but it shares the problem of difficult to decode error messages. Oh boy, does it ever.

Adding explicit type specifications helped a little bit. Adding parentheses around everything helped a little bit more. For some reason, the parentheses trick seems to be little-known online, but it's something I really had to do sometimes in OCaml. I once spent a half hour trying to figure out why a file was getting a parse error at the end. I eventually did a kind of binary search, commenting out half of the file at a time until I could narrow it down. It was a missing brace halfway through. The problem is that without the need to put all functions in the top-level, things just float in a sea of declarations, and if two things are next to one another, it's assumed to be curried... and so your error message about a missing brace shows up on a line number far removed from the actual problem.

It's possible that with more development effort put into the language, OCaml and other functional programming languages would have better compiler error messages. It's also possible that there's just a fundamental difficulty trying to teach a profoundly stupid computer to give reasonable error messages about a super-clever system. Hopefully the popularity of functional languages like Scala and OCaml will give us a chance to find out the answer to tihs.



Clang has excellent error messages for C++ - it even spellchecks your code and can suggest the function you meant to type when you typo something. So this is almost certainly a case of development effort, and not something intrinsic to the type system.


Yeah, clang's error messages are excellent, especially given how difficult C++ is to parse, let alone compile. However, they are still not as good as Go's. And try doing the kind of automated source transforms that Go can do with "go fix." IDEs for C++ are still fairly limited due to things like conditional compilation, unit-by-unit compilation, macros, etc. etc. You can make a pig fly, by shooting it out of a cannon, but ultimately it is still a pig.

I've been meaning to try the clang plugin for vim... context-sensitive autocomplete for C++ would be nice.


Oh, Haskell can have it's share of weird error messages. But generics are not really a source of them.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: