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

Haskell's lambdas are extremely elegant (\args... -> code, and treated no differently to any other function), but C++ has a pile of other considerations that Haskell doesn't have to worry about, due to Haskell's uniform representation and garbage collection.


I think that functions and closures are fundamentally different types. Haskell does implicit type erasure whereas C++ does not. Most of the time in C++ when you use lambda you don't need uniformity and you are better off using templates to pass them around. For the rare circumstances you do need this, you just stick it in a std::function. Haskell also has mechanisms that could handle this: type classes/parametric polymorphism/existential types and I would find this a much cleaner approach, but it would wreak havoc with other design decisions in the language such as currying. My main point of this is that Haskell proponents often think of C++ programmers to be unenlightened or wilfully ignorant, when its actually very possible they have thought things out and simply reached different conclusions.




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

Search: