2007-05-04 08:32:29

by la deng

[permalink] [raw]
Subject: c 's OOP in VFS vs c++'s OOP

reference to the c++'s father's interview

http://www.artima.com/intv/abstreffi.html

fortran and c++ can achive good performance for they can abstract in
higher level and their compiler can think in higher level to avoid
the cache miss (like in the array vs vector )or to achive the "no
code" Optimization

The vfs using c to OOP but c compiler can't have the high level
Intelligence as the c++ or fortran's compiler to help at the high
level Optimization


one benchmark showed the c insert in the array will slow by speed of 1/17


Then ,what's the power of c OOP vs c++ with the compiler's
Intelligence in OOP?or maybe the c compiler have Outdated?

any input will be appreciated.


2007-05-04 11:00:18

by la deng

[permalink] [raw]
Subject: Re: c 's OOP in VFS vs c++'s OOP

On 5/4/07, WANG Cong <[email protected]> wrote:
> On Fri, May 04, 2007 at 04:32:27PM +0800, la deng wrote:
> >reference to the c++'s father's interview
> >
> >http://www.artima.com/intv/abstreffi.html
> >
> >fortran and c++ can achive good performance for they can abstract in
> >higher level and their compiler can think in higher level to avoid
> >the cache miss (like in the array vs vector )or to achive the "no
> >code" Optimization
> >
>
> Well, it seems

that you are a zealot of OOP. I admit OOP is really a good idea and a
good abstraction. And that's the reason why we borrow it in. Of
course, OOP in C is not true OOP. (Maybe we can call it pseudo-OOP.)
>
> >The vfs using c to OOP but c compiler can't have the high level
> >Intelligence as the c++ or fortran's compiler to help at the high
> >level Optimization
> >
>
> We just borrow the OOP ideas from OOP languages, like C++/Java/Python, but we can't use any of them. The reasons can be summarized as the following:
>
> 1. Those languages, like C++, hide many things behind you. But kernel needs to know those things.
> 2. Those languages can't be (well) mixed with assembly.
> 3. Speed is crucial for kernel, while those languages can't surpass C.
>
> >
> >one benchmark showed the c insert in the array will slow by speed of 1/17
>
> What benchmark? If your algorithm is well designed, C can't be more slowly.
>
> >
> >
> >Then ,what's the power of c OOP vs c++ with the compiler's
> >Intelligence in OOP?or maybe the c compiler have Outdated?
> >
>
> C compiler is _not_ out of date, of course. Why we choose OOP in C is explained above.
>
> In a word, we choose OOP because it's a good idea like you wanna show us, we prefer C because of it's low-levelness and speed.
>
> >any input will be appreciated.
>
> Regard!
>
> WANG Cong
>
>
well,I mean when use c as a higher level assembly maybe it a good
choose compare to assembly.

but,as below

http://www.research.att.com/~bs/esc99.html

when we use c to do the OOP ,for the c compiler has no the globe
Analysis .then the cache miss(for example : insert a array,c compiler
maybe put the data into memory and then take it again for no globe
Analysis ) and the data not Optimi for in the register and c can't
control register like lisp or c++ with some compiler glob control and
Analysis,giveing c the penalty of 1/17 speed as normal

What's you think about it?

Thanks

2007-05-04 11:41:46

by Jan Engelhardt

[permalink] [raw]
Subject: Re: c 's OOP in VFS vs c++'s OOP


On May 4 2007 19:00, la deng wrote:
>
> What's you think about it?

I think the discussion should stop right here, because the kernel
will not be transformed into C++ anytime soon.


Jan
--

2007-05-04 12:26:05

by Cong Wang

[permalink] [raw]
Subject: Re: c 's OOP in VFS vs c++'s OOP

On Fri, May 04, 2007 at 01:40:04PM +0200, Jan Engelhardt wrote:
>
>On May 4 2007 19:00, la deng wrote:
>>
>> What's you think about it?

C gives you the power to control nearly everything. You can, of course, control the registers via inserting assembly code. That's not the fault of C.

>
>I think the discussion should stop right here, because the kernel
>will not be transformed into C++ anytime soon.
>
>
>Jan

OK. Stop here.

Regards!

2007-05-04 13:53:39

by la deng

[permalink] [raw]
Subject: Re: c 's OOP in VFS vs c++'s OOP

On 5/4/07, WANG Cong <[email protected]> wrote:
> On Fri, May 04, 2007 at 01:40:04PM +0200, Jan Engelhardt wrote:
> >
> >On May 4 2007 19:00, la deng wrote:
> >>
> >>
>
> C gives you the power to control nearly everything. You can, of course, control the registers via inserting assembly code. That's not the fault of C.
I think you don't understand me correctly

I know c can inline assmebly to control registers

but,this control not the globe Analysis of control register like
internal of c++ compiler or lisp 's compiler language,c can't

sigh

2007-05-04 14:17:16

by Jan Engelhardt

[permalink] [raw]
Subject: Re: c 's OOP in VFS vs c++'s OOP


On May 4 2007 21:53, la deng wrote:
>>
>> C gives you the power to control nearly everything. You can, of course,
>> control the registers via inserting assembly code. That's not the fault of
>> C.
> I think you don't understand me correctly
>
> I know c can inline assmebly to control registers
>
> but,this control not the globe Analysis of control register like
> internal of c++ compiler or lisp 's compiler language,c can't

Using __asm__ in C++ is the same thing as in C. If you want to
make GCC aware of registers you could use


register int *p1 asm ("r0") = ...;

See chapter "5.37 Variables in Specified Registers" in `info gcc`.


Jan
--

2007-05-04 15:23:21

by Cong Wang

[permalink] [raw]
Subject: Re: c 's OOP in VFS vs c++'s OOP

On Fri, May 04, 2007 at 09:53:34PM +0800, la deng wrote:
>On 5/4/07, WANG Cong <[email protected]> wrote:
>>On Fri, May 04, 2007 at 01:40:04PM +0200, Jan Engelhardt wrote:
>>>
>>>On May 4 2007 19:00, la deng wrote:
>>>>
>>>>
>>
>>C gives you the power to control nearly everything. You can, of course,
>>control the registers via inserting assembly code. That's not the fault of
>>C.
>I think you don't understand me correctly
>
>I know c can inline assmebly to control registers
>
>but,this control not the globe Analysis of control register like
>internal of c++ compiler or lisp 's compiler language,c can't
>
>sigh

You didn't understand me correctly.

I mean that C gives you the power to control them, you can do analysis and then do what you like. It's up to you. But I think if you add optimizing options, the compiler won't be so foolish as what you say.

So, can we stop now?

2007-05-05 06:37:41

by la deng

[permalink] [raw]
Subject: Re: c 's OOP in VFS vs c++'s OOP

On 5/4/07, Jan Engelhardt <[email protected]> wrote:
>
> On May 4 2007 21:53, la deng wrote:
> >>
> >> C gives you the power to control nearly everything. You can, of course,
> >> control the registers via inserting assembly code. That's not the fault of
> >> C.
> > I think you don't understand me correctly
> >
> > I know c can inline assmebly to control registers
> >
> > but,this control not the globe Analysis of control register like
> > internal of c++ compiler or lisp 's compiler language,c can't
>
> Using __asm__ in C++ is the same thing as in C. If you want to
> make GCC aware of registers you could use
>
>
> register int *p1 asm ("r0") = ...;
>
> See chapter "5.37 Variables in Specified Registers" in `info gcc`.
>
>
> Jan
> --
>
hmm,thanks

I found gcc has some extensions can help this

very thanks

2007-05-05 07:29:34

by la deng

[permalink] [raw]
Subject: Re: c 's OOP in VFS vs c++'s OOP

> Analysis,giveing c the penalty of 1/17 speed as normal
>
> What's you think about it?
>
> Thanks
>
I think I mean the "side effect" of C