unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Olivier Dion <olivier.dion@polymtl.ca>
To: CToID <funk443@yandex.com>, guile-user@gnu.org
Subject: Re: Is it possible to write program only in Guile?
Date: Wed, 18 Oct 2023 09:10:57 -0400	[thread overview]
Message-ID: <87fs289iu6.fsf@laura> (raw)
In-Reply-To: <d57fe799-0910-4a2c-b41f-d96de746764b@yandex.com>

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




  parent reply	other threads:[~2023-10-18 13:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 10:23 Is it possible to write program only in Guile? CToID
2023-10-18 12:51 ` Basile Starynkevitch
2023-10-18 13:31   ` CToID
2023-10-18 13:36     ` Basile Starynkevitch
2023-10-18 14:43     ` Greg Troxel
2023-10-18 15:06       ` CToID
2023-10-18 15:50         ` Hans Åberg
2023-10-18 20:24           ` Janneke Nieuwenhuizen
2023-10-18 16:11         ` Thompson, David
2023-10-19  4:52       ` tomas
2023-10-19 11:18         ` wolf
2023-10-20  4:35           ` tomas
2023-10-18 13:10 ` Olivier Dion [this message]
2023-10-18 13:32   ` Marc Chantreux
2023-10-18 13:44     ` Olivier Dion
2023-10-18 18:49       ` wolf
2023-10-18 19:14         ` Olivier Dion
2023-10-20 10:19         ` Marc Chantreux
2023-10-18 13:12 ` Zelphir Kaltstahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fs289iu6.fsf@laura \
    --to=olivier.dion@polymtl.ca \
    --cc=funk443@yandex.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).