Posted: Wed Oct 29, 2008 12:11 pm Post subject: Re: RE:scanf - integer to string
btiffin @ Sat Oct 25, 2008 12:02 am wrote:
Rigby5 @ Fri Oct 24, 2008 2:43 pm wrote:
The I/O libraries of C++ are simply not good at precise formatting of output.
Ever try to output good looking tables of data?
C++ is not more complex in general.
It is easier.
With C we had to work with function pointers and massive switch statements, that C++ does behind the scenes.
But C++ is not good for output.
You do not want C++ deciding data types, you want to do that yourself, when it comes to output.
The main advantage of C++ is modularity.
Functions are grouped with the associated data.
With C, it is as if all functions are global.
And that's just one of the many class interfaces available. STL and extensions add even more candy.
Cheers
I still disgree.
Sure you can set the width, but only for a single output object at a time.
If you have a dozen things to output on a line of a table, that is a real pain.
C does is easier and more clearly controlled, because you can do dozens of variables in one printf.
The formatting is associated with each variable, and not with the output steam object.
I don't know anyone who uses the C++ I/O operations.
Sponsor Sponsor
btiffin
Posted: Wed Oct 29, 2008 5:32 pm Post subject: Re: scanf - integer to string
Quote:
I still disgree.
Sure you can set the width, but only for a single output object at a time.
If you have a dozen things to output on a line of a table, that is a real pain.
C does is easier and more clearly controlled, because you can do dozens of variables in one printf.
The formatting is associated with each variable, and not with the output steam object.
I don't know anyone who uses the C++ I/O operations.
Disagreeing is a good thing, imho. The computer field is a vast, wide and deep field with tools that'll float just about any boat.
old guy ramble follows
I've only worked C++ on one serious large scale project. I'm not a particular fan of C++ as I feel the complications involved require above avergage programming and management skills. BUT, for above average developers, C++ can build awesome environments for other programmers that follow or assist in projects. The KDE system, is huge and unwieldy, but it has a layer now that is very amenable to most programmers and useful "good" applications can be built fairly quickly. All due to efforts of some above average programmers that laid down foundations.
So, the system I did work on, we built a very useful output stream that you could throw just about any data at, and configuration controlled the final look. With C you are constrained to functional I/O, C++ can be used to build some very clean and useful toolkits. I was distressed at the time, watching how fragile the tool was when normal IQ coders were tasked with building the foundations, not simply using those foundations, but hey, large corporations can somewhat afford the luxury of building tools that make the next application more powerful and easier to deal with.
Sadly, our industry is usually chasing the next shiny new ball, so many of these corporate toolkits are tossed before the end of the first project, and not built upon as Bjarne actually intended when C++ was on the drawing board.
In comes down to the moldy old expression, Your Mileage May Vary. And in my not so humble opinion, programmers are far more productive using tools they "believe in", and all the bells and whistles and tools and technology are completely secondary, contrary to what management may believe when forcing tools on or dictating environments for developers. So for anyone free to choose, go right ahead and choose. You'll build better programs using tools you like than using tools your buddy may think is the best thing since sliced bread (unless of course, you happen to believe that as well). Having said that, if you are not free to choose then suck it up and make the best of it. Leave the negativism at home, on the shitter, between friends over drinks or here on the forums. A complainer can taint an entire project with useless and counter-productive bitching. It is best to be the positive bright light in whatever task is at hand and management will likely take notice. I say this having been a negative nelly on occasion ... it doesn't help.
Cheers
edits; typos and corrections
Rigby5
Posted: Fri Oct 31, 2008 11:51 pm Post subject: RE:scanf - integer to string
The point is that in reality, with C printf you can do a format and output a whole table row in a single simple instruction.
While in C++ it could easily take 20 instructions.
It takes 1 instruction to set the width for every single variable, and you have to output one variable at a time, in its own instruction.
C printf is then at least 10 times easier and faster to use to format output then cout.
btiffin
Posted: Sat Nov 01, 2008 12:34 am Post subject: RE:scanf - integer to string
Well, yes with the "stock" manipulators. Or (with some coded toolkits) one line of code can set an option and then stream as many variables as you can pack on a line, all formatted to the particular bosses' liking or to a dataform or ...
That level of usability does not come for free, but it's possible. And that is how Bjarne envisioned C++ in my humble opinion. A compiler for building tools that build apps. Many coders go straight from C++ to app, so they really do lose out on the potential. But that potential (as I mentioned before) is not for the faint of heart or the impatient. It all comes down to choice. Personally, I avoid C++ as I don't have the level of discipline to use it effectively. So I pick other tools. The YMMV dealy.
Cheers
Edit; and we risk getting in trouble with the good folks of compsci.ca, dragging this thread so far off topic. We can argue the ++ or -- of C and C++ for decades. Which I'm always up for, but this is getting less and less fair to Ktomislav if he tries to glean any usable info from his thread now.