From: HiPhish <hiphish@posteo.de>
To: guile-user@gnu.org
Subject: [ANN] guile-msgpack: MessagePack for GNU Guile (+ help needed)
Date: Wed, 19 Sep 2018 14:33:22 +0200 [thread overview]
Message-ID: <3401551.pIYnLFp0Xl@aleksandar-ixtreme-m5740> (raw)
Hello Schemers,
I am pleased to announce to the public a project I have been working on for a
while: an implementation of the MessagePack[1] data serialization format for
GNU Guile.
https://gitlab.com/HiPhish/guile-msgpack
## What is MessagePack ##
MessagePack is a specification for how to turn data into byte and vice-versa.
Think of it like JSON, except instead of human readability it stresses speed
and size efficiency. The format is binary and well suited for data exchange
between processes. It also forms the basis of the MessagePack RPC protocol[2].
## About the Guile implementation ##
My implementation is written in pure Guile Scheme, so it should work out of
the box. You can try it out without installing anything. Just clone the repo
and give it a try:
$ guile -L .
scheme@(guile-user)> ,use (msgpack)
scheme@(guile-user)> (pack "hello" 1337 #t)
$1 = #vu8(165 104 101 108 108 111 205 5 57 195)
As you can see, the three objects passed to the `pack` procedure have been
turned into one big bytevector. We could now unpack this bytevector again,
write it to a file, or send if off to a port. Since using MessagePack with
ports is a frequent task there is also a `pack!` procedure which takes in a
port to pack to as well.
(define hodgepodge (vector 1 2 '#(3 #t) "foo"))
(pack! hodgepodge (current-output-port))
To get our object back we `unpack` it:
(unpack #vu8(#xA5 #x68 #x65 #x6C #x6C #x6F)) ; Returns "hello"
(unpack! (current-input-port))
The readme goes into more detail and the (Texinfo) manual has the complete
documentation. Building it is simple enough with the included makefile.
## What's next? ##
Next is your feedback! Once the library has settled down I would like to make
it into a Guix package. From there I can then start building a MessagePack RPC
implementation and finally a Neovim client which will allow people to write
plugins for Neovim in GNU Guile. (yes, Vim plugins written in Lisp, who would
have thought?)
## Help needed ##
This is my first time making a full project in Guile, so I would appreciate it
if someone with more experience could look over my code. I have written down
some things I could think of in the todo file. In particular I would like to
know:
How much is portability a concern? I know Guile implements *some* or r6rs, but
I wasn't paying much attention to that. Is it something worth considering or
should I just treat Guile as its own language that just so happens to be based
on Scheme?
The extension type `ext` (msgpack/ext.scm) is a pair of a signed 8-bit integer
and a bytevector. The constructor does not enforce this condition, the two
slots can be really anything. What it the proper way of enforcing this in
Guile? I know Common Lisp has type declarations and Racket has contracts, but
what does Guile have?
The `pack` procedure takes any number of objects and packs them into a large
bytevector. However, the `unpack` procedure only returns the first object it
unpacks. Is there a way of making it unpack as many as it can? I thought of
`values`, but you would need to know the number of values in advance. Also the
caller would have to know in advance how many objects he is going to get
unpacked.
As I said, there is more in the todo file, but the other questions are under
the hood, not user-visible.
## The inevitable panhandling ##
I don't want to go into this too much, because no one likes to read it, but if
you like my MessagePack implementation I would really appreciate if you could
spare some cash. Links are in the readme; at the moment I only have Liberapay
set up, if anyone can recommend me a service for one-time donations that would
be cool. All the services I could find were about fundraising for charity and
stuff, not what I was looking for.
_______________________________________________________________________________
[1] https://msgpack.org/
[2] https://github.com/msgpack-rpc/msgpack-rpc
next reply other threads:[~2018-09-19 12:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 12:33 HiPhish [this message]
2018-09-19 13:29 ` [ANN] guile-msgpack: MessagePack for GNU Guile (+ help needed) Thompson, David
2018-09-19 14:06 ` HiPhish
2018-09-19 14:12 ` John Cowan
2018-09-19 23:32 ` HiPhish
2018-09-20 1:44 ` John Cowan
-- strict thread matches above, loose matches on Subject: below --
2018-09-20 11:15 Aleksandar Sandic
2018-09-20 11:24 Aleksandar Sandic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3401551.pIYnLFp0Xl@aleksandar-ixtreme-m5740 \
--to=hiphish@posteo.de \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).