learning C
Werner Schiendl
ws-news at gmx.at
Fri Mar 9 05:38:46 EST 2001
> I think you have a different definition of "embedded" from me
> (admittedly it's a broad term). C is still in wide use in the industry I
> work in (which produces small, hard real time systems).
We have a large existing codebase for that systems in C and still a lot of
new stuff is done in C.
Yes, and we have one more proprietary platform that only supports C with
some very limited (and of course non-standard) libraries.
We ask for C++ support every other week ;-)
> This is unlikely
> to change in the near future: C++ is perceived as being slow and unsafe.
Why should C++ be slower than C if you restrict yourself to features that
perform well.
If you do dynamic_casts everywhere, pass huge objects by value it gets slow.
But this is simply poor design.
I admit that it is far less obvious in C++ than in C than something will
become slow.
But sometimes it is really neat to be able to copy objects in a defined
manner (without having to invoke a helper function for that stuff).
Unsafe is somewhat the same topic I think: It's a question of disciplined
use.
C++ is not a toy language like VB may be for some guys - you need to know
what you are doing.
> There's the feeling that you never quite know what it's going to do. By
> contrast, C compilers are pretty efficient and what they'll end up
> producing is more or less in line with what you'd expect from looking at
> the code. C itself can be unsafe, of course, but by using restricted
> subsets of the language you can help with this somewhat (banning dynamic
> allocation is common, for example).
You can have the same in C++ (using one or more static objects, or construct
the objects just once when booting)
This is nothing more difficult than in C.
One of the particular unsafe things in C is error handling, at least for a
larger application.
C++ exceptions at least make sure the error _is_ handled somewhere and does
not cause strange behaviour that is hard to debug.
>
> I don't think these systems are simple. If they were, writing them would
> be a lot easier.
>
This is what I said, and why I think some well designed objects can ease the
stuff.
> >I personally use embedded platforms and C++ is readily available there
> >(VxWorks, to be precise).
>
> ObFourYorkshiremen: You had an OS? You were lucky! In my day we had some
> interrupts and timers, and we liked it! (Actually, my current project
> does have an OS: such luxury :-)
If there is no C++ compiler you cannot use it, nothing to add...
regards
werner
More information about the Python-list
mailing list