Ammar Mian

Recurse Logs

From September 2018 to December 2018, I will be at the Recurse Center in NYC. One way to describe what it is: "a sabbatical for programmers". No tuition, no curriculum, no schedule; just smart, self-directed people and a vast amount of resources to learn.

I've been keeping daily track of my work and thought processes from my time here.

Day 1 (9/24)

Commuting from Cortlandt Manor to Brooklyn takes a little over an hour (a 45-minute express Metro North train, a 20-some minute 4 or 5 train to Borough Hall, a 5 minute walk to Recurse Center). We got a tour of the new Brooklyn space and met as many of our batchmates as possible. There are about 30 of us. Things people are interested in working on: Rust; databases; machine learning; augmented reality; computer-generated art. Five of us spontaneously met up to discuss databases. Two hours later, we had a whiteboard covered with notes on the components of a database and a calendar event for our next brainstorm. I’ll be reading some papers, source code, and blog posts over the next few days.

Day 2 (9/25)

The commute was nice this morning from Cortlandt Manor. Tomorrow morning, Alina and I are moving into our new apartment, which is conveniently less than a block away from Recurse Center. During my commute, I was reading Roaring Silence by Ngak’chang Rinpoche. Coincidentally enough, the opening chapter spoke to the idea of “unlearning”. This reminded me that I need not leap to action at Recurse Center out of some misplaced anxiety about not being good enough or not appearing busy/productive enough. So I spent today writing about what I hope to unlearn while I’m at Recurse. Some preliminary contenders:

Day 3 (9/26)

Today was my last commute from the suburbs. Alina and I spent all morning moving into the new apartment. Our furniture arrives on Friday, and we’ll be assembling our new Floyd bed frame tonight. I spent some time today getting up to speed with my looming contract work, a 20-25h/week commitment. This will roughly break down to ~6-8h on Fridays in office and ~3h/day Sunday-Thursday. I’m hopeful that this arrangement will work. After some “unlearning” reflection yesterday, I’m stoked at the prospect of writing a Redis clone in Python. Why? Because I want to study databases, and what better way than to study a widely-used, well-documented, open-source in-memory key-value store. And Python because it’s a wonderfully concise language that I have limited experience with. I spent time this afternoon reading through Learning Python, 5th Edition (which is ~1600 pages long!). Tomorrow I’ll wrap up some Python reading and switch gears over to Redis.

Day 4 (9/27)

We ended up spending the morning assembling the Floyd bed frame, which looks so good! I then went into Recurse and spent most of the day reading Redis source code. It’s very well documented. I went down a rabbit hole about how Redis uses jemalloc instead of glibc malloc on Linux for memory allocation. I came back up for air to wrap up a high-level tour in the docs of important code entrypoints. I then got late afternoon coffee with a batchmate, and we chatted about seemingly everything: philosophy of language, philosophy of logic, semantics, Israel, representation, symbols, graduate study, Brooklyn, Florida, anxiety-driven development. Very cool guy. In the evening, Alina and I set up our mattress and bedding.

Day 5 (9/28)

I’m at client HQ all day getting up to speed. Maybe I’ll have some time tonight to read some more Redis code.

Day 6 (10/1)

Today was a strangely anxiety-filled day! I still haven’t “written any code,” which may be the source of the anxiety. I think I’m desperate to get into heads-down deep work mode, but also feeling guilty for not being more involved in the serendipitous activity happening around me. Maybe once I get a single project off the ground, I’ll feel more comfortable bouncing around on different things. There are 11 weeks left, so there is plenty of time. I need to get back into my regular meditation practice, which has been on hiatus all summer. I read Michael Stonebraker’s “What Goes Around Comes Around” paper on the history of databases. I also have been working through the Redis source code, which is well organized and documented. The “AOSA 500 Lines or Less” book has two interesting chapters that implement simple in-memory databases. So I think I’m getting a good lay of the land. The next step (which hopefully takes place tomorrow) is scoping out the parameters of this database -- what problem does it hope to generally solve, how can I design it to contain abstract layers whose implementations can be swapped out and changed, etc.

Day 7 (10/2)

Today was the best day I’ve had so far. I’m finally beginning to understand how everything fits together in redis. Things I read about and explored today: async programming, event loops, and select/epoll/kqueue; C-styled code, dependency injection, and single responsibility principle; somaxconn and the file descriptor abstraction in Unix-based systems. Other stuff from today: a good (and well-documented way) to handle per-project dependencies in Python is to use virtualenv and pip freeze to isolate python versions and packages to whatever library/program you’re writing currently. Tomorrow hopefully I’ll actually write some Python!

Day 8 (10/3)

After diving into how Redis implements things in C, I gameplanned an initial stab at implementing roughly the same program structure in Python while taking advantage of its dynamic, more high-level language features. Instead of writing an event loop myself, I’m using Python’s asyncore library, which use GNU select() as its event multiplexer. This allows nonblocking I/O to take place. The library is useful because it provides a dispatcher class which, when implemented, exposes a TCP socket interface useful for defining client-server behavior. I ended the day with the basic abstractions working: Server, Event Loop, ClientHandler, Resp (redis protocol), Command, Store, and AbstractDataTypes. For now, this key-value store is backed by an in-memory Python dictionary.

Day 9 (10/4)

I learned that the asyncore library requires a lot more work to make it useful in contexts where clients are sending messages of variable sizes. Luckily, after some digging, I learned that Python has another core library called asynchat, which is built on top of asyncore. Maybe someday (hopefully later during this batch even!) I’ll revisit this and figure out how asynchat is implemented in terms of asyncore. Anyways, asynchat can handle concurrent clients and consumes only n bytes per I/O read (as defined by the user), allowing variable message sizes. Its interface is interesting in that i) like asyncore, client ”channels” are maintained in a global map, and ii) writing a response is as simple as pushing to a buffer.

Day 10 (10/5)

Felt sick today and was supposed to go into client HQ. Instead worked from home all day. There were quite a few things to nail down today, but we got things done. On to the weekend.

Day 11 (10/8)

My redisnot project is coming along! I have implemented: getting and setting string values; a server that handles clients asynchronously (event loop); an append-only log persistence strategy; some basic unit tests. I still need to look into the consequences of plugging my file I/O events into the same event loop as my network I/O events. Will this cause any race conditions? I need to shore up my understanding of what “nonblocking” really means at the systems level. The databases group met up again. A batchmate has kindly created a GitHub repo and walked us through his basic REPL that allows users to issue commands to the database he’s writing. Another batchmate is working on the BTree implementation and another on the pager between in-memory and disk.

Day 12 (10/9)

Today was a scratch. Had some personal stuff come up I had to attend to. Also ran a technical interview on behalf of my client. On the brightside, in the afternoon, I decided to start writing a command-line utility to make writing blog posts for my website easier. Previously, I had to manually write all the html for it myself. But the format of each blog post (in terms of markup + formatting) is consistent. So I’m adding a light abstraction layer above that that injects JSON properties into a template HTML file. And writing it in Python because I want to get better at Python.

Day 13 (10/10)

I’m planning on working from home in the morning, running to the gym to get a good workout in, then depending on how I feel, will either go into Recurse or spend the rest of the afternoon meditating. Today I added some more tests to redisnot and looked into the deprecation of asyncore in favor of asyncio. However, asyncio is available only in Python 3.4+ and still in provisional status (meaning they could make breaking changes to its API in future Python releases). So for now I’ll be sticking with asyncore with the caveat that I’ll probably have to change it later to stay fluent.

Day 14 (10/11)

I woke up today, went in to Recurse for the morning, and did some reading on redis + Python. The rest of the afternoon, I contemplated how I would design a language to make it easier for me to write blog posts but still retain some ability to customize things (without using a GUI or CMS). At first, I thought I could just run a convoluted regex expression on it, but then I wised up and returned to the Crafting Interpreters book and notes from my coursework with Oz and Bradfield. Then I realized that the language I wanted to write bore similarity with VueJS in some ways. So I read up some source code on their Vue template parser. Hopefully this weekend I’ll have a chance to write a blog post using a v1 of this program.

Day 15 (10/12)

In Austin for the weekend for a wedding! I’ve been noodling around with this html-compiled language for my blog posts. Using JSON as the data format isn’t something I’m happy with, so I decided to write my own little language (which requires a tokenizer and parser to make sense of it lexically and semantically)

Day 16 (10/15)

Exhausted from this weekend in Austin. Austin is an incredible town. Today I wrote some tests for my html compiler, fixed some bugs, and pushed out a blog post as a test! I’ll be cleaning some things up later and making this thing available on an open-source basis. Maybe someone else will find it helpful. I’m not a fan of using dollar signs to declare variables, so next week I may jump in and change that.

Day 17 (10/16)

I added more comprehensive tests to my templating language (named “BLAGH!”) and tried to publish an actual blog post. This revealed some big problems with my templating language. One, the regex matching pattern wasn’t quite correct (oops). Two, my debug logging wasn’t helpful for fixing problems. So I changed the placement of my debug logs, which helped identify the error. I got my first real blog post up with this! I’m using standard HTML syntax highlighting in my editor, which works like a charm. I may later go down the deep rabbit hole of the Mastering Regular Expressions book. There are parts of the codebase that look a bit nasty. I’d like to go back and clean those up or at least think about better ways to help future me reason about what’s happening. Overall, though, I’m pleased with the outcome, especially as a Python and compilers n00b.

Day 18 (10/17)

I finally woke up early today to meditate. I feel great today. I think given the success yesterday of my templating language, I’d like to work on a grab bag of things (and see which one strikes my fancy). I took two hours of Steezy Studio’s Beginner Hip-Hop class. Me likey! I also sketched out two solo business ideas ideas, each of varying feasibility. Out of these two, the second one seems like one I’d be most excited to do (and that has a demonstrable market). I've had to make many unconventional decisions along my path to becoming a programmer. Bootcamps are a dime a dozen now, but graduates of these programs can very quickly get pigeonholed into boring boilerplate jobs. There's so much space for the next level beyond that. I could tailor my pedagogy off of my learnings of what has worked at ( Viking Code School, Hack Reactor, Bradfield immersive, Recurse Center, my stint at Teach for America ). These seems like a very "me" thing to do.

Day 19 (10/18)

This morning, I grabbed coffee with a batchmate. We talked a bit about Clojure, Datomic, Rich Hickey, and reasoning about systems + the effects they produce. I spent the afternoon thinking more about the online coaching/school idea I had from yesterday, sending some feelers out to people I know who would be target customers.

Day 20 (10/19)

Onsite at client HQ. I ran a technical interview for a senior engineer candidate. He was really good. Otherwise, I spec'ed out an internal tool with the head of marketing. Then I went dancing in East Village with the wife and the amigos.

Day 21 (10/22)

Our building's rooftop lounge is amazing, so I chose to work from there this morning. I still am enchanted by the online coaching/school idea that's been festering. So I set up a splash page via Unbounce, wrote some basic copy, and bought 50 dollars in Bing ads. We'll see if anyone bites. My inkling is that high-touch education is not like a commodity business -- unless you have demonstrated your worth in some significant way already, no one will buy from you sight unseen. But today was a good exercise in figuring out what the actual problem really is, which is that bootcamp grads and junior developers can easily get pigeonholed into a career with no growth prospects. My thesis is that this happens because they never learned how to learn how things work. You become a dangerous engineer, thinker, and doer when you've figured that out.

Day 22 (10/23)

Today I'm at Recurse for the morning and grabbing coffee with a friend in the afternoon. Alina passed the bar exam! So we will celebrate tonight. As for the online school idea: it basically comes down to a series of well-crafted and well-sequenced "Build Your Own X", where X is some widely popular technology used by many companies. A first course would have to be something a mix of enthusiasts, beginners, intermediates, and advanceds would find interesting. So for that reason I may start with React, the popular and somewhat infamous frontend framework. Working on this narrows the scope a bit ("course" instead of "school"). If I can prove that my "Build Your Own X" pedagogy works exceedingly well, then people will be willing to pay money for this course. I'll have an easier time launching it or sharing it with those who would be interested. And I'd be able to build an email list for future courses. If it doesn't work, I'd have spent a couple months getting really good at React, which is fine by me!

Day 23 (10/24)

I spent all day reading React source code. It's very well documented! Cool to read about all the influences that went into building it. From my current understanding, the core ideas of it are: composition, unidirectional data flow, immutability, and small API. These three were revolutionary when React came out since no major UI library (until React came around) focused on making it clear in which ways one should mutate state and pass state around. Also cool to read about its shortcomings and use cases where it isn't the best choice.

Day 24 (10/25)

Today I spent the morning and early afternoon reading React source code. It is well documented, so I'm having a good time. Maybe I'm on the lookout to prove my "learn how things work" notion, but later this afternoon I helped a client debug an issue directly using some of my findings from the morning from understanding React internals. In the late afternoon, I met up in Union Square with an old mentor. My next steps generally break down into three possible directions: 1) take an engineering job on a team I'm jazzed about; 2) take on contract gigs to get more exposure, keep flexibility, charge more, and work on side hustle; 3) join an early-stage investors office and get exposure to teams and businesses. I met with my mentor to walk through these possibilities. The third option is interesting, but these positions are few and far between. Plus, I wonder how much of my interest is genuine; am I only in it for the prestige grab? Option 2 sounds most appealing at the moment, but I'll need to stay focused and patient.

Day 25 (10/26)

I'm at client HQ today. We were chasing down a database bug that ended up being in the way table relationships were set up with the ORM. Otherwise, I'm feeling like a lot of change and growth is upcoming in the next 6 months. The past couple weeks I haven't been as disciplined with my routine and productivity as I normally am, which usually means my unconscious mind is grappling with something big. I shall be on the lookout for any changes in my behavior next week!

last updated: October 23, 2018