??? 10/24/08 17:49 Read: times |
#159315 - Yes, you can Responding to: ???'s previous message |
Do you really mean "implicit" cast or "explicit"?
When reading from raw hardware (serial data, EEPROM memory etc) you will just get raw binary values. The question is how much you should have to fight to make use of them, since the contents often represents integers, enumerators and different complex data structures. Before the pointer extensions in Turbo Pascal, it was very, very, very hard to really manage to do real things - such as transmitting a real data type into a byte stream and restore it to a real data type on the other side. A C program don't play with "fancy stuff" unless there is a need - and the need will be there just as well if you use Pascal. Pascal does not have any magic byte-stuffing operator that can invisible perform data conversions into the required formats when working with real existing hardware. Somewhere, you just have to write the code. With C, it is business as usual. With Pascal it is: Now we do our best to leave the language - as defined by Wirth - and plays with our knees using constructs that are not really in symbios with the rest of the language until we manage to get the type conversions done. With standard Pascal, it takes a huge amount of work, since it isn't really a general-purpose language even if Turing-complete. With the Turbo Pascal extensions, you have to fight way less, but you do have to stretch the use a bit. A "hello world" application does not contain any real obstacles. If on the other hand writing an editor to allow editing of a text file way larger than the available RAM and with any-size text lines, you will notice that the Pascal language constructs will have to be stretched a bit. The same happens if you implement floating point support. Or writing code to feed one or more DSP co-processors... In the end, you will often end up having to use the Turbo Pascal extensions (that does introduce similar type-cast pointer-manipulation behaviour as you obviously dislike in C). You can always find broken applications in any language. The question is how large vocabulary you should have at your disposal when writing an application. Pascal often have a bit too small vocabulary. C++ often have a bit too large vocabulary. A too large vocabulary can be handled by using only a subset (basically what MISRA does). A too small vocabulary on the other hand can be harder to get around. I regularly hear people complaining about C pointers. But if I look through the open and closed Bugzilla entries for the last year (about four man-years of C/C++ coding), I see one single bug that might possibly be called pointer or typecast-related. None relating to buffer overflows. Don't you find that a bit strange? What is showing up all the time is incorrect behaviour - to a very large part because the customers made requests that was not really in line with what they really wanted... I can't see any indication that a change of programming language would make any real difference. Requiring our customers to spend more time thinking about there change requests would. The pointer errors I now-and-then manages to produce - and that gets immediately caught by the compiler warnings - is to use printf() with wrong number of parameters in relation to the formatting string. But these errors are so obvious that they never manage to get into the committed code base. They get located and fixed almost as quickly as the compilation errors. The problem in this world, isn't so much the language used, but the usefulnes of the language for the specific task, and the amount of time used to really learn the language. Java got introduced with the note that it does not contain pointers. That is probably why so large a percent of Java programs ends of producing funny NULL pointer exceptions. C programmers tends to write their code based on the knowledge of pointers - everyone is always spending their time telling them about minding their pointers. Many Java programmers tends to write their programs based on the assumptions that there are no pointers. But that isn't a problem with a language, but with the eduaction and how people are motivated to use the language. Yes, I have spend several years writing programs in Turbo/Borland Pascal (but none with Delphi). It is an excellent language. I have also used Java and a number of other languages. The world is full of well working languages, giving people the choice to find one suitable for the task. I just hope that people who do speak about a language have made really big attempts to try and use the language to the fullest before trying to tell other people what language they should not use. |