C++ Logo

std-proposals

Advanced search

Re: Making C++ easier for new students

From: organicoman <organicoman_at_[hidden]>
Date: Sat, 07 Aug 2021 10:34:55 +0100
I don't understand the purpose of this discussion, since we have already 02 very mature frameworks that fix all concerns.https://www.copperspice.comhttps://www.qt.io/They can do most what any newbie is looking for, and they both build on top of C++ and extend it!RegardsNadirSent from my Galaxy
-------- Original message --------From: Eyal Rozenberg via Std-Proposals <std-proposals_at_[hidden]> Date: 8/7/21 9:43 AM (GMT+01:00) To: std-proposals_at_[hidden] Cc: Eyal Rozenberg <eyalroz1_at_[hidden]> Subject: Re: [std-proposals] Making C++ easier for new students I'll make specific comments rather than address the general issue -which is a valid concern.On 03/08/2021 9:05, Bill Kerney via Std-Proposals wrote:> 1. How do I do non-blocking I/O? (Sometimes phrased like, "How do I>     read an arrow key?")I don't believe this is supposed to be trivial or succinct in ageneral-purpose programming language, as opposed to, say, a gaming or UIapp engine. I also doubt it is relevant to students beginning to learn alanguage (though perhaps I'm missing something).> 2. How do I recover from errors in input?Well, this is actually not so terrible, in the sense that cin'ing into atype which doesn't match the input doesn't get you stuck: It sets theresult variable to 0 or some other value, and sets the failbit. You canthen recover with clearing the failbit; however, clearing the inputbuffer is not trivial.Here's a post about this exact question:https://hackingcpp.com/cpp/recipe/istream_recover_from_errors.htmlNow, with your read() method - it's not clear what exactly should happenif some invalid characters are given on the input.Another alternative is suggesting people use istream::getline() andparse, if they want to handle failures. It's a bit of challenge forabsolute newbies, but it's a surmountable one, so it can be a motivatorrather than a demotivator: If you want to impress your friends in classby being able to handle errors, you could do XYZ.> 3. How do I display graphics on the screen?You may want to read the discussion of this point in a (relatively)recent paper about 2D graphics in the standard library, from 2018:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1062r0.htmlthey essentially argue that this should be easily available as apackage, but not as part of the standard.> 4. How do I do colored text?> 5. How do I read a mouse click?> 6. How do I play a sound?Same question/argument as in the above: Does it make sense for this tobe in the standard, or for there to be an education-focused,ease-of-use-focused, library for these things?> 7. How do I send data over the internet?So, here you could possibly cheat, without a proper library, by usingsystem(), and in it doing something like scp, or sending email and such.You would explain that would not work on any possible system, and isn'tpart of C++, but if your students are also learning to use the commandshell, it might not be terrible to do this. I would strive to avoidstudents using for multiple things or routinely.> 8. How do I split a string?See this StackOverflow question:https://stackoverflow.com/q/14265581/1593077Is it really too hard to get students to write something like this:     auto start = 0;     auto end = str.find(delim);     while (end != std::string::npos) { do_stuff_like_putting_in_a_container( str.substr(start, end - start)); start = end + delim.length(); end = str.find(delim, start); }? Now, sure, this doesn't use ranges, nor <algorithm>, and the choice oftypes is not ideal so it's not the most elegant thing in the world. Butis it that bad? Note that there is no use of C-style strings, nor othermemory-unsafe operations, since we're limiting ourselves to string'smethods.> I've written solutions to 1, 2, 4, and somewhat to 5.Maybe the thing to do is to get more people in C++ education aware ofyour, or others', efforts on this. Perhaps there could be a common"training wheels library", which is not in the standard, but iswell-known enough that educators will likely know about it and use it,and students would be able to have it on their system as one of the OSdistribution packages, or something which comes with their IDE or what-not.-- Std-Proposals mailing listStd-Proposals_at_[hidden]://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2021-08-07 04:35:15