Slide 1

Slide 1 text

Developing Emacs extensions in Go kiwanami 2017/06/28

Slide 2

Slide 2 text

Topics ● Emacs and extension? ● Why do I choose go? ● Design and implementation of go-elrpc

Slide 3

Slide 3 text

Me ● Masashi Sakurai ● @kiwanami ● Software Developer – Software engineer for medical/hospital systems ● OSS – Emacs Lisp, JavaScript ● Go – 2016/12 -

Slide 4

Slide 4 text

Emacs and Extensions

Slide 5

Slide 5 text

Emacs? ● TEXT EDITOR! – Since mid-1970s and continues actively as of 2017. ● Extensible, Customizable!

Slide 6

Slide 6 text

Emacs start up screen

Slide 7

Slide 7 text

Editing code

Slide 8

Slide 8 text

Split windows and color customize

Slide 9

Slide 9 text

IDE like window layout

Slide 10

Slide 10 text

Database integration

Slide 11

Slide 11 text

Web browser and Data analysing with jupyter

Slide 12

Slide 12 text

Reading and Writing Mails

Slide 13

Slide 13 text

Schedule management with calendar services

Slide 14

Slide 14 text

Cacoo Integration

Slide 15

Slide 15 text

3D FPS(First person sampo) game

Slide 16

Slide 16 text

Online Multi-player 3D FPS

Slide 17

Slide 17 text

Emacs is Great !!

Slide 18

Slide 18 text

Emacs Extension ● Pure Emacs Lisp ● “Dynamic module” – Since Emacs 25.1 – include “emacs-module.h” – not popular yet... ● IPC – STDOUT/IN, TCP Socket, D-bus – Hard to implement...

Slide 19

Slide 19 text

EPC, RPC stack for Emacs Lisp ● TCP Socket / S-exp encoding ● Language binding – emacs lisp, perl, python, ruby, nodejs, nim, scala

Slide 20

Slide 20 text

Ok, EPC solves problem? ● Yes. – Emacs gets powers through other languages. ● But, Installing other language environment and package system is very difficult... – perl/CPAN, ruby/gem, node/npm, etc

Slide 21

Slide 21 text

Go may solve the problem ● Easy deploying – One binary ● Fast and static typing – Comparing with LL ● Easy to learn – Simple language and GC – Concurrency → go bindign : go-elrpc

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Desing and Implementation go-elrpc

Slide 24

Slide 24 text

EPC overview

Slide 25

Slide 25 text

go-elrpc overview ● S-exp encoding/decoding – parsing s-exps and serializing data values – type conversion ● RPC stack – TCP stream – async and sessions – bi-directional

Slide 26

Slide 26 text

S-exp encoding/decoding ● goyacc and handwritten lexer (call add (1 2 3)) Lexer State channel [token] Parser (yacc) S-exp AST rune (unicode char) lexer thread parser thread

Slide 27

Slide 27 text

RPC stack implementation ● stream threads and controle thread Receiver thread Sender thread Controle thread decoding encoding socket stream dispatching messages managing sessions User Code RPC Service

Slide 28

Slide 28 text

Type convesion ● S-exp (not static typed) input ● Types which are needed by static typed functions func add(a int64, b float64) float64 1 (int), 2 (int) input:

Slide 29

Slide 29 text

Performance ● echo(a int) int method – perl: 3154 msg/sec – ruby: 10526.3 msg/sec – nodejs: 9174.31 msg/sec – golang: 26347 msg/sec

Slide 30

Slide 30 text

Thank you