Tuesday, January 26, 2016

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

Jerry Stuckle <jstucklex@attglobal.net>: Jan 25 08:21PM -0500

On 1/25/2016 3:31 PM, Alf P. Steinbach wrote:
> week, offer, must just be disregarded, ignored.
 
> Cheers & hth.,
 
> - Alf
 
Alf,
 
I didn't say YOU couldn't teach C++ in a week. All I said was the two
people I know who were university instructors could not teach it in a week.
 
But since you admit you can't do it, I guess you can't. There are a
number of other instructors whom I know are quite capable of doing it.
And they have done it on Europe, North America and Asia, as I have.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Jan 25 08:23PM -0500

On 1/25/2016 3:42 PM, Stefan Ram wrote:
>> I could certainly not teach C++ in a week.
 
> One cannot teach C++ in a week, and one cannot teach C++
> in one semester.
 
That's where you're wrong. Corporations require courses no more than a
week long.
 
> What one can teach is a selection of C++ (a subset of all
> that one could say about C++).
 
One can teach the syntax and theory of C++ and OOP. I didn't say the
students were experts coming out of the class. But they are productive.
 
> The choice of that subset depends on several factors that
> include the length of the course.
 
Corporate courses can be no longer than one week (about 37.5 hours).
And there are numerous companies around the world which satisfy this
requirement. It can, and is being done.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
David Brown <david.brown@hesbynett.no>: Jan 26 09:06AM +0100

On 26/01/16 02:21, Jerry Stuckle wrote:
 
> Alf,
 
> I didn't say YOU couldn't teach C++ in a week. All I said was the two
> people I know who were university instructors could not teach it in a week.
 
Jerry, you are very good at /saying/ one thing, and /implying/ something
very different.
 
From what you wrote and the way you wrote it, your message and thought
process was clear:
 
1. You know two people who taught programming at college, and failed to
teach it to companies.
 
2. Therefore everyone who teaches at college will fail at teaching to
companies.
 
3. Alf taught at college then moved to teaching to companies.
 
4. Therefore Alf is a bad teacher.
 
5. Therefore you win the argument.
 
 
I assume that you don't intend to come across as patronising and
insulting, but that's how it reads to me. I'm sure Alf has the
self-confidence to know that he is a good teacher (judging from his vast
number of helpful posts in this group over the years), and will not be
bothered by your attitude - but as a bystander, it irritates me.
 
> But since you admit you can't do it, I guess you can't. There are a
> number of other instructors whom I know are quite capable of doing it.
> And they have done it on Europe, North America and Asia, as I have.
 
Alf and Stefan are right. They are experienced C++ programmers and
teachers. You cannot learn C++ in a semester, and certainly not in a
week. You can get a reasonable /grounding/ of C++ in a semester, but
there is a lot of the language and how to use it that will be missing
completely. In a week, all you will get is a very rough overview.
 
Of course, this will not stop instructors claiming to teach C++ in a
week. And it will not stop companies sending employees on week-long
courses and assuming that after that, they "know" C++. And it will not
stop companies wasting time, money and reputation as a result of making
said employees program in a language they barely comprehend.
 
There is only one known realistic plan for really learning C++ in a
short time-frame, and even then it takes 21 days rather than a week:
 
<http://abstrusegoose.com/249>
"Öö Tiib" <ootiib@hot.ee>: Jan 26 03:57AM -0800

On Tuesday, 26 January 2016 10:06:44 UTC+2, David Brown wrote:
> self-confidence to know that he is a good teacher (judging from his vast
> number of helpful posts in this group over the years), and will not be
> bothered by your attitude - but as a bystander, it irritates me.
 
Sufficiently advanced troll is indistinguishable from a genuine kook but
Jerry Stuckle is likely genuinely insane. Just read comp.lang.c thread
"Offtopic: couldn't stop myself from sharing". When he ran out of nonsense
that seemed slightly coherent from afar then he turned to blather in style
of "Whoopie doopie ding dong". We can't provide the care he needs.
David Brown <david.brown@hesbynett.no>: Jan 26 03:18PM +0100

On 26/01/16 12:57, 嘱 Tiib wrote:
> "Offtopic: couldn't stop myself from sharing". When he ran out of nonsense
> that seemed slightly coherent from afar then he turned to blather in style
> of "Whoopie doopie ding dong". We can't provide the care he needs.
 
Yes, I have seen that thread, and my opinion of Jerry is heavily
influenced by it (just as my opinion of Alf is heavily influenced by his
long history of helpful and considered posts - even if I have not always
agreed with them). Jerry is new to Usenet, or at least newly returned
to Usenet - I hope he can learn a more constructive style.
 
Anyway, enough of this - back to the topic on hand.
David Brown <david.brown@hesbynett.no>: Jan 26 03:24PM +0100

On 23/01/16 02:55, JiiPee wrote:
> In this thread/post you can tell what you like in C++11/C++14. How it
> made things nicer, how you use it and how it made those things easier.
> Why you like C++11/C++14 more than the old C++?
 
My favourites would be:
 
* constexpr functions (improved in C++14)
* auto (for local variables, and local functions)
* explicit overrides and final
* strongly typed enumerations
* explicit conversion operators (no more "safe boolean idiom)
* static assertions (no more ugly macros)
 
Lambdas and nullptr are nice too. User-defined literals have been nice
to play with.
 
C++14 fixes up a few missing points (std::make_unique, improved constexpr).
 
It will be interesting to see what C++17 brings in concepts (including
requires, axiom, and assumes).
Jerry Stuckle <jstucklex@attglobal.net>: Jan 26 09:45AM -0500

On 1/26/2016 3:06 AM, David Brown wrote:
>> people I know who were university instructors could not teach it in a week.
 
> Jerry, you are very good at /saying/ one thing, and /implying/ something
> very different.
 
David, I implied nothing.
 
> teach it to companies.
 
> 2. Therefore everyone who teaches at college will fail at teaching to
> companies.
 
I implied no such thing.
 
> 3. Alf taught at college then moved to teaching to companies.
 
> 4. Therefore Alf is a bad teacher.
 
> 5. Therefore you win the argument.
 
I implied no such thing.
 
> self-confidence to know that he is a good teacher (judging from his vast
> number of helpful posts in this group over the years), and will not be
> bothered by your attitude - but as a bystander, it irritates me.
 
Read my words - not what you *think I mean*. If I would have thought
Alf is a bad teacher, I would have said so.
 
> week. You can get a reasonable /grounding/ of C++ in a semester, but
> there is a lot of the language and how to use it that will be missing
> completely. In a week, all you will get is a very rough overview.
 
You obviously have no idea what can and cannot be learned in a week.
Corporations pay big money for these courses because they are effective.
 
> courses and assuming that after that, they "know" C++. And it will not
> stop companies wasting time, money and reputation as a result of making
> said employees program in a language they barely comprehend.
 
And it will not stop corporations from paying big money for something
that works. Virtually all of my clients were Fortune 500 companies -
such as IBM, Intel, Boeing and many others. You're saying these
companies don't know what they're doing? I don't think so.
 
> There is only one known realistic plan for really learning C++ in a
> short time-frame, and even then it takes 21 days rather than a week:
 
> <http://abstrusegoose.com/249>
 
That's one way. There are others - as corporations understand.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Jan 26 09:45AM -0500

On 1/26/2016 6:57 AM, Öö Tiib wrote:
> "Offtopic: couldn't stop myself from sharing". When he ran out of nonsense
> that seemed slightly coherent from afar then he turned to blather in style
> of "Whoopie doopie ding dong". We can't provide the care he needs.
 
Yup, and that was an accurate response.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Jan 26 09:51AM -0500

On 1/26/2016 9:18 AM, David Brown wrote:
> agreed with them). Jerry is new to Usenet, or at least newly returned
> to Usenet - I hope he can learn a more constructive style.
 
> Anyway, enough of this - back to the topic on hand.
 
Do you think I really care what your opinion of me is? You have shown
no reason for me to think your opinions are worth anything.
 
And no, I'm not at all new to usenet. I was one of the first people on
usenet back in the early 80's. I was on arpanet before usenet even
existed; we started with email lists, then went to list servers. Usenet
grew out of that. While I wasn't part of the crowd that created the
protocols, I was using the servers which eventually resulted in the RFPs
for NNTP being created.
 
And I have been on usenet continually since that time. Just not in this
newsgroup.
 
This and your other posts prove you are not worth any respect and your
opinions are completely worthless.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
JiiPee <no@notvalid.com>: Jan 26 07:50PM

On 26/01/2016 14:24, David Brown wrote:
> Lambdas and nullptr are nice too.
 
i like very much nullptr, ... no more pondering whether to use 0 or
create some NULL stuff.... now its clear what to use everywhere. I did
not like that zero:
 
int* p = 0;
"Bill Cunningham" <nospam@nspam.invalid>: Jan 26 01:24PM -0500

I just wanted to ask someone famailiar with C++ this question. just
asked this nextdoor in clc so I will get clc++'s take. In C one initializes
a dynamic array as such,
 
int *p;
p=malloc(10*sizeof(int));
 
And this works for its' purpose. How is dynamic memory handled in C++? In an
easier manner?
 
Bill
Victor Bazarov <v.bazarov@comcast.invalid>: Jan 26 01:26PM -0500

On 1/26/2016 1:24 PM, Bill Cunningham wrote:
> p=malloc(10*sizeof(int));
 
> And this works for its' purpose. How is dynamic memory handled in C++? In an
> easier manner?
 
Ease is in the eye of the beholder. In C++ it is done either exactly
the same way (since 'malloc' is part of C++ just as it is part of C), or
 
int *p = new int[10];
 
V
--
I do not respond to top-posted replies, please don't ask
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jan 26 07:39PM +0100

On 1/26/2016 7:24 PM, Bill Cunningham wrote:
> p=malloc(10*sizeof(int));
 
> And this works for its' purpose. How is dynamic memory handled in C++? In an
> easier manner?
 
vector<int> v( 10 );
 
 
Cheers & hth,
 
- Alf
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jan 26 07:53PM +0100

On 1/26/2016 7:26 PM, Victor Bazarov wrote:
>> easier manner?
 
> Ease is in the eye of the beholder. In C++ it is done either exactly
> the same way (since 'malloc' is part of C++ just as it is part of C),
 
Well in C++ one has to cast the result of `malloc` unless a `void*` is
what one desires, while in C one shouldn't cast the result lest one
inadvertently generates an implicit declaration when the relevant
include is missing. This difference in the advice or best practice for
the two languages is due to different rules for implicit conversions,
and different rules for implicit declarations. Of course, using `malloc`
is usually not best practice in C++ anyway, but it can be necessary due
to requirements of C APIs, or for use of `realloc`.
 
 
> or
 
> int *p = new int[10];
 
Yes.
 
One difference here is that this defaults to throwing an exception when
memory can't be allocated, while malloc returns a nullpointer, so at
least when memory exhaustion is an issue one can't just replace a C
`malloc` call with a C++ `new` expression and have equivalent C++ code.
 
• • •
 
All those differences noted, I think in C++ one should generally prefer
standard library containers when possible, and in this case, just use
`vector<int>`,
 
vector<int> v( 10 );
 
which automates all that memory management, is more robust, and provides
much useful & convenient functionality.
 
I'm pretty sure you agree with that but just didn't put that in your
short & fast answer.
 
Cheers,
 
- Alf
Paavo Helde <myfirstname@osa.pri.ee>: Jan 26 09:00PM +0200

On 26.01.2016 20:24, Bill Cunningham wrote:
> p=malloc(10*sizeof(int));
 
> And this works for its' purpose. How is dynamic memory handled in C++? In an
> easier manner?
 
Either
 
std::array<int, 10> arr;
 
or
 
std::vector<int> vec(10);
 
The first provides a fixed-size buffer whereas the second can easily
grow and shrink at run-time.
 
hth
Paavo
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jan 26 07:02PM

On Tue, 26 Jan 2016 13:26:43 -0500
> or
 
> int *p = new int[10];
 
> V
 
Not quite exactly the same way, as in C++ for safety reasons there is no
implicit cast from void* to int*, so it would be:
 
p=static_cast<int*>(malloc(10*sizeof(int));
 
However in C++ you would in practice use std::make_unique() instead of
the new expression or malloc(), or as someone else has suggested, you
would use std::vector, and move them as necessary.
 
Chris
"Bill Cunningham" <nospam@nspam.invalid>: Jan 26 02:08PM -0500

"Paavo Helde" <myfirstname@osa.pri.ee> wrote in message
news:sr-dnfJEa7z5XzrLnZ2dnUU78IudnZ2d@giganews.com...
 
> std::vector<int> vec(10);
 
> The first provides a fixed-size buffer whereas the second can easily grow
> and shrink at run-time.
 
One thing is in what little C++ I have done, it's been small things. And
I believe that's when the 'using' directive can be used. In all my .cc code
I've done before I have...
 
#include <iostream>
using std namespace;
 
So I've never done anything with namespaces. Nor in C.
 
Bill
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jan 26 07:10PM

On Tue, 26 Jan 2016 21:00:51 +0200
 
> std::vector<int> vec(10);
 
> The first provides a fixed-size buffer whereas the second can easily
> grow and shrink at run-time.
 
The OP said he was interested in "dynamic memory", whereas std::array is
the equivalent of a C array allocated on the stack. This is compounded
by the fact that, because it is stack allocated, it is not a movable
container. A move of std::array will try and move every element, or
copy them if the element type has no move constructor or move
assignment operator (as the case may be).
 
std::vector is as you say a direct analogue of malloc(), because its
memory is allocated dynamically and is moveable with a pointer swap.
 
Chris
"Bill Cunningham" <nospam@nspam.invalid>: Jan 26 02:10PM -0500

"Paavo Helde" <myfirstname@osa.pri.ee> wrote in message
news:sr-dnfJEa7z5XzrLnZ2dnUU78IudnZ2d@giganews.com...
>> easier manner?
 
> Either
 
> std::array<int, 10> arr;
 
Ok with the static buffer here, is arr or array the name of the array?
One must be a directive or command.
 
> or
 
> std::vector<int> vec(10);
 
Ok. the above is dynamic. Runtime so there's never any buffer overflows
with the above code?
 
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jan 26 07:17PM

On Tue, 26 Jan 2016 14:10:51 -0500
"Bill Cunningham" <nospam@nspam.invalid> wrote:
[snip]
 
> > std::vector<int> vec(10);
 
> Ok. the above is dynamic. Runtime so there's never any buffer
> overflows with the above code?
 
Sure there can be buffer overflow if you use direct access to its
elements with operator[](), because as constructed it has a size of 10
ints. To add more elements than 10 you would need to use
std::vector::push_back().
 
If you want to avoid buffer overflow when setting elements use the
default constructor and then insert elements using that method. If you
want to avoid buffer overflow when reading elements you can use
std::vector::at() instead of operator[](), in which case you will get
an exception if you try to access a non-existent element.
 
Chris
"Bill Cunningham" <nospam@nspam.invalid>: Jan 26 02:25PM -0500

"Chris Vine" <chris@cvine--nospam--.freeserve.co.uk> wrote in message
news:20160126191752.52a5b0be@bother.homenet...
 
> want to avoid buffer overflow when reading elements you can use
> std::vector::at() instead of operator[](), in which case you will get
> an exception if you try to access a non-existent element.
 
Oh I see. Well I kinda wondered if that was to good to be true. I
thought runtime memory management that's smart! Now I've never seen the
scoping operator used twice as above. I've also never seen at() or
operator[](). Guess I have some things to check into.
 
Bill
scott@slp53.sl.home (Scott Lurndal): Jan 26 07:50PM


>Ease is in the eye of the beholder. In C++ it is done either exactly
>the same way (since 'malloc' is part of C++ just as it is part of C), or
 
> int *p = new int[10];
 
And in neither case is the dynamic array "initialized". The pointer
will have a valid value, but the contents to which it points are
UNDEFINED.
JiiPee <no@notvalid.com>: Jan 25 11:49PM

People keep asking me that "what is the best book for beginners learning
C++". Well, I am pretty sure it must be C++11/14 at least. Anybody knows
a good book which uses C++ style (and not too much teaching C)? I have
not read any of them really recently so dont know much.
 
Bjarnes "Principles and Practice Using C++" seems ok, but it does not
seem to teach so much the language features.
A book which teaches all C++ features but correctly (in "Bjarnes" way).
Ian Collins <ian-news@hotmail.com>: Jan 26 03:05PM +1300

JiiPee wrote:
 
> Bjarnes "Principles and Practice Using C++" seems ok, but it does not
> seem to teach so much the language features.
> A book which teaches all C++ features but correctly (in "Bjarnes" way).
 
The C++ Programming Language, 4th edition.
 
--
Ian Collins
JiiPee <no@notvalid.com>: Jan 26 12:02AM

On 25/01/2016 21:46, Waqas Ahmed wrote:
> Requirements:
> - Minimum of 2 years of experience in a data analyst role, with
> increasing levels of responsibility
 
I have more than 3 years c++ experience, but I live in London . Can I
get a green card as well??
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: