guix-devel
[Top][All Lists]
Advanced

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

Re: Including code in a non-Guile language into Guix


From: Attila Lendvai
Subject: Re: Including code in a non-Guile language into Guix
Date: Fri, 01 Nov 2024 22:49:49 +0000

> I know that Guix is mainly written in Guile, but has much thought
> gone into optimizing these commands by rewriting some of the code in
> a more performance-oriented language like C?


this is a slow-dying, but completely unjustified stereotype of C and 
"highlevel" languages like lisp.

the truth is that for any non-trivial problem/domain it's easier to write 
faster lisp code than C.

the reason is that even if a FOR loop runs twice as fast in C (it's not), if 
the programmer can spend more time thinking/experimenting with the domain, and 
come up with a better optimization *in the domain*, then he may gain *orders of 
magnitude*, not a mere doubling that "more performance-oriented languages" 
provide.

and if the task is about the most efficient use of the hardware at hand (think 
of simulations), then i have way more tools to profile my lisp code, and it's 
way easier to extend the lisp compiler under me with some custom-made 
primitives to peephole optimize my hotspots. or run the same code with and 
without custom made instrumentation to gain more insights about the 
bottlenecks. or compile my hotspots at runtime, if e.g. i have a task that 
rarely changes, but must be repeated endlessly (think of a firewall). or if the 
domain is such, then straight out write a custom compiler for a DSL that is 
specific to the task at hand, and seamlessly integrates into the the rest of my 
lisp codebase.

when coding in C you're wasting a lot of your attention on manually translating 
the domain to a verbose mess of C code that can't really encode much of the 
domain abstractions. writing C code is much more of a manual, lossy translation 
from domain-to-C than writing a lisp solution to the same problem, which is 
much more about converging lisp and your domain from both directions. and on 
top of this all, what a timesink debugging C code can be!

</rant>

PS: note though that the above is written from experience with more capable 
lisps like SBCL + Slime.

-- 
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Government is the great fiction through which everybody endeavors to live at 
the expense of everybody else.”
        — Frédéric Bastiat (1801–1850), 'The State' (1848)




reply via email to

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