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

In theory.

In practice, I found that translating from OCaml to C++ is often painful, while the reverse is quite easy. When I deal with generic code, this difficulty is largely attributable to the differences between Hindley-Milner and templates.

My conclusion is that where it really matters, C++'s templates are less flexible than OCaml's genericness. I dare you to try and prove me wrong with production code without being fired… upon.



First, I think it's important to note that as the original claimant here, the onus is on you to prove your claim, not on me to disprove it. If you think OCaml's "easy genericness" is "more flexible than C++ templates" then provide an example of the exercise of such flexibility.

Second, ease of translation between languages is not particularly relevant to flexibility. Insofar as it is relevant, things that are more flexible are typically more difficult, not easier, on account of that flexibility, at least in my experience.

Remember, your original claim was not about ease, but about flexibility. I doubt you attempted the subtle transition maliciously, and perhaps your original claim was where you misspoke, but I would never argue that C++ templates are easier than other forms of genericity, simply that they're more flexible.




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

Search: