Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In what languages besides C can I write a C library?

Tags:

c

dll

I want to write a library that is dynamically loadable and callable from C code, but I really don't want to write it in C - the code is security critical, so I want a language that makes it easier to have confidence that my code is correct. What are my options?

To be more specific, I want C programmers to be able to #include this, and -l that, and start using my library just as if I had written it in C. I'd like programmers in other languages to be able to use their favourite tools for linking to C libraries to link to it. Ideally I'd like that to be possible on every platform that supports C, but I'll settle for Linux, Windows and MacOS.

like image 335
Paul Crowley Avatar asked May 07 '13 20:05

Paul Crowley


People also ask

What language can replace C?

To overcome such issues, Microsoft developers recently announced to use the Rust programming language instead of C and C++ to write and code the components of Windows. The project is known as Verona where the developers will develop a new and safer programming language for Windows.

Can I create my own library in C?

First thing you must do is create your C source files containing any functions that will be used. Your library can contain multiple object files. After creating the C source files, compile the files into object files. This will create a static library called libname.

What language is library written in?

The standard libraries are typically written in C and C++, using a bare minimum of assembly code in order to interact with the functionality provided by the operating system, and most operating systems are written in C as well as a mix of assembly for a handful of things that cannot be done directly in C.

Are there C libraries?

C Standard library functions or simply C Library functions are inbuilt functions in C programming. The prototype and data definitions of these functions are present in their respective header files. To use these functions we need to include the header file in our program.


1 Answers

Anything that compiles to native code. So you might Google for that - "languages that compile to native code." See, e.g., Programming languages that compile to native code and have the batteries included

C++ is often the choice for this. Compiles to native code and provided you keep your interfaces simple, easy to write an adapter layer.

Objective C and Fortran are also possible.

like image 76
djechlin Avatar answered Sep 21 '22 03:09

djechlin