Asynchronicity

by Gilbert Keith

I’m about ready to sleep like a log now (running hills played no small part) but I felt like I should blog a little bit about what I have been up to.

Right now a lot of my time is being taken up writing code for a project – a tool to help with registrations/tournament organization/etc. for quizbowl. I’m using Python (Flask) + PostgreSQL (a la SQLAlchemy) and very tiny amounts of JS (JQuery). It’s been very interesting to work on this. It’s the first real project I’ve worked on, and even though I’m barely at v0.05 right now, I’m learning a lot. Not sure if a lot of the stuff I’m writing is good. It feels hacky sometimes. But it works for now, I’ll worry about the beautification in a bit.

The biggest challenge so far has been grappling with ajax. It took forever to figure out what exactly it (i.e. JQuery’s $.ajax() function) was doing. That it boils down to just sending a HTTP request, I get it. But I had not the best understanding of what HTTP requests involved… It’s nice to abstract away the details of all that. The other interesting thing is the .success and .error functions. These are evaluated based on the response received, which may occur after your code is done going through its other things that sequentially follow your ajax call. I’m having a hard time describing why exactly this is interesting…but it tripped me up once or twice today. You see a lot of answers on StackOverflow about these success and error functions, which boil down to ‘the person asking not having a grasp on the asynchronicity of the requests/responses. It’ll take some getting used to.

 

Advertisements