Live data from Hacker News

Linus Torvalds on C++

harmful.cat-v.org

31–40 of 190 posts

Re: Linus Torvalds on C++

#31
post #26

Earlier quoted context omitted.

How many distributed version control systems have you worked on and released to the public? Any worth critiquing?

Had he worked on any would that have been a valid excuse to be derogatory to others over something as childish as what programming language they use? If you're going to ask me if I had worked on any OS kernels or distributed version control systems, the answer is no. But I would also never degrade people who might otherwise be willing to help contribute to my projects based on some idiotic notion of programming langu…

Hint: someone saying that you should rewrite your project in his own favorite language is NOT someone that you should allow to help or contribute.

Re: Linus Torvalds on C++

#32
post #20

Now 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…

STL containers are essentially the opposite of what's used in many C programs, Linux kernel included.

In C, in order to string several data items into a collection one would add a container-specific control element to the data item, and then feed a pointer to this element to the container code. Container sees only these elements, and nothing else. On one hand, accessing actual data item obviously requires casting and offsetof'ing, but on other hand it allows placing the same data item into multiple containers, and this is great. Think - multiple key-value stores, each keyed by a different field in data item. Generally speaking, the paradigm is that there are THE data items, and there are miscellaneous supporting structures that help organizing tehm.

In C++, container is the ultimate destination for a piece of data. It is the owner of a data item. If I want a piece of data to be on a list and in a tree, I must decide which will be the "primary" container. Alternatively, I can store a pointer to an item, but this effectively negates safety benefits of STL containers.

[0] http://kernelnewbies.org/FAQ/LinkedLists

Re: Linus Torvalds on C++

#33

Linus is probably the %1 of people in the world who actually needs to get the performance gain that C has over C++ - as for the rest of us? Probably doesn't matter.

> needs to get the performance gain that C has over C++ With RTTI and Exceptions disabled you should be able to get almost identical performance with C and C++. In some cases C++ compiler has additional information that can allow it to produce faster code as well.

Yup, and if you avoid using any of the new language constructs like objects and whatnot that C++ brings and basically stick to standard C, maybe using just a bit of C++ sugar here and htere, true.... but at that point you might as well be using C, and the argument is really moot.

Re: Linus Torvalds on C++

#34
post #17

Linus's objections seem centered on the fact that it makes it easier to generate bloated code. While this may be true, there's nothing a little self-discipline can't control. STL and Boost may not make sense for the kernel, but there's nothing wrong with using C++ classes at their most basic. The kernel would be far more readable if it used classes and simple inheritance rather than re-inventing the wheel with struct…

It's also based on experience. For a while, he was convinced to at least compile the kernel with the C++ compiler.

The experiment didn't last long.

Re: Linus Torvalds on C++

#35
post #30
post #14

Earlier quoted context omitted.

If I understand what proponents of C++ say, C++ is supposed to be suited best for medium-level programming where abstraction is helpful but low-level constructs and speed are still helpful. It's supposed to give you many of the benefits of higher level languages while still giving you high performance. It's intended to be widely portable but still easily hook into special OS-specific facilities. This description soun…

It's that "if properly managed" bit that would be a nightmare from hell to manage... easier to just do it in C. What it's intended to do is rather different than what it's actually used for in real life..... code talks, anything else is just smoke, right? IF someone can come alnog and show us a better way in any language, then tehre's something to argue about, otehrwise, the guy who has working code wins over the guy…

I guess what I'm really interested in here is, if git isn't an appropriate project for C++, just what is?

Re: Linus Torvalds on C++

#36
post #31
post #26

Earlier quoted context omitted.

Had he worked on any would that have been a valid excuse to be derogatory to others over something as childish as what programming language they use? If you're going to ask me if I had worked on any OS kernels or distributed version control systems, the answer is no. But I would also never degrade people who might otherwise be willing to help contribute to my projects based on some idiotic notion of programming langu…

Hint: someone saying that you should rewrite your project in his own favorite language is NOT someone that you should allow to help or contribute.

Torvalds' post to me looked to attack C++ programmers in general. I'm not ignoring that the initial comment was pretty useless, but even so there are better ways to handle those than the way he chose.

Re: Linus Torvalds on C++

#37
post #22
post #17

Linus's objections seem centered on the fact that it makes it easier to generate bloated code. While this may be true, there's nothing a little self-discipline can't control. STL and Boost may not make sense for the kernel, but there's nothing wrong with using C++ classes at their most basic. The kernel would be far more readable if it used classes and simple inheritance rather than re-inventing the wheel with struct…

"...rather than re-inventing the wheel with structs full of function pointers." I think you got that backwards. Structs full of function pointers predate c++. Going for the ad absurdum, why bother inventing C++, it's just a re-inventing of the structs full of function pointers wheel?

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.

Re: Linus Torvalds on C++

#38
post #31
post #26

Earlier quoted context omitted.

Had he worked on any would that have been a valid excuse to be derogatory to others over something as childish as what programming language they use? If you're going to ask me if I had worked on any OS kernels or distributed version control systems, the answer is no. But I would also never degrade people who might otherwise be willing to help contribute to my projects based on some idiotic notion of programming langu…

Hint: someone saying that you should rewrite your project in his own favorite language is NOT someone that you should allow to help or contribute.

Doesn't mean he should insult them ... at some point in a person's life, they should be above that, but that's just my opinion.

Re: Linus Torvalds on C++

#39
post #9

Earlier quoted context omitted.

I think we're missing the point here. Taking the side of the customer of git, I'm happy. I type things on a CLI with git and things happen pretty fast. I'm happy. I don't care whether you wrote it with C, C++ or Haskell. It works. It works just fine. To Linus's point, I've never used, or even heard of someone using Monotone. That must say _something_.

I've used Monotone. It's pretty horrible if you ask me.

It has nothing to do with the fact that it is written in C++...

Re: Linus Torvalds on C++

#40
post #20

Now 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…

STL containers are essentially the opposite of what's used in many C programs, Linux kernel included. In C, in order to string several data items into a collection one would add a container-specific control element to the data item, and then feed a pointer to this element to the container code. Container sees only these elements, and nothing else. On one hand, accessing actual data item obviously requires casting and…

That was a fantastic link. I love the kernelnewbies site.
Post reply on HN