Unix and C

David Brown davidb at davidb.org
Thu May 9 09:55:18 PDT 2013

On Tue, May 07, 2013 at 02:28:49PM -0700, Andrew Lentvorski wrote:

>It's pretty hard to find a language that matches the expressiveness of
>structures, unions and bitfields for laying out *exactly* what you want
>*exactly* how you want it.  Thus the necessity for Protocol Buffers,
>Thrift, etc. for managing binary data in other languages.

I've always thought C was pretty horrible at matching hardware, mostly
because so much of what it does is implementation defined.

The best language I've found for matching hardware layout has to be
Ada, especially the newer versions.  For any given record, you can
describe, in detail, exactly how it is to be layed out, down to the
bit.  It also supports moduluo numbers of unusual sizes, and even
things like packed arrays of 21 bit numbers, just in case you need

>Urp.  Oh, yeah, Ada.  Forgot about that.
>How low-level is Ada?  VHDL (a hardware description language) borrows a
>lot of concepts from Ada.

VHDL borrows syntax, roughly from Ada.  It's close enough to be
annoying when trying to use both.

As far as "level", I would describe it's low-level parts as lower than
C, since it is better at describing exact layout.  But, it also has
higher level constructs such as OOP.

It also has a lot of constructs useful for Real Time built into the
language, such as tasks, synchronization and the likes.  This
generally relies on a runtime library to interface to the underlying
operating system.  At least in the GNU Ada compiler, very little of
this code is written in C (The linux runtime library has 360K lines of
Ada code, and 14K lines of C).  Much of the C code is about dealing
with libc, which uses fairly C-specific conventions.

>> Also, make sure we don't forget Pascal.  The original MacOS was largely
>> written in Pascal.
>Erm, I don't think so.  The assembly tricks in MacOS are pretty legendary.

Assembly tricks doesn't mean not written in.  As far as I understand,
most of the code was still written in Pascal, gradually being
rewritten into C (as well as much of the assembly).


More information about the KPLUG-List mailing list