Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ASCII vs binary - holy war...




Another contribution to the ASCII vs binary controversy...

Some people (hello, Carl!) want to have an ASCII protocol for CrossFire,
mainly because it would be easier to implement it on various systems (MACs,
PCs, etc.).  Well, I disagree with that, and here is why:
- It won't be easier to parse ASCII data.  You will have to keep a table
  with all commands and do several strcmp's to find the one that matches.
  Then you will have to convert all numbers from ASCII to binary.
- If you send binary data, you can have fixed-length blocks in you packets.
  Each block begins with the command number on 1 or 2 bytes (very easy to
  parse, you only need to use a switch statement) and the following data is
  already in binary form.  No conversion is necessary, unless the byte order
  is different (and it's easy to handle that case).
- Binary will be much more compact.  Compare the number of bytes needed in
  each case for a map update, for instance.  In an ASCII packet, we will have
  the following things: command name (5 to 15 bytes), newline (1 byte),
  first coord (2 to 4 bytes), space (1 byte), second coord (2 to 4 bytes),
  space (1 byte), name of object/picture (5 to 15 bytes), newline (1 byte),
  ... (repeated if there are several objects), end marker (2 bytes).
  In a binary packet, we will have: command number (2 bytes), number of objects
  in the following block (2 bytes), first coord (2 bytes), second coord (2
  bytes), dynamic reference number for the object/picture (2 bytes), ...
  (may be repeated), and that's all.  Come on, don't tell me that some
  compression protocol in CSLIP will compress ASCII 5 times better than binary!
- ASCII won't be easier to debug.  Even if you are debugging the protocol
  layer, you won't enter the data by hand in real time on a telnet connection!
  So you will need to write a little program that sends/receives the packets
  and it will be easier if the packets are in binary form, with fixed-length
  blocks.
- If we want to have CrossFire on MACs and PCs, the protocol must be designed
  in such a way that it is:
  1) easy and fast to parse - binary is better.
  2) compact to save bandwith - binary is better.

So, tell me, what's the point in using ASCII?

Just my $0.2... <grin>

-Raphael