I recently had the priveledge to attend the Recurse Center, which if you have not heard of, you should definitely check out. It was a really interesting time to attend, given the current global pandemic we all are finding ourselves in now. The entire experience was moved online, and done remotely.
While a lot of the social aspect was lost (but credit is due to the RC team, a lot was retained as well), I was still able to grow and learn about a number of things I had no idea I would tackle. I wanted to cover everything here, as a record of what I learned, and maybe as a starting place for when I can jump back in!
With that in mind, I was able to publish fancy-axis, with its first feature, a rug plot. It implements the same interface as D3 for axes, so that it follows the same API and can be used interchangeably. But now that the axes will need to access the chart data directly, it also adds a couple more methods as well an options object for styling, but it follow the same patterns as the rest of the library’s api so that it should still be familiar. Here is an example:
and here is what that could look like in a sample chart I built, with the options listed above:
I had wanted to dive into another language to further broaden my horizons on what are the styles and stardards are of another successful and popular language. I at first wanted to try some dialect of Lisp, probably Clojure, but I start also looking at Elm which is heavily influenced by Haskell.
I completed the official beginner’s tutorial, and built some small components, such as a simple counter. I enjoyed the type system more, but overall I did have trouble getting used to the syntax. I don’t think I would pick it up on my own, but I do think I would enjoy working on an existing project that used Elm! Here is a small snippet of a “Hello, world” app for clarity:
All code eventually runs as machine code. Before it gets to there, it is compiled to assembly, which is a symbolic representation of machine code. Since machine code is specific to the hardware it is run on, so is assembly. So, code must be compiled to something else first, called an intermediate representation. This is more portable now, as it can be run on any computer, and that computer would be responsible for compiling it into its own assembly.
WebAssembly aims to be another intermediate representation, fitting in right before assembly. It is run in the browser, and the implications are vast. Consider the JVM, which is what Java, Scala, Clojure, and others compile down to. This is considered an intermediate representation. If a compiler exists to compile code written for the JVM into WebAssembly, then any programs written in those languges can now be run in the browser!!
So I need to learn Rust now?
There are some special caveats (with WebAssembly as a whole), such as you can only return numbers. If you return complex type, such as an array, function, class instance, or even a string, the number returned will point to the location in the shared memory buffer where you can retrieve the data. There are some nice loaders though, where this work is done for you, and you can return strings and typed arrays, but not currently any other comlplex type.
Here is a sample of AssemblyScript that just adds two 32 bit signed integers:
Collaborative text editor
A few years ago at eBay, we typically used Collabedit for our coding interviews. It wasn’t that good, and often we lost connection and had to refresh the page. A coworker and I joked that we should learn how to build one and do it for a Hack Week project one summer. I agreed that it was a good idea, but we never got around to it. However, I decided to dig into it now and see if it could be done!
I started building my own and successfully got peers to connect to each other over WebRTC via a shared url. Next was the sharing of actual data typed by clients. Central to this feature is avoiding conflicts as everyone types over the same characters. One clever way to solve this is with a new kind of datatype I had not heard of, called a CRDT or confict-free replicated data type. Specifically, I would be dealing with a sequential CRDT.
It works by treating the characters as nodes, and edits to those nodes then become children themselves. Each node keeps track of which user made it. I’m oversimplifying here, but by treating the data this way, it can manage all the edits from various users and ensure that everyone ends up with the same result on their respective computers! This was perhaps the project I had the most fun on, and wish I had more time to delve in and get it working like the conclave team did. There is always next time!
As the Recurse Center often says, “never graduate!”.