6 ms·
Gisp: A Lisp that compiles to Go
- cryptolect 13y agoFeels like this is the beginning of a trend: Clojure, Hy and now Gisp.
- nickik 13y agoThis has always been done. Very view of these will actually get any real world use.
- klibertp 13y agoTraditionally 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 13y agoWhat 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 13y agoKind 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.
- zem 13y agobut the main reason to use these language-hosted lisps rather than just using one of the mainstream lisps is to get access to the host language's libraries and ecosystem. that wouldn't translate particularly well between languages.
- ardfard 13y agoThis exactly my thought too. It looks like everybody who already know Lisp will developed some sweet spots for it. My guess once you experience the Lisp kool-aid, it'll be hard to be apart with it. You'll miss it whenever you code.
- yason 13y agoFor any programming language or platform without macros, a Lisp frontend appears.
- rdc12 13y agoA new law?
- pjmlp 13y agoNo, an old law. "Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp." Since the quote is from 1993, you just need to replace C and Fortran by the languages of the day.
- gruseom 13y agoThat's about the evolution of complicated programs, so quite different.
- mkesper 13y agoNisp: A Lisp that compiles to Nothing the perfect zen...
- agumonkey 13y agoAnd if you need a Lisp that is nothing : https://en.wikipedia.org/wiki/NIL_(programming_language) https://en.wikipedia.org/wiki/NIL_(programming_language)
- chalst 13y agoIf 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 13y agoThat looks useful, thanks.
- pjmlp 13y agoFor 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 13y agos/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 13y ago> 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.
- erikj 13y agoIs there a Scheme implementation that compiles to Go?
- wuschel 13y agoI 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/
- pjmlp 13y agoThere are lots of them that compile to native code.
- e12e 13y agoDoes 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 13y agoIndeed 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
- blahbl4hblahtoo 13y agoOh 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.
- deleted 13y ago[deleted]
- jcla1 13y agoAuthor here, in case anyone has any questions!
- sdegutis 13y agoHow 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 13y agoIt 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/
- deleted 13y ago[deleted]
- bfe 13y agoSee also Kakapo, an effort at a lisp interpreter in Go. https://github.com/bytbox/kakapo https://github.com/bytbox/kakapo