
Gisp: A Lisp that compiles to Go - jcla1
https://github.com/jcla1/gisp
======
chalst
If you are wanting a native dynamic scripting language for Go, goluago is
coming along quite nicely (alpha version released at New Year):

[https://github.com/akavel/goluago](https://github.com/akavel/goluago)

I think if I wanted to implement a native Lisp interpreter/ bytecode compiler
for Go, I would build on top of this project rather than starting from
scratch.

~~~
JulianMorrison
That looks useful, thanks.

------
yason
For any programming language or platform without macros, a Lisp frontend
appears.

~~~
mkesper
Nisp: A Lisp that compiles to Nothing

the perfect zen...

~~~
agumonkey
And if you need a Lisp that is nothing :
[https://en.wikipedia.org/wiki/NIL_(programming_language)](https://en.wikipedia.org/wiki/NIL_\(programming_language\))

------
pjmlp
For those playing with this type of code generation, you get to learn more by
targeting Assembly instead.

Define a proper interface between ASTs and code generation and retarding the
compiler is also not that complicated.

Or generate LLVM bitcode and use the LLVM tools to compile it to native.

Way better than relying in other compiler stacks.

Of course, it is a matter how deep one wants to get into compiler stuff.

~~~
unwind
s/retarding/retargeting/? Or something else? I haven't been able to come up
with an interpretation where "retarding" makes sense in that sentence, but of
course I'm not a native speaker.

I guess targeting assembly is way harder, you must deal with register
allocation and other scary-sounding topics.

~~~
pjmlp
> s/retarding/retargeting/?

Ooops, a typo.

> I guess targeting assembly is way harder, you must deal with register
> allocation and other scary-sounding topics.

Not necessarily, if you are ok with just getting something to run.

You can pre-define a set of generation templates for each AST node, no need
for register allocation.

------
bfe
See also Kakapo, an effort at a lisp interpreter in Go.

[https://github.com/bytbox/kakapo](https://github.com/bytbox/kakapo)

------
jcla1
Author here, in case anyone has any questions!

~~~
sdegutis
How does it actually work? Does it compile to Go's intermediate language and
then use the normal Go tool chain to compile it into native code, and then
execute it? Or is it just an AST interpreter?

~~~
jcla1
It takes a given Gisp program and then lexes/parses it into a Gisp AST. Then
it translates that Gisp AST into a Go AST [1] and then just prints out [2] the
Go program that would generate that specific Go AST.

[1] [http://golang.org/pkg/go/ast/](http://golang.org/pkg/go/ast/) [2]
[http://golang.org/pkg/go/printer/](http://golang.org/pkg/go/printer/)

------
e12e
Does look like it could use a little more documentation? Am I missing
something or is the only list of supported syntax etc the (very limited)
examples and the implementation itself? There's no design/goal document
listing what's supported or not?

Other than that, this looks like a lot of fun :-)

~~~
jcla1
Indeed it was a lot of fun implementing it (author here), and yes it could do
with some more documentation, though up to now no one besides me was really
concerned about the functionality... :-0

------
cryptolect
Feels like this is the beginning of a trend: Clojure, Hy and now Gisp.

~~~
klibertp
Traditionally C was the target language, many Schemes compile to it with great
results. Writing a Lisp on top of something else has a very long tradition and
certainly is not beginning just now. :)

~~~
ZenoArrow
What interests me is can these Lisp implementations facilitate easier
translation between languages, e.g. write in Python, Python translated to Hy,
Hy translated to Gisp, Gisp translated to Go. Whilst lisp dialects do differ,
I'd imagine such links would be easier than a direct Python to Go translator.

~~~
deckiedan
Kind of - although these are all 'lisps', there's quite a lot of difference
between them all. Most of these are keeping with their 'host' language scoping
rules, for instance. Also external library calls, etc.

------
erikj
Is there a Scheme implementation that compiles to Go?

~~~
wuschel
I haven't seen that yet, could be a fun thing to have. I just found an
implementation of Tinylisp in go. It would be fun to have all the funky
goroutines in a schemish design..

[http://www.oki-osk.jp/esc/golang/lisp.html](http://www.oki-
osk.jp/esc/golang/lisp.html)

On another note, there is Chicken Scheme, which compiles to C and produces
executable files. Nice stuff!

www.call-cc.org/‎

------
blahbl4hblahtoo
Oh my god, if someone wrote a bitcoin wallet that protected you chats from the
NSA in this List that compiles to GO THIS WOULD BE THE PERFECT HN POST.

