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. |
- Announcement of new C++11 library to handle measures - 10 Updates
- knock knock: my self-documenting code pursuit - 6 Updates
- C++ and Web Services (OT maybe?) - 2 Updates
- Advice from Bjarne Stroustrup - 2 Updates
- Onwards and upwards - 1 Update
c.milanesi.bg@gmail.com: Oct 06 10:38AM -0700 Dombo wrote: > micro-controllers, but I see few problems with judicious use of C++ on > those other than that the benefits of C++ may be less significant for > small programs. According the TIOBE index ( http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html ), there are more than three times as many C programmers as C++ programmers. What kind of software do they develop, if even lowly 8-bit micro-controllers run C++ software? Here I don't want to speak about which language is better, but I heard that C++ is much less used than C (or assembly) language for applications that need to keep code less than 64 KB. However, as I now see so much interest, I will try to keep those platforms into account, but without removing the requirement for some C++11 conformance. -- Carlo Milanesi |
c.milanesi.bg@gmail.com: Oct 06 10:50AM -0700 Öö Tiib wrote: > will be made one way as rule by experienced users. Author has still > to maintain code and documentation (useless work). So better idea > is to consider it beforehand. As I wrote elsewhere, such dynamic units are much less efficient, by at least 6 times, according a rough benchmark. My idea was to avoid any impact on performance when they are not needed. But actually, with current implementation, they have a small impact, as they allocate and fill some small collections at program start-up. Therefore they require some memory for data and some memory for the machine code of "vector", "unordered_set", and the required default memory allocator and exception handling mechanism. For those who want absolutely zero-overhead, implementation has to be reworked. I will work on that. But I wonder if such kind of measures are really needed by anyone. I mean, if an application must let the user choose between inches or millimetres, or between degrees and radians, it is reasonable to force the application programmer to write machine code for just one unit per magnitude, and convert the input value from the unit required by user and to such unit at output, or alternatively, it is better to force the application programmer to generate machine code for all the supported units (possibly using templates)? Here is some sample code that gets from the user the desired unit of measurement, a value in such unit, does some computation (computes the triple of such value), and prints the result in the same unit of the input value. With no library: int unit = get_desired_unit(); double value = get_desired_value(); double result = value * 3; // fast computation print_value_and_unit(result, unit); With dynamically-defined unit measures: int unit = get_desired_unit(); double value = get_desired_value(); dyn_vect1<Space> value(unit, value); // encapsulate dyn_vect1<Space> result = value * 3; // slow computation print_value_and_unit(result); // decapsulate With several cases of statically-defined unit measures: int unit = get_desired_unit(); double value = get_desired_value(); switch (unit) { case inches_id: vect1<inches> value_inches(value); vect1<inches> result_inches = value_inches * 3; // fast computation print_value_and_unit(result_inches); // overload break; case millimetres_id: vect1<millimetres> value_millimetres(value); vect1<millimetres> result_millimetres = value_millimetres * 3; // fast computation print_value_and_unit(result_millimetres); // overload break; } With single case of statically-defined unit measures: int unit = get_desired_unit(); double value = get_desired_value(); // The value is always converted // from the specified unit to inches. vect1<inches> value_inches( convert_from_to(unit, inches_id, value)); // Computation is done always in inches. // fast computation vect1<inches> result_inches = v_inches * 3; // The value of the result is always converted // from inches to the specified unit. double result = convert_from_to(inches_id, unit, result_inches.value()); print_value_and_unit(result); // Unique output routine Which solution is better? -- Carlo Milanesi |
c.milanesi.bg@gmail.com: Oct 06 10:58AM -0700 Geoff wrote: > A proper class to handle these computations would convert scalars to > vectors of the form v = x + iy where iy is zero. Then it would display > Watts if the product had a zero imaginary component and VA if not. The "measures" library has no knowledge of electricity. It just assumes that every magnitude is primitive or it is obtained by multiplying or by dividing two other magnitudes, or by squaring or by taking the square root of another magnitude, it assumes also and that every unit of a magnitude is the only base unit of its magnitude, or it may be obtained by multiplying the base unit by a constant ratio and translating its origin by a constant offset. > I downloaded your source but I have not been able to successfully > compile it. The library is header-only. You just need to include it and compile your source. The other files are there for testing of the library; but to run them, a complex setting is required, not yet documented. To try the library, read the Tutorial document. -- Carlo Milanesi |
scott@slp53.sl.home (Scott Lurndal): Oct 06 06:15PM >o/tpci/index.html ), there are more than three times as many C programmers = >as C++ programmers. What kind of software do they develop, if even lowly 8-= >bit micro-controllers run C++ software? TIOBE data is meaningless. There is 40 years of legacy C code out there, including several operating systems, Oracle's RDBMS and many other very large codebases. Nobody in their right mind would spend the $$ to rewrite it in C++. |
Wouter van Ooijen <wouter@voti.nl>: Oct 06 08:46PM +0200 > But actually, with current implementation, they have a small impact, as they allocate and fill some small collections at program start-up. Therefore they require some memory for data and some memory for the machine code of "vector", "unordered_set", and the required default memory allocator and exception handling mechanism. > For those who want absolutely zero-overhead, implementation has to be reworked. > I will work on that. From the perspective of very small real time systems (microcontroller with Kb's or 10's of Kb's of memory): some small code and data overhead is in most cases not a problem, but such systems often have no heap and no exception handling (which in itself often 'drags in' a substatial code & data overhead), so being forced to have either of those could be a killer for the use of the library in such systems. |
Wouter van Ooijen <wouter@voti.nl>: Oct 06 09:00PM +0200 >> those other than that the benefits of C++ may be less significant for >> small programs. > According the TIOBE index ( http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html ), there are more than three times as many C programmers as C++ programmers. What kind of software do they develop, if even lowly 8-bit micro-controllers run C++ software? There is a big difference between 'the chip *can* run C++' and 'everyone uses C++ on that chip'. IMO nearly all users of C that have a real option (management, compiler, other tools) to use C++ would be better off doing so, even if that would mean using only the 'better C' subset. But eveidently not everyone agrees... > Here I don't want to speak about which language is better, > but I heard that C++ is much less used than C (or assembly) language for applications that need to keep code less than 64 KB. > However, as I now see so much interest, I will try to keep those platforms into account, but without removing the requirement for some C++11 conformance. Those chips (< 64 Kb in your characterization) often deal with pysical values (sensors, actuators, time), so they have ample opportunity to make the errors the library aims probably prevent (and there are benefits beyond just preveting errors). But IME the "let's do it the way we did the previous project, that worked OK' attitude is even more prevalent in such projects than in PC-level programming. I think acceptence in those circles requires that the impact of using the library, especially in code/data size, performance, and secondary requirements like heap and exception handling, is be minimal. Being header-only and not being part of a hughe lib like Boots (whether that is a valid argument or not) is surely a good start. |
Luca Risolia <luca.risolia@linux-projects.org>: Oct 06 09:35PM +0200 Il 06/10/2014 20:15, Scott Lurndal ha scritto: > There is 40 years of legacy C code out there, including several operating > systems, Oracle's RDBMS and many other very large codebases. > Nobody in their right mind would spend the $$ to rewrite it in C++. More importantly, nobody would spend the $$ to write anything similar in C. |
c.milanesi.bg@gmail.com: Oct 06 12:39PM -0700 Öö Tiib wrote: > with such libraries for all that math rather than try to have > the vectors and matrixes and linear algebra reinvented inside > of your library. I think that using my library I can write much more readable code than using a vector algebra library. A problem I actually had when I was developing a typographic application was how to handle positions and displacements on a sheet. Using My library, I can write the code cited at the beginning of this post. Instead, using only one-dimensional measures and the Eigen vector library I should write the following code: // Use arrays to store coordinates. point1<inches> p[2]; vect1<inches> v[2]; vect1<mm> vmm[2]; // Map values to Eigen. Map<Vector2d> pe(&p[0].value()); Map<Vector2d> ve(&v[0].value()); Map<Vector2d> vmme(&vmm[0].value()); // Apply correct operation using Eigen. pe += ve; // Apply incorrect operation using Eigen. vect1<mm> p[2]; pe += pe; // position += position // Apply incorrect operation using Eigen. pe += vmme; // inches += mm // Output one dimension at a time with its unit. cout << p[0] << ", " << p[1] << endl; // Output the whole position, but without unit. cout << p << endl; // It outputs: 13 20" I think that for such kind of tasks, using 2D or 3D unit-decorated variables is invaluable. -- Carlo Milanesi |
c.milanesi.bg@gmail.com: Oct 06 01:34PM -0700 Luca Risolia wrote: > I don't know what other compilers you are considering, but both GCC and > CLANG have been supporting literal operators for quite a while now and > are certainly widely-used and ready for the C++11 era. I wrote *perhaps*. But also Intel C++ compiler one year ago didn't supported user-defined literal operators. > tutorial, I would expect "auto len = 10_m" to unambiguously refer to a > "static relative" measure, while for a temperature "auto t = 10_K", I'd > expect a "static absolute" measure. I don't know why. 10_m can be both a position (i.e. absolute) and a displacement (i.e. relative); and 10_K can be both a temperature point and a temperature variation. > vect1<..., unsigned long long> len = 10_m; // integer literal (ULL) > vect1<..., long double> len = 10.0_m; // floating point literal (long > double) The numeric parameter may be also int, long, float, double, complex, and perhaps some other numeric type. > symbols). I would not say they are so "many". As I deliberately wrote in > my example, you can probably make the SI symbols available under a > specific namespace if you wonder about possible collisions. For every base unit there are 10 multiples and 10 submultiples. And there are many derived units. > > * SI is used a lot, but many non-SI units are still used, and that would open requirements for every unit used on Earth at some time. > True, but IMHO SI is a special case and should be included in the > library from the beginning. I prefer to keep the library physics-convention-agnostic, i.e. independent from conventions established by engineers or physicists. Anyway, such definitions may be added later to the library. For now, you may define your own literals using the macros defined in the following program: #include "measures_io.hpp" using namespace measures; using namespace std; #define DEFINE_VECT_STATIC_UNIT_OPERATOR(Unit, Num, Operator) \ vect1<Unit,Num> operator "" _##Operator(long double n)\ { return vect1<Unit,Num>(n); }\ vect1<Unit,Num> operator "" _##Operator(unsigned long long n)\ { return vect1<Unit,Num>(n); } #define DEFINE_POINT_STATIC_UNIT_OPERATOR(Unit, Num, Operator) \ point1<Unit,Num> operator "" _##Operator(long double n)\ { return point1<Unit,Num>(n); }\ point1<Unit,Num> operator "" _##Operator(unsigned long long n)\ { return point1<Unit,Num>(n); } #define DEFINE_VECT_DYNAMIC_UNIT_OPERATOR(Unit, Num, Operator) \ dyn_vect1<Unit,Num> operator "" _##Operator(long double n)\ { return dyn_vect1<Unit,Num>(n); }\ dyn_vect1<Unit,Num> operator "" _##Operator(unsigned long long n)\ { return dyn_vect1<Unit,Num>(n); } #define DEFINE_POINT_DYNAMIC_UNIT_OPERATOR(Unit, Num, Operator) \ dyn_point1<Unit,Num> operator "" _##Operator(long double n)\ { return dyn_point1<Unit,Num>(n); }\ dyn_point1<Unit,Num> operator "" _##Operator(unsigned long long n)\ { return dyn_point1<Unit,Num>(n); } // Example magnitude definition. DEFINE_MAGNITUDE(Space, metres, " m") // Example user-defined literal definition. DEFINE_VECT_STATIC_UNIT_OPERATOR(metres, double, m) DEFINE_POINT_STATIC_UNIT_OPERATOR(metres, float, mp) int main() { cout << 12.3_m << "; " << 23_m << endl; cout << 34.5_mp << "; " << 45_mp << endl; } It should output: 12.3 m; 23 m [34.5] m; [45] m -- Carlo Milanesi |
"Öö Tiib" <ootiib@hot.ee>: Oct 06 02:44PM -0700 > For those who want absolutely zero-overhead, implementation has to > be reworked. > I will work on that. That is nice. > But I wonder if such kind of measures are really needed by anyone. I was also thinking that those are may be not needed at all. > result_inches.value()); > print_value_and_unit(result); // Unique output routine > Which solution is better? Last. In my high school (ages ago) our physics teacher always demanded us as first thing to convert all assignment data into SI units, then do the math and then convert results to units required for answer. Behaving like that is most robust since we needed only to know the formulas with base SI units and for rest of the units we only needed to know how to convert from/to base SI units. |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Oct 06 12:56AM +0100 On 05/10/2014 21:12, Rick C. Hodgin wrote: > not hear the message. > Not hearing is an exceedingly fearful place to be. My prayer is that each of you will hear, and > come out, and be saved. Have you had a stroke mate? /Flibble |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 06 02:39AM -0700 Mr Flibble, I will reveal to you the character of God: He is of such a love that even though you continually deny Him, and criticize in various ways people like me who teach about who He is, the moment you cry out to Him, the very second you call upon His name, "Jesus, save me!" ... He will do so. Even if it is the last thing you do before being killed upon this Earth. Jesus came to save men's eternal souls from Hell, from the wrath of God which He demands for all disobedience. His love is revealed in that while we were yet sinners, while we were actively denying Him, while we ourselves would've been the ones to drive the nails through His arms and legs, while we walked in such hatred toward Him, He still came here to die on the cross to save us. The One you mock, Mr Flibble, is the same one who will have angels dancing in Heaven if you ever call upon His name. The angels will rejoice as Jesus takes your sin upon Himself, and pays the price of your iniquity for you. It is why He came to the Earth ... to save individuals, whomever will hear Him, and call out to Him. Even you. Even me. "And it shall come to pass that whosoever calls upon the name of the Lord shall be saved." http://biblehub.com/acts/2-21.htm The reason I reach out to you, Mr Flibble, is because His love is in me -- the born again nature. I love you, Mr Flibble. But Jesus loves you more. Best regards, Rick C. Hodgin |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Oct 06 05:54PM +0100 On 06/10/2014 10:39, Rick C. Hodgin wrote: > Mr Flibble, I will reveal to you the character of > God: He is of such a love that even though you [snip] Evolution is proof that your god, Jesus, doesn't exist and also that you are deluded, mate. /Flibble |
Christopher Pisz <nospam@notanaddress.com>: Oct 06 02:40PM -0500 On 10/6/2014 11:54 AM, Mr Flibble wrote: > Evolution is proof that your god, Jesus, doesn't exist and also that you > are deluded, mate. > /Flibble Someone had mentioned a kill file at some point. How do I set one up in Thunderbird, so I don't have to read the religious arguments between Fibble and Rick Hodgin? |
Ian Collins <ian-news@hotmail.com>: Oct 07 09:03AM +1300 Christopher Pisz wrote: > Someone had mentioned a kill file at some point. How do I set one up in > Thunderbird, so I don't have to read the religious arguments between > Fibble and Rick Hodgin? Tools->Message Filters -- Ian Collins |
Christopher Pisz <nospam@notanaddress.com>: Oct 06 03:58PM -0500 On 10/6/2014 3:03 PM, Ian Collins wrote: >> Thunderbird, so I don't have to read the religious arguments between >> Fibble and Rick Hodgin? > Tools->Message Filters Sweet! I can also get rid of all those "the quaran says" spams too! You made my day Ian. |
woodbrian77@gmail.com: Oct 06 09:08AM -0700 On Friday, October 3, 2014 8:40:53 AM UTC-5, Scott Lurndal wrote: > byte, whereas a binary version may consume four bytes > (depending on the desired magnitude of the value in the > binary stream). A binary version may just need one byte if you're using a variable-length integer format. I think games that have a lot of numeric data usually use a binary format to communicate. Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
Christopher Pisz <nospam@notanaddress.com>: Oct 06 02:45PM -0500 On 10/2/2014 4:10 PM, Richard wrote: > If you want to supply a restful API from your C++ based server, then > you might want to look at this stack overflow thread: > <http://stackoverflow.com/questions/15183232/library-for-restful-api-in-c> I've got a REST architecture in. It really isn't the best for relational data, I am finding, because you have to make so many calls to first get the data that tells you what other data you might be interested in. The SOAP based ones seem better in that regard in that there is usually some method with an argument list which could be a collection of foreign keys, rather than a URL that ends up having a parameter list 1000s of arguments long. But it ends up, I have to support almost any feasable way someone would want to give me data. So, I need Rest and Soap. I did find Microsoft evidently created a native C++ web services library and it was super easy to use and very clean compared to Gsoap, but there seems to be issues with getting it from them for pre windows 7 machines. |
legalize+jeeves@mail.xmission.com (Richard): Oct 06 06:46PM [Please do not mail me a copy of your followup] At the end of each chapter in "The C++ Programming Language", 4th edition, Bjarne Stroustrup has a list of advice. I found the advice very helpful and decided that the advice should be online somewhere. Initially I put this together as a PPT presentation, but oh my lord, it was too long. Instead, I made a page in my user space on the cppreference.com wiki: <http://en.cppreference.com/w/User:Legalize/Advice_from_Bjarne_Stroustrup> This let me link to other pages on the wiki describing specific language features where possible. Hopefully you will find it useful. -- "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> |
woodbrian77@gmail.com: Oct 06 12:18PM -0700 On Monday, October 6, 2014 1:46:14 PM UTC-5, Richard wrote: > At the end of each chapter in "The C++ Programming Language", 4th > edition, Bjarne Stroustrup has a list of advice. I found the advice > very helpful and decided that the advice should be online somewhere. He knows how to put things on line himself. If I had written that book, I wouldn't appreciate your taking it upon yourself to put part of the book on line. I suggest you remove the content. Brian Ebenezer Enterprises http://webEbenezer.net |
woodbrian77@gmail.com: Oct 05 08:17PM -0700 I tried rewriting this: bool found=false; for(auto const& acct:accounts) if(acct.number==request.accountNbr){found=true;break;} if(!found)throw failure("The following account number is not logged in: ") <<request.accountNbr.value; using a lambda: if(::std::none_of(accounts.begin(),accounts.end() ,[&] (cmw_account_info const& a){return a.number==request.accountNbr;})) throw failure("The following account number is not logged in: ") <<request.accountNbr.value; The two versions have the same text size according to the size command. I think the first version is easier to understand. Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.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:
Post a Comment