home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / proscons.zip / dts.txt < prev    next >
Text File  |  1995-03-15  |  8KB  |  166 lines

  1.  
  2.    The (highly unofficial) FIDONET OS2PROG C++ compiler pros and cons list
  3.    ───────────────────────────────────────────────────────────────────────
  4.  
  5.                           What is DirectToSOM C++ ?
  6.                           ─────────────────────────
  7.  
  8.     To understand what DirectToSOM C++ is, you must first understand what
  9.     SOM, IBM's System Object Model, is.
  10.  
  11.     SOM is a language-independent foundation for classes and objects.  It
  12.     defines a run-time environment to use for creating, destroying,
  13.     instantiating, and generally manipulating classes.  It uses CORBA IDL
  14.     for writing class definitions.
  15.  
  16.     One idea behind SOM is that class support need not be language or
  17.     compiler specific.  Most object oriented languages until now have had
  18.     proprietary runtimes for their class systems.  SOM provides an open
  19.     binary standard interface for class support at runtime which any
  20.     language can use, and the SOM toolkit contains tools to translate
  21.     class specifications in IDL into "language bindings" that allow those
  22.     languages to use and implement SOM classes.
  23.  
  24.     Any language that can call functions through pointers can use SOM, so
  25.     using SOM classes is even possible in C. The C language bindings use
  26.     an incredible number of macros to try to make the class system seem as
  27.     sensible as possible, and to try to hide all of the pointers used for
  28.     method accesses.
  29.  
  30.     Another idea behind SOM is to separate class implementation and class
  31.     use by providing a binary layer that they both adhere to.  SOM sets
  32.     several rules, which, if they are abided by, mean that it is possible
  33.     to change the implementation of a class and add new data or function
  34.     members without affecting the client in any way.
  35.  
  36.     DirectToSOM is the logical next step to take with SOM.  Instead of
  37.     using syntactically obscure language bindings, the compiler takes your
  38.     source written in your native language and compiles it into object
  39.     code that uses the SOM runtime for class support, instead of a
  40.     proprietary class runtime specific to that compiler or that language.
  41.  
  42.     A DirectToSOM C++ compiler can take normal C++ source and compile it
  43.     to use the SOM runtime directly, instead of the proprietary C++
  44.     runtime.  This means that it is possible to take a normal C++ class
  45.     and make it into a SOM class simply by compiling with the appropriate
  46.     compiler switches.
  47.  
  48.     Another route is to change the C++ class definition so that it
  49.     inherits from an existing SOM class, such as the predefined SOMObject
  50.     class.  Here, for example, is such a SOM class written in DTS C++ :
  51.  
  52.       class BankAcount : public SOMObject {
  53.       public:
  54.           long balance ;
  55.       } ;
  56.  
  57.       int main ( int, char ** )
  58.       {
  59.           BankAccount account ;
  60.       }
  61.  
  62.     It looks just like C++, doesn't it ?  Compile it, though, and you
  63.     should even be able to use it from SmallTalk.
  64.  
  65.     For a C++ programmer, DirectToSOM C++ is the easiest way to use SOM,
  66.     because there is very little new to learn.  You just write C++ code as
  67.     you always have done.
  68.  
  69.     What are interesting, though, are the advantages that DTS C++ has over
  70.     normal C++ because it uses SOM.  Certainly, DTS C++ gives (to coin a
  71.     phrase) "a better C++ than C++" in a lot of respects.
  72.  
  73.     In normal C++, two C++ compilers cannot share code at any level below
  74.     source level.  There are many reasons for it being impossible,
  75.     including the facts that most C++ compiler vendors use different name
  76.     mangling schemes, different parameter passing conventions, different
  77.     run-time support functions in the standard library, and different
  78.     run-time data structure layouts for things like virtual function
  79.     tables and inheritance.  This means that all C++ class libraries are
  80.     required either to be compiled with every individual C++ compiler that
  81.     they wish to support, or to be distributed in source form.
  82.  
  83.     Two DirectToSOM C++ compilers, however, can share code at the binary
  84.     level, since SOM is a binary standard.  You can compile a DTS C++
  85.     class into a dynamic link library and distribute it; and as long as
  86.     the class definition is shipped along with it, any DTS C++ compiler
  87.     (or even any other SOM-capable language) can use that class.  There
  88.     are no name mangling issues to worry about when compiling a DTS C++
  89.     class into a DLL either.  A DTS C++ class requires exactly three
  90.     export entries, none of which have mangled names.
  91.  
  92.     SOM comes with several such class libraries (or "frameworks") already.
  93.     The Persistence, Replication, and Distribution frameworks are little
  94.     more than libraries of SOM classes, and are distributed as a suite of
  95.     DLLs, along with IDL class definitions so that people can use them.
  96.  
  97.     Other features of DTS C++ not found in C++ but familiar to object
  98.     oriented programmers who use other languages are metaclasses and
  99.     attributes.
  100.  
  101.     Classes are "first class objects" in SOM, meaning that every class is
  102.     itself an instance of another class, the "metaclass".  Metaclasses
  103.     have methods that are used for various things, and metaclass
  104.     programming with DTS C++ opens up a whole new area at runtime not
  105.     normally available to the C++ programmer, including such abilities as
  106.     adding new methods to classes at runtime, and controlling class
  107.     instance placement and construction.
  108.  
  109.     Attributes provide more control over instance data for classes, such
  110.     as the ability to make it read-only.  Here is the above example, with
  111.     an attribute :
  112.  
  113.       class BankAcount : public SOMObject {
  114.       public:
  115.           long balance ;
  116.           #pragma SOM_Attribute(balance)
  117.       } ;
  118.  
  119.       int main ( int, char ** )
  120.       {
  121.           BankAccount account ;
  122.           account.balance = 100 ;
  123.       }
  124.  
  125.     One of the more interesting things possible with attributes are that
  126.     it is possible for a class to intercept all read and write accesses to
  127.     an attribute, by providing "get" and "set" member functions for that
  128.     attribute, which are invisible to the client.
  129.  
  130.     DTS C++ also has a more extensive run-time type information (RTTI)
  131.     system than C++.  All classes are actual physical entities at run-time
  132.     with SOM, and not mere compile-time abstractions.  This allows you to
  133.     traverse the class hierarchy at run-time and find out a lot of
  134.     information about instance types.
  135.  
  136.     DTS C++ compilers also allow you to use C++ language facilities that
  137.     aren't normally part of SOM, such as function overloading, exception
  138.     throwing, and abstract base classes.  DTS C++ compilers map these
  139.     C++isms onto SOM as gracefully as possible (if non-C++ SOM client
  140.     tries to instantiate an abstract base class, a run-time error results,
  141.     for example).
  142.  
  143.     This is especially useful where DTS C++ is being used as an
  144.     enhancement to C++ instead of as as a means of using SOM itself.  This
  145.     could be the case where the greater separation between class
  146.     implementation and class use that SOM affords is desirable in a C++
  147.     application, for instance.
  148.  
  149.     SOM is already used by several applications.  The Workplace Shell is
  150.     almost entirely a set of SOM classes (such as WPFolder, WPProgram, and
  151.     WPShadow), and all WPS extensions are new classes derived from
  152.     existing WPS classes.  IBM Works, and several of the BonusPak
  153.     utilities like Ultimail rely on SOM.  SOM is the intended basis for
  154.     the Taligent Application Frameworks as well.
  155.  
  156.     DirectToSOM C++ was co-developed by MetaWare and IBM.  MetaWare is
  157.     currently on to the second release of its DTS C++ compiler, High C++
  158.     version 3.31.  IBM is currently beta testing its first DTS C++
  159.     compiler, CSet++ version 3.0.  There has been no word as yet from
  160.     Watcom on when it will support DirectToSOM C++.
  161.  
  162.     See the Pros and Cons list for contact information.
  163.  
  164.    » JdeBP «               » (c) Copyright 1995 All Rights Reserved. «
  165.    » JdeBP@donor2.demon.co.uk                      FIDONET 2:440/4.0 «
  166.