[prog] School problem, C++ and cout.precision(2);
Ganesh Swami
ganesh at rapidtech.bc.ca
Sat Nov 23 04:12:45 EST 2002
hello,
Robert J. Hansen wanted us to know:
> As a word of warning: I'm a certified language zealot. My two preferred
> languages are LISP and C++; C++ for when I need fine-grained control
> over hardware and LISP for everything else. I've been a C++ programmer
> for thirteen years now.
Goody ! Thirteen years back, I still had the thumb in my mouth ;-)
> > How many people use C++ completely ? Actually very few. Is it worth
> > learning Templates and other advanced C++ features ?
>
> Absolutely. No templates = no STL. No STL = you're not using the best
> feature, IMO, of C++.
>
> > I consider Qt/KDE to be a very good C++ library. It uses exactly what is
> > required. No more bloat. But still they cant beat the overheads.
>
> The `overhead' of C++ is largely a myth. There's a hard and fast rule
> in the C++ community: You Don't Pay For What You Don't Use. If you
> don't use templates, you don't suffer the runtime penalty for them; if
> you don't use vfuncs, you don't suffer the runtime penalty for them;
> etc. YDPFWYDU--which is pretty much C++'s answer to Perl's TMTOWTDI--is
Absolutely. A C program thru a C and a C++ compiler should yield similar
results.
> sometimes ignored by compiler authors. For instance, Sun's compiler was
> for years infamously bad with templates; the most trivial use of
> templates could bloat code size by over a meg.
Hmm...How do Microsoft's compiler fare ? Do they add their /custom/
extensions ?
> On the other hand, though, GCC 3.2 is acceptably good. The /linker/ is
> still horrible, but the compiler is pretty good. Under glibc, C++
> programs often have unacceptable startup times because of some pretty
> poor linker behavior. The GCC crew is trying to address this issue.
So, is GLIBC the library that implements C functions like *printf() ? I
find KDE to be real fast under FreeBSD. Is it because FreeBSD does not
use GLIBC ?
>
> > I believe C++ comes with its own classes for implementing stacks, hashes
> > and other data structures. Does anybody use them ?
>
> All the time. Using them has probably doubled my productivity and
> halved my bugs. No, I'm not kidding.
Maybe thats why we have some die hard fans for Delphi. It provides units
for everything.
> > I personally do not like streams. Its more trouble than ease. And, I
> > love strongly typed languages (you can call PHP an exception ;-))
>
> C++ is a strongly typed language, which is why in the archives I was
> surprised to see you using C-style (typeless) casts. C++ provides
> typesafe casts.
I have been largely ignorant of C++. Time to play 'catchup'.
Do you still deal with complex pointer arithematic ? I dont mean simple
stuff by pass-by-ref, but like using arrays and lists. I thought people
jumped to Java, because it was more difficult to make pointer mistakes.
But, I dont know Java too....so I may be wrong.
> As a short example of some C++ which makes full use of templates and the
> STL...
> =====
<snip code I dont understand>
> =====
>
This is greek to me.
> As another example, Codebook--a GnuPG GUI that I'm working on--uses
> templates, objects and virtual function calls extensively. All three of
> them are usually considered to be bloatware. But Codebook manages to
> come in at under 180k, which isn't bad at all for an app.
So which GUI framework are you using ?
-- Ganesh
--
: _ /~\'_
(o o)
=====oooO==U==Oooo================[Ganesh Swami]==========
Well, to be Frank, I'd have to change my name.
More information about the Programming
mailing list