Developing Emacs extensions in Go

B4046a83c88f4b98c4a37920d674a3cb?s=47 kiwanami
July 03, 2017
1.2k

Developing Emacs extensions in Go

Geeks Who Drink @nulab on 2017/06/28
https://nulab.connpass.com/event/57238/

B4046a83c88f4b98c4a37920d674a3cb?s=128

kiwanami

July 03, 2017
Tweet

Transcript

  1. Developing Emacs extensions in Go kiwanami 2017/06/28

  2. Topics • Emacs and extension? • Why do I choose

    go? • Design and implementation of go-elrpc
  3. Me • Masashi Sakurai • @kiwanami • Software Developer –

    Software engineer for medical/hospital systems • OSS – Emacs Lisp, JavaScript • Go – 2016/12 -
  4. Emacs and Extensions

  5. Emacs? • TEXT EDITOR! – Since mid-1970s and continues actively

    as of 2017. • Extensible, Customizable!
  6. Emacs start up screen

  7. Editing code

  8. Split windows and color customize

  9. IDE like window layout

  10. Database integration

  11. Web browser and Data analysing with jupyter

  12. Reading and Writing Mails

  13. Schedule management with calendar services

  14. Cacoo Integration

  15. 3D FPS(First person sampo) game

  16. Online Multi-player 3D FPS

  17. Emacs is Great !!

  18. 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...
  19. EPC, RPC stack for Emacs Lisp • TCP Socket /

    S-exp encoding • Language binding – emacs lisp, perl, python, ruby, nodejs, nim, scala
  20. 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
  21. 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
  22. None
  23. Desing and Implementation go-elrpc

  24. EPC overview

  25. 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
  26. 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
  27. 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
  28. 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:
  29. Performance • echo(a int) int method – perl: 3154 msg/sec

    – ruby: 10526.3 msg/sec – nodejs: 9174.31 msg/sec – golang: 26347 msg/sec
  30. Thank you