Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×

Comment Re:Jesus Christ... (Score 1) 595

Except that C++ has several features that inherently make it hard to pick up a piece of code and understand what it does. Yes, it's very 'nice' that you can define a new version of the same function by varying its parameters - when done consistently within a well designed class library. But it's sheer laziness to refactor existing code by counting on that feature. Have pity on the poor schlub that's ultimately going to inherit your code and try to support it.

To some extent, I think C++ is fine - as long as you code your application logic as if it were in C and restrict the C++'y stuff to the class libraries you use. That avoids the problem of programmers who barely understand what the C++ compiler is doing 'designing' classes that somehow magically work - most of the time.

1. I don't see what function overloading has to do with class libraries. Also, I use that feature extremely sparingly. I would imagine that people use coding standards when working on any large project and it would be trivial to forbid that. That is hardly an argument against the use of C++. The closest I come to using something like function overloading is occasionally having a single default argument.
2. Classes that magically work (All the time, of course!) are extremely useful and make code much shorter and far easier to understand. As with all languages, you have to understand the tools that you are using. The Linux kernel is full of hand-coded "virtual" functions, "destructors" and other simulated C++ features that would be more maintainable if coded in C++.

Finally, who says that everything in C++ has to be in a class? C++ is not Java and does not have the single "hammer", the class. Therefore not everything looks like a nail! In my code only about 10% of the functions that I write are class member functions. Yes, I frequently use instances of classes that I wrote, but mostly in regular plain, old functions. OOP is one tool in a large C++ toolbox. Procedural, functional and generic programming are others and all have their uses.

My top criteria are readability/maintainability and performance and not to use every nook and cranny of the C++ language as often as possible. The most esoteric feature that I occasionally use is probably defining my own iterators in classes that conceptionally can be viewed as some kind of container and, extremely rarely, a templatized class or function. I lead a team of developers that are far less experienced in C++ and pay attention to making sure that they can do code reviews of my code w/o asking me how something works most of the time. ;-)

Comment Re:Jesus Christ... (Score 1, Insightful) 595

C++ is tricky to get right in a kernel context because you cannot depend on garbage collection. When using something like STL, stuff gets scattered across more memory pools than desirable. Reallocation strategies have unknown semantics and timing.

1. What does garbage collection have to do with C++?
2. Where does it say that you have to use the STL in kernel code?

I used to program in C and still love the language. For years now I program primarily in C++, but also in Java, Python and PHP (Boy, do I *hate* this language!). I think that only idiots and masochist would prefer C over C++. C++ gives you far better abstraction capabilities. Destructors and const member functions are wonderful, just to pick two examples, and, if you understand how C++ works, you can get the same close-to-the-metal efficiency of C but with far fewer lines of code that is also safer and more reusable than the same thing written in C. It is much easier to write C++ code without memory leaks than to do the same thing in C. Finally RAII rocks.

Comment Re:Its the rightwingers who snowflake on religion (Score 1) 251

Right now it's open season on Christianity, but every other religion gets a pass.

I certainly don't feel that Islam is getting a pass right now even though many liberals are treating any criticism of Islam as "racism". Neither in the US nor here in Europe. I do suspect that you might be right concerning indigenous religions. Personally I don't know why people have warm and fuzzy feelings concerning indigenous people. Probably it's because they were and often still are victims of more technologically advanced cultures. What people tend to forget is that a) they are just as human as we are and occasionally just as nasty and b), being a victim does not make you a better person. (For idiots that try to read things into what I say that I didn't say: It also does not make them worse people.) Just look at how Israel is treating the Palestinians.

Just for the record: I am a liberal and "Fuck Hinduism, fuck Islam, fuck Buddhism and fuck $YOUR_RELIGION_HERE!"

Comment Re:Its the rightwingers who snowflake on religion (Score 1, Flamebait) 251

your religion

Which religion would that be? Let me guess: The only true one! How did you figure that out? Did you compare all the world's religions when you were a kid or did you just pick the one of the people who raised you or that you happened to interact with.

All religions are bullshit and no rational person should put up with any of them!

Slashdot Top Deals

"The four building blocks of the universe are fire, water, gravel and vinyl." -- Dave Barry

Working...