Discussion:
[std-proposals] Can we have beginner friendly new line and deprecate std::endl?
m***@gmail.com
2018-11-08 13:37:54 UTC
Permalink
Wouldn't it be miles better to instead of un-teaching people from std::endl
and advertise '\n'
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#slio50-avoid-endl>
to have equally attractive alternative?

The point is - '\n' is not in any way beginner friendly as it is not an std
or build in "command"/object, but some alien symbol (to a new comer) like,
literally nothing else - it does not even look a single character.
Even for a non-beginner, some prefer typing std::endl as it is just simple
letters, not rarely used symbols (double colon, is not rarely used a t all)

Also, if we have a friendly new line alternative we could deprecate endl
and teach to new-line-and-flush-if-needed.
Without deprecating it, we might add confusion.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org.
Hyman Rosen
2018-11-08 15:47:48 UTC
Permalink
'\n' has been the way to write newlines in C for half a century.
It's also the way to do it in C++, Java, Perl, Python, and other languages.
We don't need a beginner-friendly way to specify newlines,
because it's as easy to tell the beginners '\n' as to tell them anything
else.
Post by m***@gmail.com
Wouldn't it be miles better to instead of un-teaching people from
std::endl and advertise '\n'
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#slio50-avoid-endl>
to have equally attractive alternative?
The point is - '\n' is not in any way beginner friendly as it is not an
std or build in "command"/object, but some alien symbol (to a new comer)
like, literally nothing else - it does not even look a single character.
Even for a non-beginner, some prefer typing std::endl as it is just simple
letters, not rarely used symbols (double colon, is not rarely used a t all)
Also, if we have a friendly new line alternative we could deprecate endl
and teach to new-line-and-flush-if-needed.
Without deprecating it, we might add confusion.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYpsmvjRc65vKqPv4f6G6MzSgo1LL_73QDum66mxRB3EQ%40mail.gmail.com.
Ray Hamel
2018-11-08 16:57:21 UTC
Permalink
I don't see any reason why '\n' or "string literal\n" is unintuitive or
would need to be replaced. I do think it's a good idea to rename std::endl
to something less misleading, and deprecate the old std::endl.

- Ray
Post by m***@gmail.com
Wouldn't it be miles better to instead of un-teaching people from
std::endl and advertise '\n'
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#slio50-avoid-endl>
to have equally attractive alternative?
The point is - '\n' is not in any way beginner friendly as it is not an
std or build in "command"/object, but some alien symbol (to a new comer)
like, literally nothing else - it does not even look a single character.
Even for a non-beginner, some prefer typing std::endl as it is just simple
letters, not rarely used symbols (double colon, is not rarely used a t all)
Also, if we have a friendly new line alternative we could deprecate endl
and teach to new-line-and-flush-if-needed.
Without deprecating it, we might add confusion.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/8e5e9eab-3bc0-41df-9143-990fd1102d8c%40isocpp.org.
g***@gmail.com
2018-11-08 21:53:01 UTC
Permalink
Grumpy me says lets make endl not flush in C++20, since it surprises people.
And if people want flush they'll have to add a flush call explicitly.
Hopeful me says isn't someone going to produce a new faster API that will
replace that whole machinery anyway with something faster and better
designed so won't endl et al, all come to a sticky um, end, anyway sometime
"soon"?
Post by m***@gmail.com
Wouldn't it be miles better to instead of un-teaching people from
std::endl and advertise '\n'
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#slio50-avoid-endl>
to have equally attractive alternative?
The point is - '\n' is not in any way beginner friendly as it is not an
std or build in "command"/object, but some alien symbol (to a new comer)
like, literally nothing else - it does not even look a single character.
Even for a non-beginner, some prefer typing std::endl as it is just simple
letters, not rarely used symbols (double colon, is not rarely used a t all)
Also, if we have a friendly new line alternative we could deprecate endl
and teach to new-line-and-flush-if-needed.
Without deprecating it, we might add confusion.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f3b96b40-aca4-4df3-a4e4-9b18346956ab%40isocpp.org.
Thiago Macieira
2018-11-08 22:21:48 UTC
Permalink
Post by g***@gmail.com
Grumpy me says lets make endl not flush in C++20, since it surprises people.
Not flushing where it is flushing today would cause way more surprise than
what we have today. Plus, the C standard library does flush on newlines, if
the FILE* object is in line-buffered mode, so why should we deviate?
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2013789.PttkctXh33%40tjmaciei-mobl1.
Brian Bi
2018-11-08 22:07:55 UTC
Permalink
Post by m***@gmail.com
Wouldn't it be miles better to instead of un-teaching people from
std::endl and advertise '\n'
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#slio50-avoid-endl>
to have equally attractive alternative?
The point is - '\n' is not in any way beginner friendly as it is not an
std or build in "command"/object, but some alien symbol (to a new comer)
like, literally nothing else - it does not even look a single character.
Even for a non-beginner, some prefer typing std::endl as it is just simple
letters, not rarely used symbols (double colon, is not rarely used a t all)
I think the reason why novices use std::endl is that they're under the
impression (no doubt perpetuated by incompetent educators) that std::endl
is portable whereas '\n' isn't.

Also, I think adding some hypothetical new "std::newline" constant in an
attempt to "seduce" novices does them a disservice by making them waste
keystrokes and tempting them to use "using namespace std" to save a few.

In other words, teaching people to use '\n' really is the best solution.
Post by m***@gmail.com
Also, if we have a friendly new line alternative we could deprecate endl
and teach to new-line-and-flush-if-needed.
Without deprecating it, we might add confusion.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAMmfjbOkdN63EON%2BhrCJWj94n48vtVvMfUjzeau5KmPWSpwkow%40mail.gmail.com.
T. C.
2018-11-08 22:30:23 UTC
Permalink
Post by Brian Bi
Post by m***@gmail.com
Wouldn't it be miles better to instead of un-teaching people from
std::endl and advertise '\n'
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#slio50-avoid-endl>
to have equally attractive alternative?
The point is - '\n' is not in any way beginner friendly as it is not an
std or build in "command"/object, but some alien symbol (to a new comer)
like, literally nothing else - it does not even look a single character.
Even for a non-beginner, some prefer typing std::endl as it is just
simple letters, not rarely used symbols (double colon, is not rarely used a
t all)
I think the reason why novices use std::endl is that they're under the
impression (no doubt perpetuated by incompetent educators) that std::endl
is portable whereas '\n' isn't.
Also, I think adding some hypothetical new "std::newline" constant in an
attempt to "seduce" novices does them a disservice by making them waste
keystrokes and tempting them to use "using namespace std" to save a few.
In other words, teaching people to use '\n' really is the best solution.
I can see a manipulator that does endl-without-the-flush to be marginally
useful. It would be different from << '\n' in that it performs unformatted
output, i.e., no padding.

I'm not convinced that it's worth standardizing.
Post by Brian Bi
Post by m***@gmail.com
Also, if we have a friendly new line alternative we could deprecate endl
and teach to new-line-and-flush-if-needed.
Without deprecating it, we might add confusion.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fff2c6b4-0f49-4151-bcf0-094e273cafa5%40isocpp.org.
W Brown
2018-11-09 00:33:29 UTC
Permalink
Wouldn't it be miles better to instead of un-teaching people from std::endl and advertise '\n' <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#slio50-avoid-endl> to have equally attractive alternative?
The point is - '\n' is not in any way beginner friendly as it is not an std or build in "command"/object, but some alien symbol (to a new comer) like, literally nothing else - it does not even look a single character.
Even for a non-beginner, some prefer typing std::endl as it is just simple letters, not rarely used symbols (double colon, is not rarely used a t all)
I think the reason why novices use std::endl is that they're under the impression (no doubt perpetuated by incompetent educators) that std::endl is portable whereas '\n' isn't.
Also, I think adding some hypothetical new "std::newline" constant in an attempt to "seduce" novices does them a disservice by making them waste keystrokes and tempting them to use "using namespace std" to save a few.
In other words, teaching people to use '\n' really is the best solution.
I can see a manipulator that does endl-without-the-flush to be marginally useful. It would be different from << '\n' in that it performs unformatted output, i.e., no padding.
I'm not convinced that it's worth standardizing.
Also, if we have a friendly new line alternative we could deprecate endl and teach to new-line-and-flush-if-needed.
Without deprecating it, we might add confusion.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org?utm_medium=email&utm_source=footer>.
--
Brian Bi
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fff2c6b4-0f49-4151-bcf0-094e273cafa5%40isocpp.org <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fff2c6b4-0f49-4151-bcf0-094e273cafa5%40isocpp.org?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/EE0B9E72-114F-4182-8A64-67113839FE54%40gmail.com.
Hyman Rosen
2018-11-08 22:43:06 UTC
Permalink
Post by Brian Bi
I think the reason why novices use std::endl is that they're under the
impression (no doubt perpetuated by incompetent educators) that std::endl
is portable whereas '\n' isn't.
I think novices use std::endl because that's how C++ formatted I/O
was presented for ages. I have the feeling, completely unsupported
by evidence, that the iostreams designers thought manipulators were
really keen, and wanted to have one that would always get used.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com.
Peter Sommerlad
2018-11-09 06:22:15 UTC
Permalink
So the better way is do better teaching. I show my students that they should not use endl, except when they need it.

Sent from Peter Sommerlad's iPad
+41 79 432 23 32
Post by Hyman Rosen
I think the reason why novices use std::endl is that they're under the impression (no doubt perpetuated by incompetent educators) that std::endl is portable whereas '\n' isn't.
I think novices use std::endl because that's how C++ formatted I/O
was presented for ages. I have the feeling, completely unsupported
by evidence, that the iostreams designers thought manipulators were
really keen, and wanted to have one that would always get used.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/AB167E1A-FA59-4B72-A9C2-1624D1B56614%40hsr.ch.
m***@gmail.com
2018-11-09 09:19:04 UTC
Permalink
There are multiple problems with '\n'

First - it is ultimately C ("way")
Second, when we introduce simple output to beginners, for which cout is
actually good because of overloading,
when using '\n' we have to introduce additional topics
- the fact a char can be more the one, well, character
- special magic characters
We also create asymmetry b/w what is used to start the output std::cout (an
object), to modify it (hex) and what is used to end it ("magic").

This screams some design flaw - we should be able to insert a new lines the
same way we modify the stream!

On its own std::endl has the flaw that it does not obey the "do one thing"
rule.
Once we deprecate it, this will shut down all the naive tutorials/courses
still teaching it as the default!


As for std::newline, we have options -

std::nl //< even a beginner can "read" it
std::newl //< orthogonal to endl
std::br //< why not at this point!
std::brl
std::bl

Geeks can still use `\n`, but a beginner (and a teacher) will have a
simple, *correct, *go-to option that models the syntax already introduced
(std::cout)!
Post by Peter Sommerlad
So the better way is do better teaching. I show my students that they
should not use endl, except when they need it.
Sent from Peter Sommerlad's iPad
+41 79 432 23 32
Post by Brian Bi
I think the reason why novices use std::endl is that they're under the
impression (no doubt perpetuated by incompetent educators) that std::endl
is portable whereas '\n' isn't.
I think novices use std::endl because that's how C++ formatted I/O
was presented for ages. I have the feeling, completely unsupported
by evidence, that the iostreams designers thought manipulators were
really keen, and wanted to have one that would always get used.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org.
Brian Bi
2018-11-09 16:50:44 UTC
Permalink
Post by m***@gmail.com
There are multiple problems with '\n'
First - it is ultimately C ("way")
This mailing list is about C++, not Java, Rust, Swift, etc.
This is not an argument.

Second, when we introduce simple output to beginners, for which cout is
Post by m***@gmail.com
actually good because of overloading,
when using '\n' we have to introduce additional topics
- the fact a char can be more the one, well, character
- special magic characters
We also create asymmetry b/w what is used to start the output std::cout
(an object), to modify it (hex) and what is used to end it ("magic").
What do you mean, "what is used to end it"? A semicolon?
Post by m***@gmail.com
This screams some design flaw - we should be able to insert a new lines
the same way we modify the stream!
Yes, the way to do that is with '\n'.
Post by m***@gmail.com
On its own std::endl has the flaw that it does not obey the "do one thing"
rule.
Once we deprecate it, this will shut down all the naive tutorials/courses
still teaching it as the default!
As for std::newline, we have options -
std::nl //< even a beginner can "read" it
std::newl //< orthogonal to endl
std::br //< why not at this point!
std::brl
std::bl
Geeks can still use `\n`, but a beginner (and a teacher) will have a
simple, *correct, *go-to option that models the syntax already introduced
(std::cout)!
Post by Peter Sommerlad
So the better way is do better teaching. I show my students that they
should not use endl, except when they need it.
Sent from Peter Sommerlad's iPad
+41 79 432 23 32
Post by Brian Bi
I think the reason why novices use std::endl is that they're under the
impression (no doubt perpetuated by incompetent educators) that std::endl
is portable whereas '\n' isn't.
I think novices use std::endl because that's how C++ formatted I/O
was presented for ages. I have the feeling, completely unsupported
by evidence, that the iostreams designers thought manipulators were
really keen, and wanted to have one that would always get used.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAMmfjbOjpJvBWEke1z0XXnHXhjtEO_otNN5-jayGPwe3RHO0Rw%40mail.gmail.com.
m***@gmail.com
2018-11-10 15:24:34 UTC
Permalink
Post by Brian Bi
Post by m***@gmail.com
There are multiple problems with '\n'
First - it is ultimately C ("way")
This mailing list is about C++, not Java, Rust, Swift, etc.
This is not an argument.
There is some sort of miscommunication.
The fact there no C++ way to insert a new line (only a UNIX special
character way) is what I state an issue,
considering the rest of the API
Post by Brian Bi
Second, when we introduce simple output to beginners, for which cout is
Post by m***@gmail.com
actually good because of overloading,
when using '\n' we have to introduce additional topics
- the fact a char can be more the one, well, character
- special magic characters
We also create asymmetry b/w what is used to start the output std::cout
(an object), to modify it (hex) and what is used to end it ("magic").
What do you mean, "what is used to end it"? A semicolon?
std::cout //< start
<< 12.f
<< ' '
<< std::hex //< modify
<< 255
<< '\n'; //< finish (magic)

Note that printf (and other languages) already use special characters to
modify the output, so having an '\n' is not abrupt.

But C++ streams are different, having to spell out a special character is
odd and unintuitive for a beginner and a design deficiency in general.
Post by Brian Bi
Post by m***@gmail.com
This screams some design flaw - we should be able to insert a new lines
the same way we modify the stream!
Yes, the way to do that is with '\n'.
Post by m***@gmail.com
On its own std::endl has the flaw that it does not obey the "do one
thing" rule.
Once we deprecate it, this will shut down all the naive tutorials/courses
still teaching it as the default!
As for std::newline, we have options -
std::nl //< even a beginner can "read" it
std::newl //< orthogonal to endl
std::br //< why not at this point!
std::brl
std::bl
Geeks can still use `\n`, but a beginner (and a teacher) will have a
simple, *correct, *go-to option that models the syntax already
introduced (std::cout)!
Post by Peter Sommerlad
So the better way is do better teaching. I show my students that they
should not use endl, except when they need it.
Sent from Peter Sommerlad's iPad
+41 79 432 23 32
Post by Brian Bi
I think the reason why novices use std::endl is that they're under the
impression (no doubt perpetuated by incompetent educators) that std::endl
is portable whereas '\n' isn't.
I think novices use std::endl because that's how C++ formatted I/O
was presented for ages. I have the feeling, completely unsupported
by evidence, that the iostreams designers thought manipulators were
really keen, and wanted to have one that would always get used.
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7da1f33f-c2c1-482f-8fc2-c23a9767a5ec%40isocpp.org.
Nicolas Lesser
2018-11-10 15:28:24 UTC
Permalink
You're going to have a hard time because the committee doesn't like
iostreams and plans on replacing them with something else.

And I don't really see a problem with \n. Sure, it's a bit old-school, but
it's clear and almost every language uses it. If you're programming you'll
going to have to learn \n eventually.
Post by m***@gmail.com
Post by Brian Bi
Post by m***@gmail.com
There are multiple problems with '\n'
First - it is ultimately C ("way")
This mailing list is about C++, not Java, Rust, Swift, etc.
This is not an argument.
There is some sort of miscommunication.
The fact there no C++ way to insert a new line (only a UNIX special
character way) is what I state an issue,
considering the rest of the API
Post by Brian Bi
Second, when we introduce simple output to beginners, for which cout is
Post by m***@gmail.com
actually good because of overloading,
when using '\n' we have to introduce additional topics
- the fact a char can be more the one, well, character
- special magic characters
We also create asymmetry b/w what is used to start the output std::cout
(an object), to modify it (hex) and what is used to end it ("magic").
What do you mean, "what is used to end it"? A semicolon?
std::cout //< start
<< 12.f
<< ' '
<< std::hex //< modify
<< 255
<< '\n'; //< finish (magic)
Note that printf (and other languages) already use special characters to
modify the output, so having an '\n' is not abrupt.
But C++ streams are different, having to spell out a special character is
odd and unintuitive for a beginner and a design deficiency in general.
Post by Brian Bi
Post by m***@gmail.com
This screams some design flaw - we should be able to insert a new lines
the same way we modify the stream!
Yes, the way to do that is with '\n'.
Post by m***@gmail.com
On its own std::endl has the flaw that it does not obey the "do one
thing" rule.
Once we deprecate it, this will shut down all the naive
tutorials/courses still teaching it as the default!
As for std::newline, we have options -
std::nl //< even a beginner can "read" it
std::newl //< orthogonal to endl
std::br //< why not at this point!
std::brl
std::bl
Geeks can still use `\n`, but a beginner (and a teacher) will have a
simple, *correct, *go-to option that models the syntax already
introduced (std::cout)!
Post by Peter Sommerlad
So the better way is do better teaching. I show my students that they
should not use endl, except when they need it.
Sent from Peter Sommerlad's iPad
+41 79 432 23 32
Post by Brian Bi
I think the reason why novices use std::endl is that they're under the
impression (no doubt perpetuated by incompetent educators) that std::endl
is portable whereas '\n' isn't.
I think novices use std::endl because that's how C++ formatted I/O
was presented for ages. I have the feeling, completely unsupported
by evidence, that the iostreams designers thought manipulators were
really keen, and wanted to have one that would always get used.
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7da1f33f-c2c1-482f-8fc2-c23a9767a5ec%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7da1f33f-c2c1-482f-8fc2-c23a9767a5ec%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALmDwq1wq9pKv3Esy4AXepnSMotfXTwoJ3BUQwHdmJza2gWP_Q%40mail.gmail.com.
m***@gmail.com
2018-11-10 17:02:32 UTC
Permalink
Post by Nicolas Lesser
You're going to have a hard time because the committee doesn't like
iostreams and plans on replacing them with something else.
Are there any proposals in flight? I see Text Formating
<http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0645r3.html>, but
it does not include I/O (AFAICT)
Post by Nicolas Lesser
And I don't really see a problem with \n. Sure, it's a bit old-school, but
it's clear and almost every language uses it. If you're programming you'll
going to have to learn \n eventually.
Post by m***@gmail.com
Post by Brian Bi
Post by m***@gmail.com
There are multiple problems with '\n'
First - it is ultimately C ("way")
This mailing list is about C++, not Java, Rust, Swift, etc.
This is not an argument.
There is some sort of miscommunication.
The fact there no C++ way to insert a new line (only a UNIX special
character way) is what I state an issue,
considering the rest of the API
Post by Brian Bi
Second, when we introduce simple output to beginners, for which cout is
Post by m***@gmail.com
actually good because of overloading,
when using '\n' we have to introduce additional topics
- the fact a char can be more the one, well, character
- special magic characters
We also create asymmetry b/w what is used to start the output std::cout
(an object), to modify it (hex) and what is used to end it ("magic").
What do you mean, "what is used to end it"? A semicolon?
std::cout //< start
<< 12.f
<< ' '
<< std::hex //< modify
<< 255
<< '\n'; //< finish (magic)
Note that printf (and other languages) already use special characters to
modify the output, so having an '\n' is not abrupt.
But C++ streams are different, having to spell out a special character is
odd and unintuitive for a beginner and a design deficiency in general.
Post by Brian Bi
Post by m***@gmail.com
This screams some design flaw - we should be able to insert a new lines
the same way we modify the stream!
Yes, the way to do that is with '\n'.
Post by m***@gmail.com
On its own std::endl has the flaw that it does not obey the "do one
thing" rule.
Once we deprecate it, this will shut down all the naive
tutorials/courses still teaching it as the default!
As for std::newline, we have options -
std::nl //< even a beginner can "read" it
std::newl //< orthogonal to endl
std::br //< why not at this point!
std::brl
std::bl
Geeks can still use `\n`, but a beginner (and a teacher) will have a
simple, *correct, *go-to option that models the syntax already
introduced (std::cout)!
Post by Peter Sommerlad
So the better way is do better teaching. I show my students that they
should not use endl, except when they need it.
Sent from Peter Sommerlad's iPad
+41 79 432 23 32
Post by Brian Bi
I think the reason why novices use std::endl is that they're under
the impression (no doubt perpetuated by incompetent educators) that
std::endl is portable whereas '\n' isn't.
I think novices use std::endl because that's how C++ formatted I/O
was presented for ages. I have the feeling, completely unsupported
by evidence, that the iostreams designers thought manipulators were
really keen, and wanted to have one that would always get used.
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7da1f33f-c2c1-482f-8fc2-c23a9767a5ec%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7da1f33f-c2c1-482f-8fc2-c23a9767a5ec%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f7bd155a-bcbf-49f0-ac34-f0628ccf50e1%40isocpp.org.
Nicolas Lesser
2018-11-10 17:04:49 UTC
Permalink
Post by m***@gmail.com
Post by Nicolas Lesser
You're going to have a hard time because the committee doesn't like
iostreams and plans on replacing them with something else.
Are there any proposals in flight? I see Text Formating
<http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0645r3.html>,
but it does not include I/O (AFAICT)
I don't actually know. It's just what I've been hearing. Don't know how
accurate that is though...
Post by m***@gmail.com
Post by Nicolas Lesser
And I don't really see a problem with \n. Sure, it's a bit old-school,
but it's clear and almost every language uses it. If you're programming
you'll going to have to learn \n eventually.
Post by m***@gmail.com
Post by Brian Bi
Post by m***@gmail.com
There are multiple problems with '\n'
First - it is ultimately C ("way")
This mailing list is about C++, not Java, Rust, Swift, etc.
This is not an argument.
There is some sort of miscommunication.
The fact there no C++ way to insert a new line (only a UNIX special
character way) is what I state an issue,
considering the rest of the API
Post by Brian Bi
Second, when we introduce simple output to beginners, for which cout is
Post by m***@gmail.com
actually good because of overloading,
when using '\n' we have to introduce additional topics
- the fact a char can be more the one, well, character
- special magic characters
We also create asymmetry b/w what is used to start the output
std::cout (an object), to modify it (hex) and what is used to end it
("magic").
What do you mean, "what is used to end it"? A semicolon?
std::cout //< start
<< 12.f
<< ' '
<< std::hex //< modify
<< 255
<< '\n'; //< finish (magic)
Note that printf (and other languages) already use special characters to
modify the output, so having an '\n' is not abrupt.
But C++ streams are different, having to spell out a special character
is odd and unintuitive for a beginner and a design deficiency in general.
Post by Brian Bi
Post by m***@gmail.com
This screams some design flaw - we should be able to insert a new
lines the same way we modify the stream!
Yes, the way to do that is with '\n'.
Post by m***@gmail.com
On its own std::endl has the flaw that it does not obey the "do one
thing" rule.
Once we deprecate it, this will shut down all the naive
tutorials/courses still teaching it as the default!
As for std::newline, we have options -
std::nl //< even a beginner can "read" it
std::newl //< orthogonal to endl
std::br //< why not at this point!
std::brl
std::bl
Geeks can still use `\n`, but a beginner (and a teacher) will have a
simple, *correct, *go-to option that models the syntax already
introduced (std::cout)!
Post by Peter Sommerlad
So the better way is do better teaching. I show my students that they
should not use endl, except when they need it.
Sent from Peter Sommerlad's iPad
+41 79 432 23 32
Post by Brian Bi
I think the reason why novices use std::endl is that they're under
the impression (no doubt perpetuated by incompetent educators) that
std::endl is portable whereas '\n' isn't.
I think novices use std::endl because that's how C++ formatted I/O
was presented for ages. I have the feeling, completely unsupported
by evidence, that the iostreams designers thought manipulators were
really keen, and wanted to have one that would always get used.
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it,
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7da1f33f-c2c1-482f-8fc2-c23a9767a5ec%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7da1f33f-c2c1-482f-8fc2-c23a9767a5ec%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f7bd155a-bcbf-49f0-ac34-f0628ccf50e1%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f7bd155a-bcbf-49f0-ac34-f0628ccf50e1%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALmDwq1jR7r2m6fFVVDMzjwDkfptcDN6bZF8mr9z%2BkYcteLaNA%40mail.gmail.com.
Brian Bi
2018-11-11 21:38:15 UTC
Permalink
Post by m***@gmail.com
Post by Brian Bi
Post by m***@gmail.com
There are multiple problems with '\n'
First - it is ultimately C ("way")
This mailing list is about C++, not Java, Rust, Swift, etc.
This is not an argument.
There is some sort of miscommunication.
The fact there no C++ way to insert a new line (only a UNIX special
character way) is what I state an issue,
considering the rest of the API
'\n' is standard C, which became standard C++ about 20 years ago. I don't
see the issue.
Post by m***@gmail.com
Post by Brian Bi
Second, when we introduce simple output to beginners, for which cout is
Post by m***@gmail.com
actually good because of overloading,
when using '\n' we have to introduce additional topics
- the fact a char can be more the one, well, character
- special magic characters
We also create asymmetry b/w what is used to start the output std::cout
(an object), to modify it (hex) and what is used to end it ("magic").
What do you mean, "what is used to end it"? A semicolon?
std::cout //< start
<< 12.f
<< ' '
<< std::hex //< modify
<< 255
<< '\n'; //< finish (magic)
Note that printf (and other languages) already use special characters to
Post by m***@gmail.com
modify the output, so having an '\n' is not abrupt.
But C++ streams are different, having to spell out a special character is
odd and unintuitive for a beginner and a design deficiency in general.
It's only "magic" if you teach beginners that '\n' is a special magic
command, rather than the literal representation of the newline character.
Post by m***@gmail.com
Post by Brian Bi
Post by m***@gmail.com
This screams some design flaw - we should be able to insert a new lines
the same way we modify the stream!
Yes, the way to do that is with '\n'.
Post by m***@gmail.com
On its own std::endl has the flaw that it does not obey the "do one
thing" rule.
Once we deprecate it, this will shut down all the naive
tutorials/courses still teaching it as the default!
As for std::newline, we have options -
std::nl //< even a beginner can "read" it
std::newl //< orthogonal to endl
std::br //< why not at this point!
std::brl
std::bl
Geeks can still use `\n`, but a beginner (and a teacher) will have a
simple, *correct, *go-to option that models the syntax already
introduced (std::cout)!
Post by Peter Sommerlad
So the better way is do better teaching. I show my students that they
should not use endl, except when they need it.
Sent from Peter Sommerlad's iPad
+41 79 432 23 32
Post by Brian Bi
I think the reason why novices use std::endl is that they're under the
impression (no doubt perpetuated by incompetent educators) that std::endl
is portable whereas '\n' isn't.
I think novices use std::endl because that's how C++ formatted I/O
was presented for ages. I have the feeling, completely unsupported
by evidence, that the iostreams designers thought manipulators were
really keen, and wanted to have one that would always get used.
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdYYZjeHHbRZ5bcHLYVsWfspwCeQ8oxEDRbuJ8dqAtsX5A%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b49f4c85-816b-4b35-851d-407061a8ef9f%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7da1f33f-c2c1-482f-8fc2-c23a9767a5ec%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7da1f33f-c2c1-482f-8fc2-c23a9767a5ec%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAMmfjbMHae%3DpbG7LMjjjqWAE-5Zaiwi3rpWXr-HpwBRo0bjvfA%40mail.gmail.com.
Jake Arkinstall
2018-11-11 22:26:01 UTC
Permalink
Post by Brian Bi
It's only "magic" if you teach beginners that '\n' is a special magic
command, rather than the literal representation of the newline character.
This. A thousand times this.

'\n' isn't magic in the same way that '\0' and '\t' aren't magic. They're
well known representations of special characters, and such ideas have been
in use in encodings in one form or another for well over a hundred years.
Avoiding them in any learning setting is fruitless in my opinion and,
perhaps, gives the opposite of the intended outcome - we replace a "magic"
that is consistent across dozens of languages with a "magic" command that
creates a newline.

I agree that endl is badly named, but it's one of those things where
deprecation (in terms of renaming) would cause a lot of friction. I'd
sooner just see a better (I.e. more efficient, better compile time support,
and less verbose - especially the disaster that is stream modifiers, that
make printf look user friendly) output approach and let std::endl die out -
not with a bang, but with a whimper.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCOudOQQYextom6SH8AvuK%2B4cPtbVaGNmNojkd%2BPFsEQcQ%40mail.gmail.com.
m***@gmail.com
2018-11-11 23:01:33 UTC
Permalink
Post by Jake Arkinstall
Post by Brian Bi
It's only "magic" if you teach beginners that '\n' is a special magic
command, rather than the literal representation of the newline character.
This. A thousand times this.
'\n' isn't magic in the same way that '\0' and '\t' aren't magic. They're
well known representations of special characters, and such ideas have been
in use in encodings in one form or another for well over a hundred years.
Avoiding them in any learning setting is fruitless in my opinion and,
perhaps, gives the opposite of the intended outcome - we replace a "magic"
that is consistent across dozens of languages with a "magic" command that
creates a newline.
By no mean I suggest avoiding them altogether. I only point out that
- A beginner will have to be abruptly introduced to special characters in
his first day (in an API that does not used any special characters!)
- It is a glaring API inconsistency on its own
Post by Jake Arkinstall
I agree that endl is badly named, but it's one of those things where
deprecation (in terms of renaming) would cause a lot of friction. I'd
sooner just see a better (I.e. more efficient, better compile time support,
and less verbose - especially the disaster that is stream modifiers, that
make printf look user friendly) output approach and let std::endl die out -
not with a bang, but with a whimper.
We all do, but I don't see that coming anytime soon.

Maybe we could just deprecate endl and advocate using '\n' "until something
better comes along".
This will play nicely with format() as people will get used to adding it as
part of the formating string.

As mentioned, deprecating it will (hopefully) prevent teaching it.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7ea647c8-9bfb-4cd9-b55f-4e8b83160451%40isocpp.org.
Brian Bi
2018-11-11 23:07:30 UTC
Permalink
Post by m***@gmail.com
Post by Jake Arkinstall
Post by Brian Bi
It's only "magic" if you teach beginners that '\n' is a special magic
command, rather than the literal representation of the newline character.
This. A thousand times this.
'\n' isn't magic in the same way that '\0' and '\t' aren't magic. They're
well known representations of special characters, and such ideas have been
in use in encodings in one form or another for well over a hundred years.
Avoiding them in any learning setting is fruitless in my opinion and,
perhaps, gives the opposite of the intended outcome - we replace a "magic"
that is consistent across dozens of languages with a "magic" command that
creates a newline.
By no mean I suggest avoiding them altogether. I only point out that
- A beginner will have to be abruptly introduced to special characters in
his first day (in an API that does not used any special characters!)
- It is a glaring API inconsistency on its own
How is it an API inconsistency? The way the API works is that you pass it a
character, and it prints that character out. Escape sequences are entirely
orthogonal to the API.
Post by m***@gmail.com
Post by Jake Arkinstall
I agree that endl is badly named, but it's one of those things where
deprecation (in terms of renaming) would cause a lot of friction. I'd
sooner just see a better (I.e. more efficient, better compile time support,
and less verbose - especially the disaster that is stream modifiers, that
make printf look user friendly) output approach and let std::endl die out -
not with a bang, but with a whimper.
We all do, but I don't see that coming anytime soon.
Maybe we could just deprecate endl and advocate using '\n' "until
something better comes along".
This will play nicely with format() as people will get used to adding it
as part of the formating string.
As mentioned, deprecating it will (hopefully) prevent teaching it.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7ea647c8-9bfb-4cd9-b55f-4e8b83160451%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7ea647c8-9bfb-4cd9-b55f-4e8b83160451%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
*Brian Bi*
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAMmfjbPBWa-QQ8c9zxQrzSOWKU83sjEw%2BA-U%3D_%3DffVfSt832Ag%40mail.gmail.com.
Thiago Macieira
2018-11-12 02:06:48 UTC
Permalink
Post by m***@gmail.com
- A beginner will have to be abruptly introduced to special characters in
his first day (in an API that does not used any special characters!)
A beginner needs to be taught the basics of the language. The difference
between "a" and 'a' is a lot more confusing than the presence of escape
sequences.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1682503.RS7KKTmsOS%40tjmaciei-mobl1.
Matthew Woehlke
2018-11-13 18:19:39 UTC
Permalink
Post by m***@gmail.com
By no mean I suggest avoiding them altogether. I only point out that
- A beginner will have to be abruptly introduced to special characters in
his first day (in an API that does not used any special characters!)
- It is a glaring API inconsistency on its own
It sounds like what you *really* want is the equivalent of Python's
print(), which prints a line of text and automatically adds the newline.

Maybe you could propose that?

BTW, Qt's QDebug also does that, and some other stuff:

qInfo() << "Hello" << "world";

...will print "Hello world\n", modulo any additional logging formatting
(e.g. prepending with the time) that is configured.
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6339a868-071b-e5c5-a19d-49a4a4d1ba43%40gmail.com.
Matthew Woehlke
2018-11-13 18:16:20 UTC
Permalink
Post by m***@gmail.com
There is some sort of miscommunication.
The fact there no C++ way to insert a new line (only a UNIX special
character way) is what I state an issue,
considering the rest of the API
Huh?

'\n' is not "a UNIX special character". It is an escape sequence that
refers to the NEWLINE character.

Escape sequences are important. Not only should most programmers be
familiar with at least '\n', but also '\'', '\"' and of course '\\'.
Lacking this familiarity is just a recipe for getting into trouble when
needing to have these characters in a string.

As for NEWLINE, it is not UNIX specific. It is true that "UNIX" the the
line ending standard that uses '\n' by itself to mark the ends of lines
of files on disk, but it is *also* the standard for files being
processed in "text" mode. *On ALL platforms*. In fact, it is more
possible to be ignorant of the existence of other line ending
conventions than to be ignorant that at a code level, '\n' is *the*
correct way to end lines.
Post by m***@gmail.com
But C++ streams are different, having to spell out a special character is
odd and unintuitive for a beginner and a design deficiency in general.
So how do you print quote characters? Or backslashes? Or *any*
"non-printable" character?

Trying to avoid teaching escaped characters, which exist in virtually
EVERY computer language (not just "programming" languages, but markup
languages as well) is just dumb.
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/59b3971f-53bf-e0c3-f9f5-3d7a82646852%40gmail.com.
o***@gmail.com
2018-11-12 11:17:39 UTC
Permalink
Post by Peter Sommerlad
So the better way is do better teaching. I show my students that they
should not use endl, except when they need it.
When does one need std::endl?
AFAIK std::endl could / should be deprecated.
Write "\n" << std::flush; if that's what you need.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c9f26898-5980-43de-9313-1d271bf43aa0%40isocpp.org.
Eyal Rozenberg
2018-11-13 22:16:54 UTC
Permalink
Post by Brian Bi
Also, I think adding some hypothetical new "std::newline" constant in an
attempt to "seduce" novices does them a disservice by making them waste
keystrokes and tempting them to use "using namespace std" to save a few.
But it allows people (not only novices) to use literal strings with no
escapes; and that _is_ kind of useful, at least from an aesthetic
perspective. There is also the argument of a (slightly) reduced learning
curve for novices. Someone who has not programmed before will understand

"hello world" << std::newline << "goodbye world"

faster than

"hello world\ngoodbye world"


I'm not saying that's an important enough advantage, but still.

Eyal
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/be5afcef-5a22-e30b-59b6-c97bf17a8ac1%40technion.ac.il.
Edward Catmur
2018-11-14 00:26:54 UTC
Permalink
Start them out with raw strings, then.

std::cout << R"(hello
world
)";

Escape characters can wait till a later lesson, once they're happy with getting a program to produce output.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/46ea9857-ee43-49d0-9bd5-9ca4075c414e%40isocpp.org.
m***@gmail.com
2018-11-11 23:27:30 UTC
Permalink
I think there's great value in teaching people about escape sequences
early, it's a useful cross-language concept that they'll run into forever.
I'm also not convinced it's harder to learn than std::endl, In fact I think
it's much simpler because it's part of the string meaning multi-line
strings are easy to work with instead of something magical that comes from
streaming in objects that come from elsewhere in the standard library.

Teaching someone 'put \n where you want a line break' seems easier to me
than 'if you want a line break, end your string, stream in std::endl, then
start streaming a new string'. The first says, 'this string has a line
break in it', the second is 'there are two strings, in the middle we're
doing the magical end-line operation.
Post by m***@gmail.com
Wouldn't it be miles better to instead of un-teaching people from
std::endl and advertise '\n'
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#slio50-avoid-endl>
to have equally attractive alternative?
The point is - '\n' is not in any way beginner friendly as it is not an
std or build in "command"/object, but some alien symbol (to a new comer)
like, literally nothing else - it does not even look a single character.
Even for a non-beginner, some prefer typing std::endl as it is just simple
letters, not rarely used symbols (double colon, is not rarely used a t all)
Also, if we have a friendly new line alternative we could deprecate endl
and teach to new-line-and-flush-if-needed.
Without deprecating it, we might add confusion.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4810f3c9-3d28-4ef3-b867-efa821dcdf50%40isocpp.org.
m***@gmail.com
2018-11-11 23:31:30 UTC
Permalink
Furthermore I think teaching \n naturally leads into curiosity about how
strings work, the fact that a 'char' is an integer holding an ASCII value,
that there are other special escape characters like \t, and that you can
escape integer literals for the other ones too.

Teaching people to use a separate std::endl doesn't teach people about
strings, it teaches them about iostreams.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5d70ae59-7519-4db4-94cc-fadd1b13d467%40isocpp.org.
Bryce Adelstein Lelbach aka wash
2018-11-12 01:26:28 UTC
Permalink
I'd rather just focus on providing a modern replacement for iostreams for
C++26, and aim to deprecate iostreams in the future.

Standard library dynamic constructors violate the zero cost abstraction
principle. std::cout and friends must go.
Post by m***@gmail.com
Wouldn't it be miles better to instead of un-teaching people from
std::endl and advertise '\n'
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#slio50-avoid-endl>
to have equally attractive alternative?
The point is - '\n' is not in any way beginner friendly as it is not an
std or build in "command"/object, but some alien symbol (to a new comer)
like, literally nothing else - it does not even look a single character.
Even for a non-beginner, some prefer typing std::endl as it is just simple
letters, not rarely used symbols (double colon, is not rarely used a t all)
Also, if we have a friendly new line alternative we could deprecate endl
and teach to new-line-and-flush-if-needed.
Without deprecating it, we might add confusion.
--
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e17189bf-51be-496d-845a-3707a516a210%40isocpp.org?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAP3wax_sPnk2FVbZj%2BKPoVcakkBAkGSP6ZcQZUSts52hc2E60g%40mail.gmail.com.
a***@gmail.com
2018-11-17 19:41:33 UTC
Permalink
If the purpose is on teaching, than for sure special characters have to be introduced sometime.
Maybe teach this?

const auto newline = '\n'; // constexpr maybe?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/019c1be1-2686-4075-8e06-be110b83e038%40isocpp.org.
FrankHB1989
2018-11-29 04:14:29 UTC
Permalink
It seems to be the cost of omission of line buffered stream notion (as in
ISO C) in C++.

That said, I don't see it a big deal to teach newbies '\n' or std::endl as
long as they can know the difference.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ad51d005-ece7-4102-aa42-aac554277733%40isocpp.org.
Loading...