From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9e2776c05028676e,start X-Google-Attributes: gid103376,public From: pvanbell@mhv.net (Paul Van Bellinghen) Subject: Why Ada is not the Commercial Lang of Choice Date: 1997/06/13 Message-ID: <33a1c14d.155787285@news.mhv.net>#1/1 X-Deja-AN: 248907295 Organization: MHVNet X-Server-Date: 13 Jun 1997 22:50:55 GMT Newsgroups: comp.lang.ada Date: 1997-06-13T22:50:55+00:00 List-Id: I've been a real-time embeded Software Engineer since 1975. I've used assembly,Pascal & Fortran (not in real-time), C, and now Ada. I think that there are basicly two reasons why Ada did not replace C as the real-time embeded language of choice - in the commercial world and recently in the military. 1. Ada is not and never was a programmer's language. It was never meant to be. It was imposed upon companies that the DOD contracts in an effort to create more reliable (i.e. bug free) products. They saw how much time and money was spent in fixing problems after a system was delivered and operational in the field. It is excessivly type-casted and cumbersome to use. 2. Ada is realy a high level language. C is more intermediate level. This makes C more well suited to real-time embedded systems that are really electronic products that use microprocessors to control electronic devices in a functional manner. It is much easier in C, for example, to output a data word to an I/O device that is memory mapped. One need only define a pointer and assign it the memory mapped address, then store the desired data value to the contents of the pointer. #define mem_map_addr B0100040 unsigned int *p; p = (unsigned int *) mem_map_addr; *p = 0x00344556; In Ada you can either define P to be an access variable of type unsigned interger (if this type is defined in your compiler as mod 2**32 for example) and assign it the address or else, if you know the exact address you want to assign it, define it as type address (from machine types) and just assign it the desired address to it (for p use at B0100040, etc..) and then assign it the data value. This is not so bad. However, now try to perform some manipulation on the address value. Suppose you had to mask off the lower 48 bits of the address to get the start of the memory sector, as I had to do recently. in C: unsigned int *sector sector = (unsigned int *) ((unsigned int) p & 0xFF000000); notice the easy way you can re-cast variables. In Ada, I had to define sector as an access variable of type internal_address which was defined as unsigned integer (mod 2**32) within the appropriate range of memory values. I defined p to be of type internal_address, not of type address since address type has no operations associated with it in machine_types (I probably could have defined these myself, I guess). I needed an unchecked conversion function to convert type address (I was stuck with this type since I was implementing my own version of a procedure (that input address types) to write to EEPROM memory in a target debug monitor) to internal_address. After converting the memory address to internal_address via the unchecked conversion function, I was then able to mask off the lower 48 bits (I originally used a logical "and" function but switched to using the V_I_BITS package to keep it compatable with Ada 83). Now I was able to assign sector address the resulting internal_address value of the sector.