git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Dmitry Potapov <dpotapov@nbs-eng.ru>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marco Costalba <mcostalba@gmail.com>,
	Pierre Habouzit <madcoder@debian.org>,
	David Kastrup <dak@gnu.org>,
	Frank Lichtenheld <frank@lichtenheld.de>,
	Alex Unleashed <alex@flawedcode.org>, Kyle Rose <krose@krose.org>,
	Miles Bader <miles@gnu.org>,
	Dmitry Kakurin <dmitry.kakurin@gmail.com>,
	Git <git@vger.kernel.org>
Subject: Re: [OT] Re: C++ *for Git*
Date: Mon, 24 Sep 2007 01:22:39 +0400	[thread overview]
Message-ID: <20070923212239.GA7249@potapov> (raw)
In-Reply-To: <alpine.LFD.0.999.0709230911360.16478@woody.linux-foundation.org>

On Sun, Sep 23, 2007 at 09:54:10AM -0700, Linus Torvalds wrote:
> 
> And we do all of this in C. There is no need to go to C++ for any "object 
> oriented principles". It really is just a syntactic issue, and in many 
> ways the syntax "advantage" of C++ is actually a big *disadvantage*.

Certainly, in this respect, C++ provides only syntactic sugar over C,
and there is a real danger of abuse, which leads to horrible programs.
This is especially likely to happen to those who think that the evil
of C++ is lying in templates, exceptions, or something other feature
of C++, because they start to abuse the only "good" feature they know
and inevitably end up with horrible code.

> 	struct somestruct __user *p
> 
> to explicitly say that it's a pointer to user space - and then having 
> every function that takes that pointer have to have that "__user" there is 
> a VERY GOOD THING.

user_ptr<somestruct> p;

> 
> That's very different from having "accessor functions" and making "p" an 
> abstract type, and having the compiler automatically generate the right 
> kind of access. That kind of stuff is TOTAL CRAP, and it's an example of 
> how C++ has a horrible design, where you carry around _implicit_ knowledge 
> instead of making the knowledge explicit and visible locally too.

Whether it will convert to something or not depends entirely on the
definition of user_ptr. So, it can be as explicit as you wish, or
completely implicit. C++ does not impose anything on you here. So,
the problem is not in C++ but in the crappy mentality -- "let's hide
everything behind 'higher' abstraction" or "let's hide this thing too
because we can". Yes, these people end up with total crap. And yes,
those people tend to prefer C++ over C, just because C++ is better at
hiding. But I don't think that C++ forces anyone to do that...

> The same goes for things like memory allocation. Memory allocation issues 
> are often some of the *biggest* performance issues, and that means that 
> they have to be explicit. I'm actually a big fan of GC, but most languages 
> that implement GC do it exactly the wrong way in my opinion: they make it 
> a fundamental thing that covers everything, and it all happens implicitly, 
> instead of making it explicit.

Stroustrup was not a big fan of GC, so he made the language to be useful
in absence of any GC, and it allows to manage memory and some other
resources though not automatically, but with much less efforts than in C.

Maybe, your idea of more explicit GC is better than what C++ offers. It
is difficult for me to say without trying, but as you said most languages
implement GC in the wrong way in your opinion, so I don't think I will
have a chance to try any language that does it right. As to "caches" in
Git, it works really nicely, but Git is not a programming language.

> But other parts of C++ are just nasty. The whole OO layer seems designed 
> to do a lot of things implicitly and in the wrong way.

It could do a lot of things implicitly, but it does not force you,
except calling destructor when the control leaves the scope of
declaration, but I hardly can consider it as implicit.

> I also disagree with exception handling,

Perhaps, you look at it from the kernel point of view. Otherwise, I
would like to hear your arguments against it. In fact, I don't think
it is possible to write generic algorithms without exceptions. Of
course, if you write a program that can print an error to stderr and
exit, there is no much need for them. So, it may depend on the task.

>  - the stuff C++ *does* have is usually nasty. Implicit initializers and 
>    destructors and the magic lifetime rules of objects etc

I am not sure what is wrong with initializers and destructors in C++,
but certainly there is no magic lifetime rules in C++, as it is fully
determined by the scope. In fact, other high level languages that use
GC have much more unpredictable lifetime rules for objects.


Dmitry Potapov

PS Please, do not confuse me with Dmitry Kakurin, who started this
thread, because my position is opposite to his. Though I like C++,
I fully understand most of your consideration in choosing C for Git.

  parent reply	other threads:[~2007-09-23 21:30 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-22 10:42 C++ *for Git* Dmitry Kakurin
2007-09-22 11:11 ` David Kastrup
2007-09-22 12:48 ` Johannes Schindelin
2007-09-22 15:23   ` Marco Costalba
2007-09-23  4:54     ` Dmitry Kakurin
2007-09-22 15:15 ` Kyle Rose
2007-09-22 18:08   ` Miles Bader
2007-09-22 18:25     ` [OT] " Kyle Rose
2007-09-22 19:11       ` David Kastrup
2007-09-22 22:50       ` Alex Unleashed
2007-09-23  2:09         ` Frank Lichtenheld
2007-09-23  6:25           ` David Brown
2007-09-23  7:23             ` David Kastrup
2007-09-23  9:29               ` Marco Costalba
2007-09-23  9:42                 ` David Kastrup
2007-09-23  9:50                   ` Marco Costalba
2007-09-23 10:45                 ` Pierre Habouzit
2007-09-23 13:42                   ` Marco Costalba
2007-09-23 14:23                     ` Nicolas Pitre
2007-09-23 14:45                       ` Marco Costalba
2007-09-23 14:37                     ` David Kastrup
2007-09-23 15:15                       ` Marco Costalba
2007-09-23 17:49                       ` Paul Franz
2007-09-23 16:54                     ` Linus Torvalds
2007-09-23 18:05                       ` Marco Costalba
2007-09-23 18:30                         ` David Kastrup
2007-09-23 18:43                           ` Marco Costalba
2007-09-23 19:11                             ` David Kastrup
2007-09-23 21:22                       ` Dmitry Potapov [this message]
2007-09-23 21:31                         ` David Kastrup
2007-09-23 23:10                           ` Robin Rosenberg
2007-09-23 22:25                         ` Reece Dunn
2007-09-24 10:46                           ` Dmitry Potapov
2007-09-22 22:24   ` Martin Langhoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070923212239.GA7249@potapov \
    --to=dpotapov@nbs-eng.ru \
    --cc=alex@flawedcode.org \
    --cc=dak@gnu.org \
    --cc=dmitry.kakurin@gmail.com \
    --cc=frank@lichtenheld.de \
    --cc=git@vger.kernel.org \
    --cc=krose@krose.org \
    --cc=madcoder@debian.org \
    --cc=mcostalba@gmail.com \
    --cc=miles@gnu.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).