* 2010-01-24 21:13 (-0800), Peng Yu wrote:

> I know Lisp is very powerful. Is the language in vim as powerful?

No, it's not. It seems that there are still unique features in Lisp
which are not supported in any other language. In this sense Lisp is the
most powerful language available. Lisp is really different. I don't know
many languages but this is what other people say. Other languages have
gained power by copying Lisp's features.

For example, a Vim script programmer can't use the language to modify
and extend the language itself. On the other hand Lisp programmers do
that pretty much all the time. Emacs people have used Emacs Lisp to
implement quite big part of Common Lisp. A programmer does not see where
the "core language" ends and other features begin because there's no
difference. A good example for this are Common Lisp's standard macros:
the language was used to build part of the language itself.

> For what type of tasks, it is more difficult to do in vim scripting
> language than lisp in emacs? And for what type of tasks, it is easier
> to do in vim scripting language than lisp in emacs?

Now there's the practical angle. Obviously languages don't live in
vacuums; they are part of some environment and often it's the
environment which very much defines language's power and limits. Vim
script is very useful language for interacting with Vim's features. But
a Vim script programmer doesn't have as much freedom as Emacs Lisp
programmer because Vim environment sets more limits than Emacs.

The fundamental difference is that Vim as an environment is pretty much
closed and the Vim script language is just a _scripting_ language for
those features. On the other hand Emacs environment itself is mostly
implemented in Emacs Lisp so programmers kind of live inside the
environment. Emacs Lisp is not a scripting language but the
implementation language of the system itself. This blurs the distinction
between Emacs developers and users. Users get the same access as the
original developers, and all of it interactively without restarting
Emacs.

But are you asking concrete examples of operations which are _easier_ to
do with one editor? There are probably thousands of such examples but
they don't tell much about language's power or environment's abilities.
Well, in Vim script it's easier to go to the first line of current
buffer: 1 (that is, the command is just the number). Nothing can be
simpler than that. The same is more "difficult" in Emacs Lisp code.
Programmers typically do it with (goto-char (point-min)).

It's also probably easier to programmatically search and replace in Vim:

    let cursor = getpos('.')
    %s/regexp/replace/g
    call setpos('.', cursor)

Programmer needs to understand a bit more about actual programming when
doing the same in Emacs Lisp code:

    (save-excursion
      (goto-char (point-min))
      (while (re-search-forward "regexp" nil t)
        (replace-match "replace")))

You know, a conditional loop and all. :-) Some things are easier in
Emacs Lisp - that (save-excursion [...]) macro being one example - but
then again these examples don't tell much about anything.

The bottom line is that

  - on theoretical level no language is more powerful than Lisp and
    therefore Emacs Lisp is more powerful than Vim script.
    
  - on practical level language's power depends on features and limits
    of the surrounding environment. In this area Emacs Lisp also wins
    because the system is almost totally open for a programmer.

  - Vim is obviously an excellent and powerful text editor. I'm just
    comparing features and power of the languages and the two different
    environments as a whole.

-- 
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to