Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interfacing with C is actually a lot of work. Not that it is not possible, but if you write a light wrapper, you end up with all the low-levelness that makes up C.

If you want to use a C library „the Ada way“, you need to wrap almost every C function with an Ada function that transforms C pointers into Ada arrays (remember, [] in C is just a pointer with no dope), C defines into Ada enumerations, C function pointers to Ada subprogramm access types and so on.

This amounts to a lot of work. For example, my OpenGL Ada wrapper is roughly 10,000 lines of code. But it does do extension loading and resource management automatically (in contrast with the raw C API) and all defines have been translated to enum values so you can call functions only with values they can handle.



This is totally true. Interfacing with other languages is important.

The operating system is in C, so to use all the operating system provides, the networking, shared memory, IPC you need a wrappers. If your sharing data with C code, you need to make sure you ada records match your C Structs so they align correctly. Ada was remarkably good at letting you set where things went in memory for each record.

Part of a past job was to write and maintain ada wrappers for a large Ada project.


The same applies to C++ APIs done properly, sadly due to the copy paste compatibility, we end up with a pile of C bindings.

This is specially visible when comparing nice C++ libraries like OWL and VCL to MFC.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: