guile-user
[Top][All Lists]
Advanced

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

Re: Is it possible to write program only in Guile?


From: Olivier Dion
Subject: Re: Is it possible to write program only in Guile?
Date: Wed, 18 Oct 2023 09:10:57 -0400

On Wed, 18 Oct 2023, CToID <funk443@yandex.com> wrote:
> Hello guys, a common lisper here.  I've recently developed some 
> interests in Guile, and wonder if I can make a program entirely written 
> in Guile.

Yes.

> The reason why I am asking this question is because Guile seems to be 
> designed as an extension language that will be embedded into other
> programs.

I see 2 ways of programming with Guile:

 1. The program is written in C.  Guile is used as a scripting language.
 This is the case for Gnu Makefile for example.  This is often the case
 if you have already started the project in C and would like to allow
 users to script your application.

 2. The program is written in Guile.  It can access C routines with the
 foreign function interface (FFI).  This includes popular C libraries
 such as SQLite or SDL2.  An equivalent in Python is Numpy.  The FFI can
 also be used to interface with routines private to the project.  This
 is useful if you need the speed of C for an algorithm.  For example,
 you might want to implement a convolution operation on signals and
 would like to use C to benefit from SIMD instructions.

There is a third way that I personally use.  I use the FFI to make
bindings of the public interface of a low-level C library I work on.
These bindings are not meant to be used by users.  They are instead used
to write tests in Guile.

Overall, if you are a common lisper and do not have an existing C
code-base or that you are not making a C library, the second way is the
best way IMHO.

NOTE: I've been mentioning C here because C is actually the only runtime
that has a well defined and not insaned ABI.  Using FFI with C++ is
simply not possible and you will need something like SWIG.

Regards,

old

-- 
Olivier Dion




reply via email to

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