Hello all, I have been following the recent clashes between various participants (see the post "Compiling differences between C51 v7.03 and v8.06" or "introducing the smoked sardine complex" :) :) ). C was given, I think, a unjustified bash in that post. I wouldn't like to have been compelled to explicitly cast too often. Most potentially dangerous casts can be filtered out by a static code analyzer. Can you give an example of more strongly-typed languages than C that are used in embedded development?
Can you give an example of more strongly-typed languages than C that are used in embedded development?
That's a tough one. Strongly-types languages are usually also high-level, and those are used rarely in "small" embedded systems.
Java and Pascal would, for example, be somewhat more strongly typed than C.
Python (rarely used in small embedded systems, but useful on the PC side) would be strongly typed.
I have never used Pascal, but know there is/are Pascal compiler(s) for the '51.
The C vs Pascal discussion always center around the question "do you want 'freedom' or do you want the compiler to protect you against yourself"
Erik
I have programmed quite a lot in Pascal.
The feeling is: How much time do I have to spend to get past the compiler, i.e. how to fool the compiler enough so that I can do my job.
Some of my problems does come from Turbo Pascal, that didn't had variant-sized arrays, so the user had to either switch to the Turbo Pascal typeless pointer type or declare new arrays at the same location as an array of a different size.
I have never seen any problem that C has too weak type checking. The biggest problem for people is that pointers and arrays are almost identical in concept, and that this makes it almost hopeless to let the compiler (or runtime) perform out-of-bounds checking on array indices. This should not be a problem if people always keeps track of their buffer sizes and makes use of the correct functions for doing different things. Nothing wrong with strcpy(), sprintf() etc but strlen(), strncpy(), snprintf() do help a lot.
I have never seen any problem that C has too weak type checking.
I agree. C simply requires the programmer to be competent with his tools.
Yes, that is the fundamental philosophical difference between 'C' and Pascal:
'C' requires the programmer to be competent with his tools - it has a "You asked for it, You got it" paradigm. 'C' gives you a powerful weapon - it's up to you not to shoot yourself with it.
Pascal originated as a teaching language; it insists that you state your intentions absolutely explicitly at all times - the theory being that this should force you to think more carefully about precisely what your intentions really are...
Of course the risk is then that you end up not being able to shoot anything at all!
View all questions in Keil forum