Monday, November 17, 2014

Digest for comp.lang.c++@googlegroups.com - 25 updates in 4 topics

comp.lang.c++@googlegroups.com Google Groups
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com.
Louis Krupp <lkrupp@nospam.pssw.com.invalid>: Nov 17 12:59AM -0700

>music from the CD and then copy it to mp3 to listen at car - surely not
>make sense buy 2 licenses to listen your album.
 
>One product one price!
 
You don't have to pay full retail for both the e-book and the
paperback. The paperback alone is $49.99, and for $5.00 more, you can
download the e-book, too. It's not free, but it doesn't sound too
unreasonable.
 
Louis
red floyd <no.spam@its.invalid>: Nov 17 09:29AM -0800

On 11/15/2014 1:33 AM, Dombo wrote:
> Some publishers, like Manning, add a coupon with a code to their paper
> books that allows you to download the electronic version for free so you
> get the best of both worlds.
 
I just read this morning about the latest Kindle which will let you
(metaphorically) stick your finger between the pages while flipping
back or forward to look at something else.
 
Still doesn't change my opinion on e-books, though.
JiiPee <no@notvalid.com>: Nov 17 06:41PM

On 17/11/2014 07:59, Louis Krupp wrote:
> download the e-book, too. It's not free, but it doesn't sound too
> unreasonable.
 
> Louis
 
Yes true , that sounds reasonable, although I would have still given it
for free for paper back buyers as there is not extra cost for giving it.
Robert Hutchings <rm.hutchings@gmail.com>: Nov 17 12:44PM -0600

On 11/17/2014 11:29 AM, red floyd wrote:
> (metaphorically) stick your finger between the pages while flipping
> back or forward to look at something else.
 
> Still doesn't change my opinion on e-books, though.
 
I like having the PDF...you can search for keywords and copy/paste code
from the PDF into the editor or IDE or your choice. That said, a
physical book is very nice for "just reading". I don't think O'Reilly
gives you the option to buy the book AND download the PDF/EPub/Mobi...?
Louis Krupp <lkrupp@nospam.pssw.com.invalid>: Nov 17 12:00PM -0700

On Mon, 17 Nov 2014 12:44:38 -0600, Robert Hutchings
>from the PDF into the editor or IDE or your choice. That said, a
>physical book is very nice for "just reading". I don't think O'Reilly
>gives you the option to buy the book AND download the PDF/EPub/Mobi...?
 
They do. For $54.99, I can download a PDF file, which I've just done,
and the book should arrive whenever it's ready.
 
Whether or not I'll understand everything that's in the book is
another story...
 
Louis
JiiPee <no@notvalid.com>: Nov 17 08:44PM

On 17/11/2014 19:00, Louis Krupp wrote:
 
> Whether or not I'll understand everything that's in the book is
> another story...
 
> Louis
 
But certainly you will be more skillful after reading it... it cannot go
wrong
Robert Hutchings <rm.hutchings@gmail.com>: Nov 17 01:52PM -0800

On Monday, November 17, 2014 1:00:27 PM UTC-6, Louis Krupp wrote:
 
> Whether or not I'll understand everything that's in the book is
> another story...
 
> Louis
 
Louis, how did you get the PDF download AND the paperback book? Was this on http://shop.oreilly.com?
legalize+jeeves@mail.xmission.com (Richard): Nov 17 04:35AM

[Please do not mail me a copy of your followup]
 
Marcel Koeppen <usenet@marzelpan.de> spake the secret code
 
>Clang C++ Modernizer can run some transformations on old code to make
>it use range based for-loops, nullptr, auto, etc.
 
>http://clang.llvm.org/extra/clang-modernize.html
 
This is the one you want to use; it's awesome.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
legalize+jeeves@mail.xmission.com (Richard): Nov 17 04:37AM

[Please do not mail me a copy of your followup]
 
Robert Hutchings <rm.hutchings@gmail.com> spake the secret code
>>> 2014 updates? Or is just a manual "do it yourself" thing?
 
>> What would be the point of automating it? You don't learn anything
>> from that.
 
Any refactoring you can perform automatically is 100x more useful than
any refactoring you must perform manually. The larger the code base,
the higher the multiplier on the usefulness.
 
Doing it once or twice is all it takes to learn something. Doing it
hundreds or thousands of times across your code base is just drudgery.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
legalize+jeeves@mail.xmission.com (Richard): Nov 17 04:39AM

[Please do not mail me a copy of your followup]
 
David Thornley <david@thornley.net> spake the secret code
 
>I'm not coming up with much more off the top of my head. A lot of
>the new functionality is better suited to be used as you write
>new code rather than changing old code.
 
Switching to move semantics might have far-reaching changes through
your code.
 
Many people use shared_ptr<T> simply because move semantics for T
didn't exist and they wanted a function that returned a vector or
something like that. I've even seen people get obsessive about
returning strings and insisting that everything be shared_ptr<string>.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Ian Collins <ian-news@hotmail.com>: Nov 17 07:36PM +1300

Richard wrote:
> [Please do not mail me a copy of your followup]
 
Why would I?
 
> didn't exist and they wanted a function that returned a vector or
> something like that. I've even seen people get obsessive about
> returning strings and insisting that everything be shared_ptr<string>.
 
That's never really been a problem. RVO has been a saviour in that area
for a long time.
 
--
Ian Collins
Robert Hutchings <rm.hutchings@gmail.com>: Nov 17 07:19AM -0600

On 11/16/2014 10:35 PM, Richard wrote:
>> it use range based for-loops, nullptr, auto, etc.
 
>> http://clang.llvm.org/extra/clang-modernize.html
 
> This is the one you want to use; it's awesome.
 
I will definitely check this out. Thanks!
scott@slp53.sl.home (Scott Lurndal): Nov 17 03:53PM

>in case you are concerned about performance, you could get
>significant improvements just by recompiling your "old" code
>with a compiler that supports at least C++11.
 
Really? Can you elaborate a bit? How does recompilation
of unmodified code improve by using a compiler that supports
newer syntax that the program doesn't even use?
legalize+jeeves@mail.xmission.com (Richard): Nov 17 05:42PM

[Please do not mail me a copy of your followup]
 
slp53@pacbell.net spake the secret code
 
>Really? Can you elaborate a bit? How does recompilation
>of unmodified code improve by using a compiler that supports
>newer syntax that the program doesn't even use?
 
You could benefit from the improved performance of move semantics.
Methods/function that return std::string would benefit and they are
pretty common. Methods that return containers would also benefit, but
they are less common for people who are sensitive to performance in
a pre-move semantics code base.
 
There may be other examples of improvements in the standard library
classes that can yield improved performance simply by using the new
compiler.
 
Compilers often get better at producing code from one release to
another as well, so using a newer compiler can make your code faster
or smaller (depending on options) "for free".
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 17 07:07PM

On Mon, 2014-11-17, Richard wrote:
> the higher the multiplier on the usefulness.
 
> Doing it once or twice is all it takes to learn something. Doing it
> hundreds or thousands of times across your code base is just drudgery.
 
You don't answer my question, though: what is the point? You now have
converted your code to a dialect of C++ which few people understand,
and you yourself haven't learned to use it.
 
(And what could possibly be a hundred times more useful than learning
something?)
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
woodbrian77@gmail.com: Nov 17 11:57AM -0800

On Monday, November 17, 2014 1:08:06 PM UTC-6, Jorgen Grahn wrote:
> > hundreds or thousands of times across your code base is just drudgery.
 
> You don't answer my question, though: what is the point? You now have
> converted your code to a dialect of C++ which few people understand,
 
After many conferences the past 3 years where half of the
talks cover new language features, I think more than a few
understand it.
 
> and you yourself haven't learned to use it.
 
From my experience automating things, you learn
how to use whatever it is you are automating.
 
> (And what could possibly be a hundred times more useful than learning
> something?)
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
"Öö Tiib" <ootiib@hot.ee>: Nov 17 12:03PM -0800

On Monday, 17 November 2014 17:54:07 UTC+2, Scott Lurndal wrote:
 
> Really? Can you elaborate a bit? How does recompilation
> of unmodified code improve by using a compiler that supports
> newer syntax that the program doesn't even use?
 
Standard library of C++ does use the new and more efficient
features. So if your code did use something from standard library
then it will likely be faster despite you change no byte of it.
legalize+jeeves@mail.xmission.com (Richard): Nov 17 08:06PM

[Please do not mail me a copy of your followup]
 
Jorgen Grahn <grahn+nntp@snipabacken.se> spake the secret code
 
>> Doing it once or twice is all it takes to learn something. Doing it
>> hundreds or thousands of times across your code base is just drudgery.
 
>You don't answer my question, though: what is the point?
 
One might as well ask:
 
Since C++ can be transformed into C, what is the point?
 
The point is that using C++ allows us to get the job done at a higher
level of abstraction than C, without losing the efficiencies of C. We
get the compiler to do more work for us so that we can work in a
manner that is expressive and intention revealing without having to
shove a thousand implementation details up into your face in every
function.
 
If there was no point to these features in C++11, they wouldn't have
been introduced.
 
As far as the transformations performed by clang-modernize:
 
- use of range-based for loops makes loops easier to read;
intent is clearly revealed without excessive syntax
- use of nullptr makes pointer use more explicit;
intent is clearly revealed without ambiguous syntax
- use of auto removes unnecessary syntactic noise;
using nested iterator typedefs to declare iterators just makes for
syntactic noise that gets in the way of clearly reading the intent
- use of override makes explicit when methods are being overridden and
more clearly reveals intent; this can result in bugs being found if
the intention was to override a method in the base but the method
name was misspelled or the signature didn't completely match
- use pass by value; the intention is more clearly revealed. We don't
need to chase through implementation details to discover that the
only reason references were used was to achieve some sort of hand
optimization that the compiler can do for us automatically with move
semantics, copy elision and return value optimization.
- replace auto_ptr with unique_ptr; replace error-prone semantics of
auto_ptr with well defined semantics of unique_ptr. This one may be
a toss up depending on your team and your code base.
 
>You now have
>converted your code to a dialect of C++ which few people understand,
 
Few people? LOL. C++11 has been around for about 3 years and none of
the above transformations, with the possible exception of the auto_ptr
-> unique_ptr change, are going to throw any decent programmer into a
tizzy. Every time I've shown existing C++ programmers these new
features through examples they always got it within a few seconds.
 
SECONDS.
 
These features aren't rocket science and don't take very long to learn.
 
We're not talking esoteric guru level template metaprogramming here.
 
It's syntactic sugar for the most part.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
"Öö Tiib" <ootiib@hot.ee>: Nov 17 12:18PM -0800

On Monday, 17 November 2014 15:20:03 UTC+2, Robert Hutchings wrote:
 
> >> http://clang.llvm.org/extra/clang-modernize.html
 
> > This is the one you want to use; it's awesome.
 
> I will definitely check this out. Thanks!
 
Note that "Loop Convert" and "Use-Auto" are just eye-candy
but "Use-Nullptr" and "Add-Override" improve safety and
"Pass-By-Value" and "Replace-AutoPtr" even improve performance.
scott@slp53.sl.home (Scott Lurndal): Nov 17 09:34PM


>Standard library of C++ does use the new and more efficient
>features. So if your code did use something from standard library
>then it will likely be faster despite you change no byte of it.
 
A remote possibility, I would expect. Given that the run-time
component (e.g. libstdc++.so.6 on linux) is dynamically linked,
most benefit would accrue sans recompilation by simply updating
the library to a newer version.
 
In any case, simply switching to a new compiler is not feasible
for most real-world projects; given internal dependencies, third-party
dependencies, the effort required to requalify any non-trivial
application with the new compilation tools and the cost of labor.
Ian Collins <ian-news@hotmail.com>: Nov 18 10:41AM +1300

Scott Lurndal wrote:
> component (e.g. libstdc++.so.6 on linux) is dynamically linked,
> most benefit would accrue sans recompilation by simply updating
> the library to a newer version.
 
No, it wouldn't.
 
Consider the use of move constructors - how could these appear in the
object code without recompilation?
 
> for most real-world projects; given internal dependencies, third-party
> dependencies, the effort required to requalify any non-trivial
> application with the new compilation tools and the cost of labor.
 
Whether to update the compiler depends on project priorities. It there
is sufficient benefit form new features, then the update will be
justified. You don't have to update all of the project components in
one pass.
 
--
Ian Collins
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Nov 16 11:53PM

On Sun, 16 Nov 2014 12:19:10 -0800 (PST)
> Stefan I'm not in front of a compiler right now but are you saying I
> should be able to do sizeof(stream) to achieve my objective?
 
No. Stefan is giving a pedantic but correct answer to the question you
put. Unfortunately the question you put is not the one to which you
wanted an answer.
 
You are not interested in "the size of the istream object", as you
thought you were. You are interested in the size of the data
accessible from the stream. In many cases that is unbounded
(terminals, sockets, pipes, fifos for example), as others have pointed
out.
 
Chris
Christopher Pisz <nospam@notanaddress.com>: Nov 17 11:42AM -0600

On 11/16/2014 1:19 PM, Mark wrote:
 
> NOTE: If the returned object was an ifstream object then I can seek to the end and determine the size in advance but this is an 'istream' object and tellg and seek doesn't work as it does with ifstream
 
> Thanks
 
You already asked this question about 20 messages down the list. What's
changed?
red floyd <no.spam@its.invalid>: Nov 17 11:05AM -0800

On 11/16/2014 2:55 PM, Mark wrote:
> //to offset against MAX_SIZE_SUPPORTED so we don't crash
> } while ( !stream.good() ) ;
> Mark
 
Only nit I have is that offset should probably std::streamsize
instead of unsigned.
scott@slp53.sl.home (Scott Lurndal): Nov 17 03:13PM

> student-support program granting free licenses to every higher school stud=
>ent who will contact and ask us about that. You just need to send us a phot=
>o of your student card or transcript.
 
For those who would rather not send a photocopy of their ID to these people, or if
one isn't interested in using Visual Studio, I'll point out the following
open-source alternative static analysis tool.
 
http://cppcheck.sourceforge.net/
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: