Re: New versions of VC++ still stuck with function prototypes?
From: Arnaud Debaene (adebaene_at_club-internet.fr)
Date: 03/27/05
- Previous message: Arnaud Debaene: "Re: New versions of VC++ still stuck with function prototypes?"
- In reply to: Andre Kaufmann: "Re: New versions of VC++ still stuck with function prototypes?"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 27 Mar 2005 19:42:59 +0200
Andre Kaufmann wrote:
> Arnaud Debaene wrote:
>> _R wrote:
>>
>>> Given that VS2005 has made an effort to clean up the syntax of VC++
>>> (in C++/CLI), is there any future plans to do away with function
>>> protos, ala C#/VB?
>>
>> You mean remove the header files? I hope they will never do it!
>>
>
> I hope they will (try to) support that in a future standard, since
> that could drastically improve compilation speed.
Uhh???
>> - Clean separation of interface and implementation (not clear enough
>> IMHO, but still better than in C# or VB).
>
> For that purpose, you donīt need any header file. C++ doesnīt offer
> any better separation than the other languages. If you make heavy use
> of templates you effectively cannot separate the interface from the
> implementation, or have to use code separation "tricks" like the pimpl
> idiom.
At least you've got the posibility to use some tricks like the pimpl idiom!
In C#, you've got nothing to separate a class interface from implementation.
I agree that the headers are not ideal in C++, but it's a first step in the
good direction. Concerning templates, the deficiencies of actual compilers
shouldn't be used to judge the validity of the language choices (though,
concerning this point, I am not sure that export, even correctly
implemented, could improve compilation speed : I believe it's a very tricky
issue that isn't understood yet, except by a few gurus like Daveed
Vandervoorde who actually have implemented export).
> Some languages are separating their code files into 2 halves. One
> interface section and one implementation section.
Do you have any examples please?
> I donīt see any
> reason, why that cannot be done in C++ and AFAIK IBM has offered a
> proprietary C++ solution. I think that would offer a much better
> handling and for template interfaces there wouldnīt be a need for an
> export keyword.
I agree that the current compiler handling of templates is not satisfactory.
<snip>
> If you have a large C++ project, youīll have to use sooner or later
> precompiled header files to speed up compilation.
And when you touch a
> single header file, the C++ compiler has to recompiled the whole
> project. Not much better than in other languages.
First of all, precompiled headers are not available in all implementations
and they aren't defined in the C++ standard. Next, you're supposed to put in
precompiled headers fairly stable headers file that don't change often, if
they change at all.If you put in precompiled headers files that you change
often, then it's your fault if you get bad compile times.
> The syntax of the C++ compiler is complex, but itīs not the only
> reason why a C++ compiler needs so much more time, than a C# or VB
> compiler.
> Besides better optimization, the main reason is the separation into
> header and implementation files.
> Yes - normally there should be only the interface in the header file,
> but effectively you will have also implementation code (templates,
> stl, windows.h) to include in the header files.
I agree concerning templates, but there is no implementation in Windows.h
(except some ugly macros)...
> And if the project
> grows, you have to permanently think of code separation, so that
> the compilation speed wonīt be too slow.
At least you *can* think of code separation. You've got no such opportunity
in C#. The C++ model is far from ideal (mainly because of non-exported
template handling, of macros and of syntax uggliness IMHO), but it offers
some room for improvements in this area, while there is nothing in C#.
> Donīt get me wrong, i love C++ in many aspects, but sometimes i still
> prefer other languages because of compilation speed.
> If my C# project with 200 units compiles faster completely than a
> single C++ unit of my project with also 200 units and header files what is
> the advantage of a clear separation in 2 files ?
200 files are not a huge project by a long shot IMHO.
> The C++ compiler could automatically detect (ok not an easy task for a
> C++ compiler) if the implementation or the interface has changed and
> mark the object file if the implementation or the interface has
> changed. Each other C++ file including the changed unit (header +
> implementation) file could then simply check if the interface has
> changed or not. If not there wouldnīt be a need to recompile the unit.
I don't get you there. It's exactly what is happening right now (except
that, as there is still some implementation details in the headers, things
don't work so smootly all the time), but this is the basic idea of
headers...
Arnaud
MVP - VC
- Previous message: Arnaud Debaene: "Re: New versions of VC++ still stuck with function prototypes?"
- In reply to: Andre Kaufmann: "Re: New versions of VC++ still stuck with function prototypes?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|