swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Turbo C Graphics Library use in Swarm


From: Alex Lancaster
Subject: Re: Turbo C Graphics Library use in Swarm
Date: 26 Mar 2002 03:26:07 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

>>>>> "TP" == Trushar Panchal <address@hidden> writes:

TP> Hi, I am wondering if I can use Turbo C libraries in Swarm. I am
TP> having difficulties in programming in Swarm and have written
TP> program in simple C and now want to convert it into Swarm. Can
TP> anyone give some suggestions how to do this.

You almost certainly won't be able to use the Turbo C graphics
libraries in Swarm, and if you can, it probably won't be worth the
effort.  If you're dead-set on using your original C code, what I'd
suggest is a two step strategy:

1. Isolate the existing code to the part which makes as little use of
   any Turbo C library-specific functions.  Remove or replace that
   code with purely ANSI C compliant-code as much as possible, then
   compile with it GCC (the GNU Compiler Collection - if you're
   running a Win32 system you can get it as part of the Cywin ports of
   the GNU toolchain: http://www.cygwin.com).

2. Once you've reached that stage you'll be in a much better state to
   start porting the C code to Swarm (i.e. wrapping the C into objects
   etc.) since Swarm uses GCC.

A better alternative is to start from scratch, writing Objective C and
borrowing the main algorithms from your original C code.  This seems
like a longer way, but in the long run you will thank me for
suggesting it.

It's much easier to start writing object-oriented code from the
ground-up, and abstract the original algorithms from your C code and
then re-implement them, rather than trying to shoe-horn existing code
into an object oriented framework.

If you're having problems with Swarm, a tip: study a *single*
application (like heatbugs, mousetrap) and understand what *every*
line of code is doing.  What I see a lot of people doing is using an
application as a high-level "template", hoping they can just tweak a
line or two there to get the desired effect, and hope that all the
rest of the code will sort of take care of itself.

Sometimes it's possible, for very simple adaptations of an existing
application, but falls down when you try and introduce any significant
new data structures.

I'm not saying you need to understand every line at once, take some
time to discover what each class and method does in isolation and then
together, but ultimately you should be able to say what every line in
the code is there for.  It'll take a while, but ultimately you'll be
able to write more powerful applications.

Alex
-- 
  Alex Lancaster           |  
  Swarm Development Group  |     web: http://www.swarm.org
-------------------------------------------------------------------

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]