
This is not the right way to look at it though Go and JavaScript are hugely different languages and compiling from one to the other is far from trivial. So technically it could look as if we’re comparing a Go → JavaScript compiler with a TypeScript to JavaScript compiler. In order to be accurate, I have to clarify something.įzf-for-js is, like many large JavaScript projects, not actually written in JavaScript, but in TypeScript.
#Totalfinder gc code
The last 5% is hell!), but rather tries to port the Go code file by file. This project aims to port the fzf code (or at least the same part that I called the core, when deciding what to include in fzf-lib) to TypeScript – so unlike some of the other efforts out there (including my own ill-conceived-now-discontinued one), he didn’t try to reverse engineer the fzf code from example inputs and outputs, and then rebuild it in JavaScript (trust me, getting 95% to work, is no problem. So I was very surprised when a couple of weeks ago I ran into fzf-for-js. When I first started looking at compiling the Go code a couple of months ago, I did have in the back of my mind that I wanted to manually port it to JavaScript as well, if only to see how much better (or worse) I would be compared to the automatic tools.īack then I had obviously checked if someone had already done this, and nobody had. In the last post I showed 2 solutions based on a Go → WebAssembly compiler (Go & TinyGo), and a single solution based on a Go → JavaScript compiler (GopherJS).

browsers).Īs I mentioned in the previous post, there are generally 4 ways to get some Go code to run in the browser: compile it to WebAssembly, compile it to JavaScript, manually write it in WebAssembly (or possibly in C and compile that) and manually write it in JavaScript.
#Totalfinder gc how to
In past posts in this series, I looked at how to convert a Go library in order for it to work in the browser.

Interface between Go 1.16 (compiled to WebAssembly) and JavaScript (syscall/js) August 05, 2021.Creating Fzf into a library: fzf-lib July 08, 2021.
#Totalfinder gc series
This post is post 4 of a (so far) 4-part series on "Making fzf available in the browser".
