Why Nobody Uses Emacs Lisp for Text Processing (2017)
Why Nobody Uses Emacs Lisp for Text Processing
reddit discussions https://www.reddit.com/r/emacs/comments/6qpbka/elisp_for_text_processing_in_buffers/
my take:
for me, the basic problems are, from more critical to less:
- emacs cannot open large files. e.g. 10 megabytes file becomes very slow.
- emacs has to load whole file into memory. It cannot just read a line of a file. Basically, you can't use emacs to process say http server log files.
- emacs has problem with long lines. e.g. many modern lib generate html/js output all in 1 single line.
- elisp is at least 6 times slower than python ruby perl.
- emacs regex sucks. (1) backslash problem. (2) Unpredicable syntax table dependent e.g. for word. (3) Verbose syntax e.g. in
[[:digit:]]
instead of\d
. (4) Less powerful. - string lib sucks. Though, usually you'd use buffer functions, still, a robust string lib helps a lot.
- when using elisp as text processing script, many obscure details one has to pay attention to. e.g. you don't want to use find-file to open cuz that loads the major mode with syntax coloring, undo on, or lots packages have added hooks when a file is opened, need to possibly turn off auto backup, etc.
- the no raw string quote is painful. e.g. in perl/ruby you use APOSTROPHE quote or q[], in python you use tripple. In elisp, you have to sprinkle backslashes into the string. Not practical when the string is long, such as comp lang code or regex code. (or you put the string into a file then read it in, but that's another inconvenience)
The emacs buffer type is far more powerful than string type. The addition of “point” datatype and others, narrow to region, move/search forward backward, insert/replace text anywhere, makes it far more powerful than any regex. I thought i'd write all text processing in elisp. But these days, i avoid it, unless i want to use it interactively while in emacs.
Emacs Lisp is the Best Programing Language for Text Processing
2024-11-24 Addendum. I think emacs lisp is the best, most powerful, convenient, programing language for doing text processing.
During 2017, i was a bit tired of some of the problems. However, all things considered, emacs lisp is the best by far. I still code text processing tasks in emacs lisp daily.
Except for the ugly regex, all other problem are fixed.