VINE

VINE is a project to develop a programmable text editor. As its name implies, VINE is heavily inspired by vim and Emacs.

Goals

Most of VINE will be written in a new high level language called Beetle. The underlying mechanism will be written in C.

Beetle

Beetle is a high level gradually but strongly typed functional1 programming language. Most programming languages today are created by people that are primarily interested in programming language development. The first big project written in a new language is often its own compiler. While this makes sense, it means that these languages tend to be optimised for writing compilers. In addition, the most popular type of programming today2 is web programming, and server-side web programming is a popular area for initially compiler-oriented programming languages to focus on next, as they are both essentially batch programming.

Beetle isn't design- or implementation-optimised for writing a compiler for Beetle, or for writing web servers, or as a JavaScript replacement. It is optimised for for writing a text editor. As this is a very different kind of programming, Beetle ends up being a very different kind of language. For example, algebraic data types and pattern matching are very convenient for writing a compiler, while for user interface programming class-based dynamic dispatch is more useful.

Beetle is not just a language for writing a text editor but also a language for scripting and customising a text editor. This means it is likely to be used by non-programmers. The design of Beetle is thus built around trying to be as intuitive as possible. Unintuitive design choices that are rooted in optimisation, like fixed-width integers and floating-point reals, have been excised.

Vinescript

While it is possible to customise VINE in Beetle, it doesn't make sense to do everything in Beetle. It is the best choice for writing plugins and scripts, but it is not the best choice for writing VINE's configuration file, nor is it the best choice as the : command language.

For that we have Vinescript. Vinescript is syntactically and functionally similar to Vimscript. However it is designed to be interoperable with Beetle. Beetle can be easily embedded in Vinescript and vice versa.

set textwidth=80
set nowrap
set number
set incsearch
set nohlsearch
set ts=8 sts=8 sw=8
set noexpandtab

function! FindByContent()
  call inputsave()
  let pattern = input("Search (by content): ")
  call inputrestore()
  if empty(pattern)
    return 1
  endif
  lexpr system('rg --column -nSe "' . pattern . '"')
  lopen
endfunction

function! FindByFilename()
  call inputsave()
  let pattern = input("Search (by filename): ", "", "file")
  call inputrestore()
  if empty(pattern)
    return 1
  endif
  lexpr system("find . -iname '*" . pattern . "*'")
  lopen
endfunction

beetle!
  import input, complete, quickfix

  def find-by-content,
    with input/save,
      let pattern = input/prompt 'Search (by content): '.
      if pattern/empty?,
        raise empty-input.
      quickfix/lexpr { rg --column -nSe '$pattern' }.
      quickfix/lopen.

  def find-by-filename,
    with input/save,
      let pattern = input/prompt 'Search (by filename): ' ~complete:complete/file.
      if pattern/empty?,
        raise empty-input.
			quickfix/lexpr { rg --files | rg --column -nSe '$pattern' }.
      quickfix/lopen.
endbeetle

Interface

Notes

  1. Contrary to popular belief, the term ‘functional’ when applied to a programming language is not synonymous with ‘pure’ or ‘statically typed‘. Haskell is an example of a statically typed pure functional programming language, while OCaml is an example of a statically typed impure functional programming language. Common Lisp is an example of a dynamically typed3 impure functional programming language, and Pure is an example of a dynamically typed pure functional programming language. A functional programming language is one in which functions are first-class. A category of objects is first-class if it can be passed as an argument to a function, returned from a function, created anonymously and assigned to a variable. In C, functions are not first-class objects, so it is not a functional programming language. [back]
  2. This is true at least in the zeitgeist sense. If most of your concept of what is trendy in software comes from time spent on websites like Twitter, /r/programming, Hacker News, GitHub or Stack Overflow then you would have trouble coming to any other conclusion. According to StackOverflow, TypeScript is more popular than C or C++ and JavaScript is more popular than Java. This says far more about the sort of people that answer StackOverflow surveys than it does about TypeScript and C or JavaScript and Java. If you have ever worked in software outside of web programming then you will know that people that work in other areas of software tend not to spend all day on reddit, and neither need to nor can ask for help on StackOverflow. [back]
  3. Arguably, Common Lisp is gradually typed. [back]