Monthly Archives: July 2016

Recurse Center

The Recurse Center is a three-month programming retreat based out of New York. It’s not a boot camp. It doesn’t have any teachers or a curriculum. It is mostly self-directed learning. RC makes money by helping its retreaters get jobs at their partner companies.

I recently went through the interview process and unfortunately was not accepted into their batch. It’s very disappointing, but I’ve to go put my head down and keep on grinding. Can’t let one no keep me down.

Asynchronous I/O

I’m learning about asynchronous I/O in the Node.js chapter of Eloquent JavaScript. I/O is input output. One way of handling I/O is reading and returning files once they are fully read (synchronous). This may cause a program to freeze up while it is still waiting for information.

An asynchronous interface allows scripts to continue running while it does other work and call a function (callback) after it is done.

 

Binary Digits

Binary Digits or Bits are numbers represented by 1’s and 0’s. Each value in a binary digit represents a power of two.

  • The first position represents 1  (2^0)
  • The second position represents 2 (2^1)
  • The third position represents 4 (2^2)
  • The fourth position represents 8 (2^3)
  • and so on and so forth

In binary, we count like below.

  • 1     –  one
  • 10   –  two
  • 11   –  three
  • 100 –  four
  • 101 –  five
  • 111 –  six

Each position can only hold 1’s or 0’s so when we want to add one to one, we carry a one to the next slot.

In a computer, all numbers are stored in bits.

 

Eloquent JavaScript Chapter 15

I’m currently working through chapter 15 of Eloquent JavaScript. The chapter walks through a project for making a simple mario-type game. Previously, if I had trouble understanding something, I would go through and write out all the code. I did that for this chapter, but I’m still trying to connect some of the pieces.

I’m going to keep grinding through for now, because I heard reading code helps you improve as a programmer. Plus, this is an opportunity to read code written and organized by someone who seems really accomplished and good at what he does.

Static, Dynamic, Compiled, Interpreted

I ran into these phrases and tried to get an idea of what they mean. Below are just some generalized definitions I could find online.

In a statically typed language, variable types are checked at compile time. This helps catch certain errors earlier.

In a dynamically typed language, variables are interpreted at run time, making writing programs a little easier.

A compiled language is when the code is translated to machine code.

In an interpreted language, the code is not executed on the target machine, but on another program.

 

Eloquent Javascript

I started reading and working through Eloquent JavaScript. I’ve been recommended this book by a number of people. I wanted to use React on my next project and wanted to firm up on some JavaScript fundamentals first. In addition, I’ve heard that the books covers a wide range of basic programming topics which seems helpful.

JS Object Property Names

JavaScript Objects are denoted by {} and they refer to arbitrary collections of properties.

var aObject = {
blah: 1,
blah2: 2,
“3blah”: 3,
“blah 4”: 4
};

You can refer to an object with dot notation if the property name is a valid variable name. In JavaScript, variables cannot start with a number or have spaces.

In the example above, you could get the values for blah and blah2 with dot notion, but the other examples you would need brackets. Brackets are used to evaluate and expression in this case.

console.log(aObject.blah);
// 1

console.log(aObject.blah2);
// 2

console.log(aObject[“3blah”]);
// 3

console.log(aObject[“blah 4”]);
// 4

Dynamic Array

A dynamic array is a data structure that has a fixed amount of space. Once all the spaces are filled and a new entry needs to be added, it will double in size.

It takes constant time or O(1) time to add an item to a dynamic array. It takes O(n) times to insert n items.

The sizing works by creating a new array and copying over information from the last array to the new array. Each time the array doubles, it will copy 1, 2, 4, … , n/4, n/2. This sum results in ~n. The total cost of insertion and copying from doubling will be 2n or O(n) times. so the (total cost) / (total cost for insertion) results in a O(1) cost per insertion.