On the richness of C++
Edward Diener
eddielee_no_spam_here at tropicsoft.com
Sun Apr 13 18:13:42 PDT 2008
Georg Wrede wrote:
> Edward Diener wrote:
>> Walter Bright wrote:
>>
>>> Edward Diener wrote:
>>>
>>>> Walter Bright wrote:
>>>>
>>>>> Kevin Bealer wrote:
>>>>>
>>>>>> I was amazed that Boost could do things like the Lambda support
>>>>>> with _1 _2, etc.
>>>>>> Those Boost guys are geniuses.
>>>>>
>>>>>
>>>>> I agree, they are geniuses. But that's really what is wrong with
>>>>> C++, you shouldn't have to be a genius to get advanced things done.
>>>>
>>>>
>>>> Are D's templates a complete replacement in functionality for
>>>> Boost's MPL ? If so could you write an article on your web site
>>>> about the how's and why's of that ? I am still trying to understand
>>>> D's templates based on the sparse documentation of them.
>>>
>>>
>>> I don't really understand Boost MPL, but D's template system is
>>> considerably more powerful than C++'s.
>>
>>
>> I do not know the MPL either although I understand the general
>> concept. It is a C++ template metaprogramming library for manipulating
>> types at compile time so that the final result of the body of a
>> template deals in whatever types the template metaprogramming needs to
>> generalize for his programming task.
>>
>> I agree that what I currently understand of D templates looks clearer
>> than the template system in C++ but I am not knowledgable enough to
>> know whether it is "better", or easier to use in doing the sorts of
>> things which Boost programmers accomplish.
>>
>>> I agree that more documentation is needed, but one can easily write a
>>> book about it.
>>
>>
>> The question is: has anyone tackled in D some of the template
>> metaprogramming tasks which various Boost programmers have
>> accomplished with C++ ?
>>
>> I am trying to get a feel for how different, or how much easier ( or
>> perhaps harder ) it would be to do Boost things like Spirit (
>> lex/yacc-like DSEL ), function ( universal callable ), bind and/or
>> lambda ( function object creation ), shared_ptr ( sharable smart
>> pointer, obviously for RAII in D because of GC ), signals (
>> generalized multicast events ), multi_index ( multiple index
>> containers ), regex and/or xpressive ( regular expressions ),
>> tokenizer ( generalized tokening of strings ), date_time ( date/time
>> and time intervals ) and many others ( the above are just my favorites
>> but I have hardly explored/used all of them ) which C++ programmers
>> find very useful. All of these libraries depend on template
>> metaprogramming in C++. Can their equivalents just as easily be
>> implemented and have any of them been done already ?
>
> Now the above is approaching the idea of this thread.
In Boost there is an entire metaprogramming paradigm based on a set of
conventions regarding C++ templates and types, as implemented by the
Boost MPL. This is despite the fact that C++ template syntax is much
more abstruse than D's templates. So I was merely wondering if there is
anything equivalent in D which can manipulate templates the way that the
Boost MPL can. I agree that D's templates appear much easier to use but
whether or not they are richer in functionality than C++ templates is
something I do not know, but would love to find out about. But that
would mean a comparison between what D can do with its templates as
opposed to what the Boost MPL can do.
>
>> I have not looked at the D libraries, phobos and tango I believe they
>> are called, so maybe I am way off base comparing the Boost libraries
>> to what may already be in D. But I am trying to get an idea if D is
>> capable of doing these Boost things just as easily or easier.
>
> Yes! And I think those are things that very may, who don't regularly
> write in this NG, really wonder about with D.
The template syntax is clearer, but I don't know if it is better, and/or
why. I am a big advocate of clarity in computer languages but not if
there is any loss of functionality. I do not believe that clarity should
ever be sacrificed for needed functionality. That is one reason I still
believe that Java and C# are merely subsets of C++, not improvements.
Taking away functionality for clarity is never the way to go, but adding
clarity while keeping, or improving the same functionality, as D has
done in mostr cases, is admirable. However in some areas D seems to have
given away functionality for clarity, or some holy grail which few
understand, as in the const debacle.
I am hoping Walter will address this issue of template functionality as
opposed to syntax, between C++ and D, extensively sometime in the
future, hopefully in a technically neutral way ( he tends to be biased
toward D fro some odd reason <g> ).
More information about the Digitalmars-d
mailing list