From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Olivier Dion Newsgroups: gmane.lisp.guile.user Subject: Re: Is it possible to write program only in Guile? Date: Wed, 18 Oct 2023 09:10:57 -0400 Message-ID: <87fs289iu6.fsf@laura> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8033"; mail-complaints-to="usenet@ciao.gmane.io" To: CToID , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Oct 18 15:16:32 2023 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qt6PW-0001oF-Pg for guile-user@m.gmane-mx.org; Wed, 18 Oct 2023 15:16:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt6KO-00051h-SU; Wed, 18 Oct 2023 09:11:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt6KM-0004t1-Q5 for guile-user@gnu.org; Wed, 18 Oct 2023 09:11:10 -0400 Original-Received: from smtp.polymtl.ca ([132.207.4.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt6KL-0000NX-3W for guile-user@gnu.org; Wed, 18 Oct 2023 09:11:10 -0400 Original-Received: from localhost ([209.209.32.82]) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 39IDAv4B010372; Wed, 18 Oct 2023 09:11:02 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 39IDAv4B010372 In-Reply-To: X-Poly-FromMTA: ([209.209.32.82]) at Wed, 18 Oct 2023 13:10:57 +0000 Received-SPF: none client-ip=132.207.4.11; envelope-from=olivier.dion@polymtl.ca; helo=smtp.polymtl.ca X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19272 Archived-At: On Wed, 18 Oct 2023, CToID wrote: > Hello guys, a common lisper here.=C2=A0 I've recently developed some=20 > interests in Guile, and wonder if I can make a program entirely written=20 > in Guile. Yes. > The reason why I am asking this question is because Guile seems to be=20 > 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 --=20 Olivier Dion