News for hackers. Stuff that matters.
Re:Why I Chose to Learn C by duaneb on Friday March 29, 2013 @03:26PM (#5462536)
I am a diehard fan of C, and even I think that C++ is preferable past a certain size of program. Classes and templates are far too powerful to not use; just consider things like `scoped_ptr`. Just because C++ has nasty parts doesn't mean you have to use them, in my experience most of my worst experiences with C++ come from reading other peoples' code (Boost.Spirit, I'm looking at you).
Re:Why I Chose to Learn C by rayiner on Friday March 29, 2013 @03:31PM (#5462563)
I'm going to be a contrarian, and say that I've just never found a program that was more readable with classes. Classes tend to rip up your algorithms to shreds and spread them over dozens of different files, which is really painful.

I've been reading through the code in libfirm lately and it's incredibly refreshing. A pass is usually in a single file (how novel!) instead of being scattered around because of the visitor pattern.

Re:Why I Chose to Learn C by duaneb on Friday March 29, 2013 @10:47PM (#5464150)
Really? Classes never made source more readable? How on earth is `Vector<Int64>` or whatever less readable than rolling a custom struct and functions?
Re:Why I Chose to Learn C by rayiner on Friday March 29, 2013 @11:24PM (#5464219)
Basic logic error (that it doesn't make things more readable doesn't mean that it's less readable).

I just don't see the big readability win going from vector_push_back(my_vec, 53) to my_vec.push_back(53)

Re:Why I Chose to Learn C by duaneb on Saturday March 30, 2013 @12:03PM (#5465767)
Oh, well the dot syntax is just, well, syntactic sugar, and arguing that THAT is the reason anyone (who knows what they are doing) uses C++ is silly. It's because of inheritance and DRY so you write less code.
Re:Why I Chose to Learn C by rayiner on Saturday March 30, 2013 @01:01PM (#5465961)
Right, and my point is that I've never seen a situation where inheritance really makes things dramatically clearer versus the alternatives (indeed, the mantra in C++ these days is that you should have "has-a" relationships with composition versus "is-a" relationships with inheritance).

I think inheritance/OOP encourages you to draw module boundaries in the wrong place. It encourages you to spread the logic of an object over several modules of code. If you find yourself using inheritance, you'd better ask yourself: could I instead abstract my base class into a self-contained object that my new object could hold a reference to?

See: http://www.paulgraham.com/noop.html