[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shrinking the C core
From: |
Eli Zaretskii |
Subject: |
Re: Shrinking the C core |
Date: |
Wed, 09 Aug 2023 15:45:51 +0300 |
> From: "Eric S. Raymond" <esr@thyrsus.com>
> Date: Wed, 9 Aug 2023 05:46:55 -0400 (EDT)
>
> Why is this in C?
History, I'm quite sure.
> Is there any reason not to push it out to Lisp and
> reduce the core complexity? More generally, if I do this kind of
> refactor, will I be stepping on anyone's toes?
For veteran and stable code such as this one, we should not rewrite
them in Lisp just because we can. We should have much more serious
and good reasons for such changes. Good reasons include adding some
significant new feature or extension, supporting new kinds of
filesystems, etc. Otherwise, this just introduces unnecessary
instability and maintenance burden into code that was working well for
eons. Even the simple change you did a few days ago broke the build
on one system and raised a couple of issues some of which are not yet
resolved, and others we don't even have a good way of resolving except
by bracing for bug reports.
In addition to the obvious issues with moving code from C to Lisp,
there are a few less obvious. One example: functions defined in C are
always available, whereas those defined in Lisp are only available
once the corresponding Lisp file was loaded. This matters during
loadup, and even if currently we either don't use the affected
primitives during dumping, or use them only after the corresponding
Lisp file is loaded, it makes the build process more fragile, because
now changing the order of loading the files in loadup or adding some
Lisp to loadup and other preloaded files runs the risk of breaking the
build due to these dependencies.
Another example: moving stuff to Lisp causes code that previously
couldn't GC to potentially trigger GC. So now various parts of Emacs
which call this primitive from C will need to be prepared to have GC
where they previously could assume no GC. How do you even assess the
risks from that in a program like Emacs, what with all our hooks etc.?
This is not academic: we had and have these problems all the time, and
they are usually quite hard to debug and solve.
We don't need such gratuitous maintenance head-aches, and we don't
need the risk of introducing subtle bugs into code which worked for
decades and which we are used to rely on and trust -- unless there are
very good reasons for that. And good reasons in my book are only
those which develop and extend Emacs, and add new and useful features.
So please let's not do that without such reasons. New code that adds
new primitives -- sure, we should discuss whether this or that part
needs to be in C, and prefer Lisp implementations whenever we can.
But not the old and trusted code like this one -- those should be
rewritten only for very good reasons. And even when we do have such
good reasons, whether they justify rewriting existing stable code
should be discussed on a case by case basis, so we could consider the
possible alternatives and choose the best way of doing that. Not
every extension that involves some primitive justifies rewriting or
reimplementing that primitive.
- Re: Type declarations in Elisp, (continued)
- Re: Shrinking the C core, Aurélien Aptel, 2023/08/18
- Re: Shrinking the C core, Emanuel Berg, 2023/08/19
- Re: Shrinking the C core, Emanuel Berg, 2023/08/31
- Re: Shrinking the C core, Richard Stallman, 2023/08/13
- Re: Shrinking the C core, Emanuel Berg, 2023/08/14
- Re: Shrinking the C core, Ihor Radchenko, 2023/08/14
Re: Shrinking the C core,
Eli Zaretskii <=
Re: Shrinking the C core, Gerd Möllmann, 2023/08/13
Re: Shrinking the C core, Gerd Möllmann, 2023/08/13
Re: Shrinking the C core, Gerd Möllmann, 2023/08/13