3 ms·
Relatively speaking this really couldn't be further from the truth. There's plenty of codebases that implement some programming language and only use C binding
by avar 10y ago
Relatively speaking this really couldn't be further from the truth.
There's plenty of codebases that implement some programming language and only use C bindings for truly low-level primitives, such as external library calls, memory allocation etc, leaving any substantial logic that's built on top of those OS primitives to a higher level language.
Emacs is not such a codebase, most of the C code by volume is things that could perfectly well be implemented in Emacs Lisp itself, but aren't because Emacs Lisp is relatively slow.
So while it's fine for "scripting" Emacs itself, things like regexes, anything that has to do with low-level character handling, most of the GUI layout of Emacs itself (i.e. the buffer logic etc, not actually calling ncurses or X) etc. is written in C.
Just browse through the C files in src/, most of this clearly has nothing to do with interacting with low-level OS primitives: http://git.savannah.gnu.org/cgit/emacs.git/tree/src http://git.savannah.gnu.org/cgit/emacs.git/tree/src
- lispm 10y ago> most of the C code by volume is things that could perfectly well be implemented in Emacs Lisp itself, A substantial part of the GNU Emacs core is written in C: the byte code virtual machine, the core Emacs Lisp language implementation, loading/saving images, memory management, ... That's not implementable in the current Lisp architecture (which additionally is single threaded). If we want to move more of the language implementation in Lisp, that's possible - see implementations like SBCL or Clozure CL. Porting/maintaining these seems more difficult. But then you can implement regexes and other stuff in Lisp.
- torrent-of-ions 10y agoYes. Basically the Emacs "C bit", is not just a Lisp like Clisp or SBCL, it also has a load of text editor code. Have a "CLmacs", ie. an emacs written in Common Lisp, is something a lot of people would really like. The problem, of course, is the vast amount of elisp that we currently use in our editors.
- kazinator 10y agoYou'd think that an Elisp implementation plus the necessary API's could be provided to make a good bulk of that code work.