I wonder what Linus thinks about Objective C as another as an alternative approach to Object Orientation in C. IMO Objective C gets much farther in implementing polymorphism and dynamic binding than C++ can even dream of. Although I hear good things about Boost, I think thats like patching the language instead of fixing the fundamental flaws in its design.
"fundamental flaws in its design" It would be pretty hard to fix them without breaking backward compatibility.
Linus Torvalds on C++
81–90 of 190 posts
Re: Linus Torvalds on C++
#82Although it is true that certain languages give you the flexibility of writing "utter crap", I can also write pretty crappy unmaintainable code in pure C just as easily. Nevertheless, after 14 years of coding in C++, I love how beautiful my C++ code comes out. All that "OO crap" makes my code easier to understand, debug, maintain and extend. I would take that at the expense of how much more difficult it is to create…
Every time I conclude that all I'd gain in the process is the extra work of finding some third party collection library, adding manual resource management where I currently use RAII, and rolling my own struct-based object system, probably with a buch of macro glue.
I don't see how this makes my life any simpler.
Re: Linus Torvalds on C++
#83Now this has me a bit confused, why no love for STL ? I wish Linus had added more detail. Is the complaint that the binaries are too big (not quite, if you strip them of the unnecessary symbols) ? or is it that it can be a tedium to go over the reams of error messages that compilers spit out when things go wrong. The second point I am willing to concede, it requires you to read messages inside out, which lisp does tr…
On one hand, it's not particularly good for really low level coding, as other people have explained.
But on the other hand, it's not really convenient for higher level coding, either.
To see what I mean, compare the interfaces of std::string [1] and Qt's QString [2]. Common, simple things like converting numeric data to/from string, splitting into substrings, and find/replace are a PITA in the STL. The containers are nice, but even they could use some work.
I know it'd never happen, but I think the non-GUI parts of Qt would make a really nice standard library.
[1] http://www.cplusplus.com/reference/string/string/ [2] http://developer.qt.nokia.com/doc/qt-4.8/qstring.html
Re: Linus Torvalds on C++
#84Earlier quoted context omitted.
You're right - "re-inventing the wheel" is probably the wrong phrase - I used it because it conveys a sense of needless effort when there is a better alternative. Basically, those who don't have access to basic object-orientation are doomed to implement it themselves in a messier, more verbose form.
I think the argument that Torvalds was making here is that that's exactly what C++ is. Messy and unnecessary. You can write C++, but if you do so without the mess, you're so close to C that there's no point in using C++. I, on the other hand, would argue that C's lack of object-orientation somehow dooms one to implement it. OOP is _not_ the pinacle of software development. Further, I would argue that "structs full of…
struct obj
{
struct obj_functions* functions;
...
}
struct obj_functions
{
void (*do_something_with_object)(struct object* obj,...);
...
}
... I'd say it's hard to argue that you're not implementing C++ style OOP, and that it wouldn't be cleaner to use C++.Now, if you're just going to stick to the basics of C++ (ie. avoid templates, operator overloading, etc...), then there's a fair argument as to whether it's worthwhile. Certainly it's not worth rewriting the Linux kernel at this point.
But, I don't think Linus's comment that "C++ is a horrible language" is fair.
(I'm sure most of that is just Linus being Linus).
Re: Linus Torvalds on C++
#85Probably Linus is right that C++ does not belong in the kernel but for application level code reinventing all the basic C++ things in C seems like a waste of time. Linked lists, virtual methods, some form of exception handling.. why waste your time? I laughed pretty hard when I understood how the linked list implementation in the Linux kernel works (pointer arithmetic tricks + sizeof). People don't even invent anything different from whats already in C++.
The key to using C++ is to find a comfortable subset and stick with it. I haven't used C++ on projects with more than 3 people yet so I don't know the pains of agreeing on exactly which subset to use but I imagine it could be done.
Re: Linus Torvalds on C++
#86Has anyone really not seen this in the last two years? Anyway, Linus may be a very experienced C programmer, but that doesn't mean his opinion on C++ carries much weight... I'd be more interested on what someone who actually has a lot of experience in using C++ says. Especially with modern C++ and recent tools, libraries etc, which are very different from what was around five or ten years ago. I suppose it is nice fo…
Re: Linus Torvalds on C++
#87This saddens me as C++ is growing into such a beautiful language. C++11 is a major step forward, and I don't really buy in to complaints that are not about the current standard. Bad programming is language agnostic. Disliking a language generally implies that you don't know enough about it to really get it.
Re: Linus Torvalds on C++
#88Earlier quoted context omitted.
AAA games, browsers... Really, anything where you need to have some abstraction but performance is still critical.
There's a large faction in AAA games that thinks C++ is a stupid idea. It's debatable who's right in that debate, but good points are being raised. The problem is not so much that C++ is a worse language than C - it's that it makes it insanely easy to shoot yourself in the foot in hideously complex ways that take forever to unravel. See e.g. two phase name lookup - http://blog.llvm.org/2009/12/dreaded-two-phase-name-…