Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > What has C++ become?

Reply
Thread Tools

What has C++ become?

 
 
Matthias Buelow
Guest
Posts: n/a
 
      06-02-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> The people who are guiding the development of C++
> have really made a mess of things, I mean templates


IMHO, the opposite has happened.. it has been hammered into shape over
the years. My "last" experience with C++, before I resumed my use of it
about a year ago, had been from the early 90ies and the current C++ is,
while being a larger and still not very pretty language, imho more
usable than back then (of course that might also be because my memory
betrays me, or the old compilers I used [Turbo and Zortech C++ in that
case] were Not Very Good back then, or whatever.)
 
Reply With Quote
 
 
 
 
Noah Roberts
Guest
Posts: n/a
 
      06-02-2008
Erik Wikstr├Âm wrote:
> On 2008-05-31 18:36, (E-Mail Removed) wrote:
>> I was looking over someone's C++ code today and despite
>> having written perfectly readable C++ code myself,
>> the stuff I was looking at was worse than legalese.
>> The people who are guiding the development of C++
>> have really made a mess of things, I mean templates
>> and competing libraries and all that just render the
>> code impossible to comprehend.

>
> Sure, templates can be a bit hard to read before you get used to them
> (and template meta-programming even harder) but considering how powerful
> they are I do not think they are overly complex.


Both of these things simply require an understanding of the language
and, in the case of TMP, the conventions used. The authors of MPL
created and documented, quite well I think, the underlying concepts of
metafunctions and their associated algorithms and tools. An
understanding of these concepts makes TMP code completely understandable.

The problem I think that is going on here, without actually seeing any
code sample, is that people are expecting that they can just learn C++
and then work in the field for 20 years without having to learn anything
new.
 
Reply With Quote
 
 
 
 
Noah Roberts
Guest
Posts: n/a
 
      06-02-2008
Walter Bright wrote:
> James Kanze wrote:
>> On May 31, 7:25 pm, Erik Wikstr÷m <(E-Mail Removed)> wrote:
>>> Sure, templates can be a bit hard to read before you get used
>>> to them (and template meta-programming even harder) but
>>> considering how powerful they are I do not think they are
>>> overly complex.

>>
>> It's always a costs-benefits tradeoff. Making the code harder
>> to read is a definite cost. Afterwards, you have to weigh the
>> benefits, and see if they are worth it.

>
> I don't believe readability is a cost benefit tradeoff. I attended Scott
> Meyers' presentation at NWCPP (slides here:
> http://www.nwcpp.org/Downloads/2008/code_features.pdf). Scott mentioned
> that he'd had help from TMP experts in creating the code examples, so we
> can discount the idea that the readability problems are caused by lack
> of programmer ability in C++ TMP.


I also attended that discussion, but the first one in 07...Red Green.
At least in that talk it seemed to be that Meyers specifically had help
in dealing with certain aspects of the TMP library and more
specifically, with things that should have worked but did not.

Furthermore, it wouldn't surprise me if Scott initially had trouble
understanding or working in TMP because it is an utterly new technique
that is very different than anything else people normally do in C++.
The closest one might come to the kind of coding that you are doing
might be LISP or Scheme, except you are unable to assign to anything.
However, by learning the concepts behind the TMP method, what a
metafunction is and things like that, the code really becomes rather
easy to comprehend.

And I'm not a C++ "expert". There are a LOT of people that know the
language better than I do.
 
Reply With Quote
 
Erik Wikstr├Âm
Guest
Posts: n/a
 
      06-02-2008
On 2008-06-02 12:27, Walter Bright wrote:
> Juha Nieminen wrote:
>> Maybe you think using <> makes template code "a mess"? I don't
>> understand why.

>
> It's because of the parsing ambiguities that come from using < > as a
> parameter delimiter.
>
>> Is this somehow unclear:
>>
>> std::vector<int> table;
>> table.push_back(5);
>>
>> What's so unclear about that? I think it's perfectly clear and legible
>> code. How else would you want it to be?

>
> It's the wordiness of it. If the code gets more complicated than such
> trivial examples, it gets rather hard to visualize. I would want it to
> use a much more compact notation, like maybe:
>
> int[] table;
> table ~= 5;


The natural interpretation of the above would in C++ be "table != 5".
Assigning non-intuitive meanings to operators is much worse than a lack
of compactness. If you really want an operator use either += or <<.

--
Erik Wikstr├Âm
 
Reply With Quote
 
Roland Pibinger
Guest
Posts: n/a
 
      06-02-2008
On Sun, 1 Jun 2008 16:34:58 -0700 (PDT), (E-Mail Removed) wrote:
>I recall having the same experience, the *first* time I looked
>at a C program, having before that seen only Pascal,
>Modula-2, Basic and assembly. But I've seen C++ many times
>now, albeit mostly my own which is deliberately readable.


You can safely ignore this geek style 'template programming' because
it will never reach the mundane area of real-world programming.


--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
 
Reply With Quote
 
Fernando Gˇmez
Guest
Posts: n/a
 
      06-02-2008
On Jun 2, 12:27 pm, (E-Mail Removed) (Roland Pibinger) wrote:
> On Sun, 1 Jun 2008 16:34:58 -0700 (PDT), (E-Mail Removed) wrote:
> >I recall having the same experience, the *first* time I looked
> >at a C program, having before that seen only Pascal,
> >Modula-2, Basic and assembly. But I've seen C++ many times
> >now, albeit mostly my own which is deliberately readable.

>
> You can safely ignore this geek style 'template programming' because
> it will never reach the mundane area of real-world programming.
>


Yeah, like, you know, WTL, Loki or the Standard C++ Library. Those are
clear examples of imaginary-world programming.



Hope you weren't serious about that...
 
Reply With Quote
 
Ramon F Herrera
Guest
Posts: n/a
 
      06-03-2008
On May 31, 12:36 pm, (E-Mail Removed) wrote:
> I was looking over someone's C++ code today and despite
> having written perfectly readable C++ code myself,
> the stuff I was looking at was worse than legalese.
> The people who are guiding the development of C++
> have really made a mess of things, I mean templates
> and competing libraries and all that just render the
> code impossible to comprehend. Sure there is
> going to be a certain amount of complexity,
> that's a given, but if code is not readable except by
> a kind of clergy then there is something wrong with
> the language. Of course, I suppose the code I was
> looking at could have been deliberately obfuscated
> so that the developer could maintain control over it,
> but shouldn't a language (or its libraries) be designed
> to prevent that?



It has been said many times before. The solution (or cure) to C++ is
the KISS principle.

-RFH

 
Reply With Quote
 
Michael DOUBEZ
Guest
Posts: n/a
 
      06-03-2008
Walter Bright a Úcrit :
> Yannick Tremblay wrote:
>> What do you think should happen on:
>>
>> std::vector<int> c;
>> c = a + b; // ??
>> Various peoples will say: sum elements individually, concatenation of
>> the two vectors ??? The fact is that '+' for vectors have no natural
>> (universal?) meaning, using it as a short hand for something else is
>> more likely to obfuscate the code rather than a more verbose solution.

>
> You're quite right. That's why the D programming language introduced the
> operators ~ and ~= to mean concatenate and append, respectively. That
> eliminates the meaning ambiguity in the + and += operators.


Another usual argument with using + for concatenation is that one expect
commutativity (a+b==b+a) but a.append(b)!= b.append(a) .

--
Michael
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      06-03-2008
Walter Bright wrote:
> It's the wordiness of it.


I disagree. Using longer keywords and notation does not make the code
unclear, but all the contrary: It makes the code more understandable and
unambiguous. When you try to minimize the length of elements what you
end up is basically an unreadable obfuscated regexp.

I think that your suggestion itself is a perfect example of that:

> table ~= 5;


Yes, that uses less characters than "table.push_back(5);". However,
why would that be any clearer and more understandable? On the contrary,
it's more obfuscated.

I have never understood the fascination some people (and almost 100%
of beginner programmers) have with trying to minimize the size of their
source code. They will sometimes go to ridiculous extents to try to make
the code as short as possible, at the cost of making it completely
obfuscated.

Brevity does not improve readability, but all the contrary.
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      06-03-2008
Michael DOUBEZ wrote:
> Another usual argument with using + for concatenation is that one expect
> commutativity (a+b==b+a) but a.append(b)!= b.append(a) .


OTOH, multiplication of matrices is not commutative, yet it may make
sense to still support the * operator for matrix types...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some shareware has a time limit and the software will not work after the time limit has expired. anthony crowder Computer Support 20 01-16-2007 10:01 AM
When a control on form has blank value or has no items (dropdownlist) then it wont' be in Request.Forms TS ASP .Net 3 10-06-2006 01:29 PM
The printing has been stopped and this job has been add to the queu? dejola Computer Support 6 12-30-2005 03:26 AM
Downloaded document has disappeared by the time Word has opened Rob Nicholson ASP .Net 12 12-06-2005 04:59 PM
ZoneAlarm has detected a problem with your installation, and therefore has restricted Internet access from your machine for your protection. Donĺt panic A Teuchter Computer Support 2 05-19-2005 09:20 PM



Advertisments