Tuesday, April 26, 2022

Neovim IDE; Lua language; MessagePack data

Home - Neovim

hyperextensible Vim-based text editor
  • API is first-class: discoverable, versioned, documented.
  • MessagePack structured communication enables extensions in any language.
  • Remote plugins run as co-processes, safely and asynchronously.
  • GUIs, IDEs, web browsers can --embed Neovim as an editor or script host
Vim (text editor) - Wikipedia


a Dutch computer programmer and an active member of the open-source software community. He is the original author, maintainer, release manager, and benevolent dictator for life of Vim,[1] a vi-derivative text editor that is very popular among programmers and power users. From July 2006 until September 2021 Moolenaar was employed by Google working in the Zürich office.


  • Modern GUIs
  • API access from any language including C/C++, C#, Clojure, D, Elixir, Go, Haskell, Java, JavaScript/Node.js, Julia, Lisp, Lua, Perl, Python, Racket, Ruby, Rust
  • Embedded, scriptable terminal emulator

Neovim has many benefits over Vim, and has been applying pressure on Vim for years to improve its own development and codebase. Nvim has first class support for Lua outside of Vimscript, which has enabled a lot of people to write more powerful plugins.








MessagePack: It's like JSON. but fast and small

MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller. Small integers are encoded into a single byte, and typical short strings require only one extra byte in addition to the strings themselves.


"MessagePack is more compact than JSON, but imposes limitations on array and integer sizes. On the other hand, it allows binary data and non-UTF-8 encoded strings. In JSON, map keys have to be strings, but in MessagePack there is no such limitation and any type can be a map key, including types like maps and arrays, and, like YAML, numbers.

Compared to BSON, MessagePack is more space-efficient. BSON is designed for fast in-memory manipulation, whereas MessagePack is designed for efficient transmission over the wire. For example, BSON requires null terminators at the end of all strings and inserts string indexes for list elements, while MessagePack doesn't. BSON represents both arrays and maps internally as documents, which are maps, where an array is a map with keys as decimal strings counting up from 0. MessagePack on the other hand represents both maps and arrays as arrays, where each map key-value pair is contiguous, making odd items keys and even items values.

The Protocol Buffers format aims to be compact and is on par with MessagePack. However, while JSON and MessagePack aim to serialize arbitrary data structures with type tags, Protocol Buffers require a schema to define the data types. Protocol Buffers compiler creates boilerplate code in the target language to facilitate integration of serialization into the application code; MessagePack returns only a dynamically typed data structure and provides no automatic structure checks."

Py Sunfish Chess => GoLang

Let's write a tiny chess engine in Go

"porting the sunfish chess engine to Go. Sunfish is notable for its simplicity and small size, while still being capable of playing decent chess.

full code of the engine at https://github.com/zserge/carnatus (the name comes from latin species name of Gopher rockfish).

If you are interested in small chess engines, I strongly recommend playing with sunfish. Also, sunfish was based on Micromax engine, which has a wonderful documentation by his author, definitely worth reading."


While this Go implementation works, there are a few issues that need attention, can not be used as-is (i.e. start K-Q position needs to be swapped, etc.)