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

If your only example to show C++ verbosity fails to compile and is also patently wrong, you are not making a good point. (The constructor is private, the variable naming prevents short accessors such as Rectangle::width()). Better:

struct Rectangle { double x,y, width, length; };

int main() { Rectangle r = {0., 0., 10., 10. }; return 0; }

This even compiles in C++03. If you really insist on private members, you will need initializer lists and some changed member names.

The small example error has been worked around with for years by simply placing the constant on the left side of the comparison. Not pretty, but effective.

I agree with the general point, though. A functional style can make C++ much more efficient. It is also the only way to do template meta-programming and everybody who tries to go into that direction can benefit from learning Haskell.




Also found a def of type classes that i like: automatic instantiation + constraint propagation

http://blog.garillot.net/post/15147165154/every-single-fresh...


I should have mentioned those articles. They are a great example of Haskell influencing a C++ programmer. Although this article might show what the average C++ programmer thinks `using the type system`, `verbosity` and `influencing their style` mean.


If you replace Rectangle r with struct Rectangle r, your example even compiles in C89. :)




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

Search: