To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 1941
1940  |  1942
Subject: 
RE: legOS and alternate operating systems [now off topic]
Newsgroups: 
lugnet.robotics
Date: 
Wed, 30 Dec 1998 23:15:06 GMT
Original-From: 
John A. Tamplin <(jat@)NoMoreSpam(traveller.com)>
Viewed: 
1245 times
  
On Wed, 30 Dec 1998, Norman Fair wrote:

Actually, this does concern Legos programming.  There is only so much
memory in the RCX, so you have to program very efficiently.  You have to be
able to squeeze a program in there.

What I meant in my previous post is, when you linked in a "traditional"
library it only linked the routines you actually used, not the entire
library.  But with object oriented you link in the entire class, even if
you only use one or two methods.  Plus you have to link in all the classes
that the class you are using is inherited from.  That can be a great deal
of overhead.  The typical "Hello world" program for Windows using C is only
a couple kilobytes, about the same as a DOS version.  If you write it in
C++ (worse yet, with Windows wrapping classes such as Microsoft Foundation
Classes), your program will start with at least 100k or more of size.

A "Hello World" program is hardly a valid example for RCX programming.  That
particular example is also unfair to C++ since iostreams have far more power
than the equivalent C libraries.

I have written an embedded multithreaded kernel for a 68020 IO processor
in C++ that fit in 16k ROM with tons of room to spare, and that was far
from a trivial program.

Regarding linking issues which pull in large amounts of unused code, the
issue is the same in C and C++.  If I write a library, I will typically put
every member function in its own object file, just as I would in C.  In fact,
C++ is better in that regard since you can have restricted scope for statics
that span multiple source files, which you can't do in C.

If you use runtime polymorphism, C++ will create vtables for you, and those
certainly take up space.  However, if you were to need the same functionality
in C, you would either do the same thing or something less efficient (such
as putting the function pointers in the structure rather than in a vtable).
C++ certainly adds code if you want to support exceptions, but since C
doesn't have exceptions this seems hardly fair and you can turn it off
for C++ and in some cases the error checking code it replaces is larger.
Widespread use of templates without factoring out common code into other
classes can cause code bloat, but so can copying one source file and changing
int to char * and changing the names on the functions, which is essentially
the sort of thing templates do for you.  If you make use of the layers of
abstraction that an OO language makes easy to do, you will generally pay
some price for that.  However, it is no more than the price you pay for
implementing the same layers of abstraction in a non-OO language.

The original C++ compilers produced C as their output, so it is ludicrous
to say one is more efficient than the other.  The C++ compiler simply
generates code for you at your request.

Programmers can write sloppy and inefficient code in whatever language
they desire.  A previous post in this thread saying that OO programming
encourages replication rather than abstraction seems without basis, since
I actually find it easier to make abstractions in an OO language.

BTW, the GCC tool chain you suggested was written in an oject oriented
language is written entirely in C.

John A. Tamplin Traveller Information Services
jat@Traveller.COM 2104 West Ferry Way
256/705-7007 - FAX 256/705-7100 Huntsville, AL 35801

--
Did you check the web site first?: http://www.crynwr.com/lego-robotics



Message is in Reply To:
  RE: legOS and alternate operating systems [now off topic]
 
Actually, this does concern Legos programming. There is only so much memory in the RCX, so you have to program very efficiently. You have to be able to squeeze a program in there. What I meant in my previous post is, when you linked in a (...) (26 years ago, 30-Dec-98, to lugnet.robotics)

4 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR