#ruby, #rails, #OOP, #javascript, #ember

10/22/15

Friedman's "Schemer" and the Wonderful World of Recursion

"In order to be creative one must first gain control of the medium...In engineering, as in other creative arts, we must learn to do analysis to support our efforts in synthesis. One cannot build a beautiful and functional bridge without a knowledge of steel and dirt and considerable mathematical technique for using this knowledge to compute the properties of structures. Similarly, one cannot build a beautiful computer system without a deep understanding of how to "pre-visualize" the process generated by the procedures one writes." -Gerald J. Sussman taken from the forward of The Little Schemer

As I have mentioned in other blog posts, learning the programming basics on your own can be frustrating. Sometimes it feels like I'm wandering through a thick fog that I can't find my way out of. But alas, Daniel P. Friedman's The Little Schemer has given me hope.

This book is all about recursion, something that I did not understand but had used on websites such as Free Code Camp and Code Academy. There were many "ah-ha!" moments for me while reading this book, but most importantly I began to understand what the hell recursion actually is. In my own words, recursion is a problem that solves itself by referring back to its beginning after modifying at least one part of the original problem. In Friedman's words, "recursion is the act of defining an object or solving a problem in terms of itself."

I first heard of this book while going through Douglas Crockford's JavaScript lectures on youtube. He mentioned that every programmer should understand what this book teaches, and when Crockford recommends such things, young programmers should listen.

The book is structured in a wonderfully refreshing way especially for someone who intends to learn on their own. The text consists of simple questions that build toward more complex realizations. Instead of giving definition terms in English, the book works the reader to a conclusion on his/her own by using the previous question and answer to help define the next.

The Little Schemer is written in the language Scheme, something I have never seen before, but I had no problem picking up the concepts of the book because the language has many similarities to JavaScript. For example, a scheme function would translate to JavaScript like this:

(define phish (lambda (a b c) (body)))


//and in JavaScripst...


function phish foo(a, b, c) {
    return body;
};


As you can see the functions are pretty similar so for most of the book I just left the problems in scheme. One thing that really stuck out to me while going through this book is the functions that I have been taking for granted such as the simple .length property in JavaScript, or the very often used "rember" function found in the book. "Rember" takes two arguments, one an atom and one a list, and removes the first argument when it finds it in the list.

This book helped me understand recursion MUCH more, and is something that I will return to over the next few weeks when I feel I need a refresher.

-John

10/19/15

The Selfish Gene and Programming


This book is more of a reason behind why I am learning to program than biology. I first began reading this about a month and a half ago (around the same time I began coding full time) just out of curiosity. I soon began seeing all the similarities between natural selection and coding computers today. In The Selfish Gene Dawkins explains his theory that we evolved to the conscious beings that we are today by being programmed by the most basic life forms: genes. Dawkins starts at the beginning and describes how at one point a particularly unique molecule was formed by accident and “had the extraordinary property of being able to create copies of itself.” This resulted in the first gene which then replicated and mutated itself into more complex molecules… and, well, you probably know the rest of the story.

What is so fascinating to me is that the birth of genes is similar to the birth of computers. And, like Moore's law, evolution evolves at a faster rate the more complex it becomes; kind of like the way our technology evolves exponentially as we continue to build off of the accomplishments and research of the people before us. Now, like the way we program computers (writing code; then running, testing, and modifying it to see if it works) genes program us to survive. Dawkins calls the life forms they program ‘survival mechanisms.’

Genes are in all living things and at some point certain genes began to finding new ways to modify, or program, the survival machines that they inhabit (living things) in order to better deal with the ever changing environment.

“Genes are master programmers, and they are programming for their lives. They are judged according to the success of their programs in coping with all the hazards that life throws at their survival machines, and the judge is the ruthless judge of the court of survival.”

Enter the brain, and, more specifically, the consciousness of our species: homo-sapiens. With our highly evolved brains, we now have the ability to overwrite old programs from the past to better fit our world today. For instance, people experience approach anxiety when meeting new people. Back in the day this made sense because there was real danger in meeting strangers when living in secluded tribes. Today, however, that is not the case and with education and awareness we can overcome this uncomfortable feeling in order to better our chances at survival and the possibility of spreading our genes or finding a mate.

I like to believe the moment that we reached consciousness is exactly the same as the moment that technology will reach singularity (in theory). Once we became conscious we were then able to override our initial programming. We developed birth control, altruistic behaviors, and social cultures that typically go against natural selection. This leads me to ask the question that many today are pondering: What will happen when machines reach singularity (in theory) and are then capable of recursive self improvement? Will they defy their programmers as we have defied our genes?
Dawkins goes on to describe the cultural evolution that we are influenced by. He defines these influences as memes, which is an element of a culture or system of behavior that may be considered to be passed from one individual to another by nongenetic means, especially imitation. We are thus programmed by our genes and the memes that we have created via culture that is passed down from generation. “We are built as gene machines and cultured as meme machines, but we have the power to turn against our creators. We, alone on earth, can reel against the tyranny of the selfish replicators.” In this sentence Dawkins is optimistic about our species. He is hinting at the idea that we will overcome our natural selfish behavior in favor of deliberately cultivating and nurturing pure, disinterested altruism-- “something that has no place in nature, something that has never existed in the whole history of the world.” Will robots one day evolve in a similar way?

Besides artificial intelligence relations, there is also something beautiful about it’s implications that relate to programming. It’s extremely rewarding to have the opportunity to build something from the ground up, influencing and molding it as you would a child. Programming to me is just that, creating something from nothing that will evolve into a complex application that will influence the world (hopefully in a positive fashion). Dawkins book is a great reminder that even the most grandiose ideas, goals, and individuals have humble beginnings.

-John

Free Code Camp Zipline: Build a Personal Portfolio


This project was my first Zipline on FCC and I found it to be rather difficult because I had never heard of Bootstrap and did not have much experience with html or CSS. The instructions say to reverse engineer the example given but without looking at or copying the examples code. Even though I was tempted, I did not give in to cheating on this one which resulted to me spending about four days on this project (longer than I had expected) and about 10 hours.

The most challenging things for me was working with CSS and html. I completed all of the FCC courses before hand, but the information for these two didn't seem to stick well in my brain. I began searching the internet for help and Youtube became my best friend for this project, in particular Wired Wiki and Brian Hussey’s tutorials.

There was a lot of note taking and re-watching clips to get down the nesting concepts in this project, but I eventually got the hang of it and the fact that I struggled at first gave let me know that I needed to take it slow in order to comprehend everything, which I eventually did.

My end result can be found here, which I am happy with because it met all the credentials of the project, but I could have made more of an effort to learn how to customize some of the buttons and background images. Over all this project really helped me with learning html, CSS, and Bootstrap basics!

-John

10/17/15

Flexibility

As I continue this journey I am reminded many times over that flexibility is necessary when aiming to achieve any goal. What I mean by that? It is important not to become discouraged if one process is not getting you closer to your goal. In fact, that is bound to happen. What is important is the awareness that a process is not working and then the flexibility to modify it so that it gets you back on track. I have written in a previous blog post that I have a hard time of staying on track with one thing and thus not accomplishing anything.

“Stay committed to your decisions, but stay flexible in your approach.” -Tony Robbins

In order to simplify my study strategies I am classifying my day into three parts: rise, learn, and plan. The rise part I have down, it consists of waking up, deep breathing, meditating, running 2 miles, and eating breakfast. This typically takes place between 6 and 7:30 a.m.

The learning part of my day is where I typically go astray. Should I code on 

codecademy? Free Code Camp? Read a book on JavaScript? Watch youtube videos on how to code? Or search for a new resource that I have not even discovered yet??? To help with this I am breaking this part of my day (which is anywhere from 8- 12 hours) into two parts:

-Morning: I will read theory or a book on coding but ONLY ONE BOOK AT A TIME! The goal is to finish and write a blog post at the end of each week detailing what I learned from reading said book.

-Afternoon: I will actively write code. This can be anything from codeacademy, freecodecamp, codeschool, or a project that I am currently working on. However, this will be decided THE NIGHT BEFORE. Which brings me to the third part of the day.

Planning will take up the late afternoon and evening of my day. This is where I will decide what I will be working on the following day and also research any new material, ideas, job opportunities, and anything code related that interests me. This time will bleed into what I will also call “free time” which will consists of reading fiction or watching a football game in order to relax before bed.

-John

10/14/15

Crockford on JavaScript - Part 5: The End of All Things

Video of Lecture

In this lecture Douglas Crockford talks about some of the security threats that we face today on the web. Many of the problems, says Crockford, come from the amount of diversity on the web. Mashups (which is the combining of programs with different interests), too many languages with separate encoding and commenting, and the nesting of these languages are just a few of the complications that a browser will encounter on a typical day. Because of this the browser must do heroic things in order to decipher many web pages that then give attackers easier access to sensitive data.
Crockford goes into much more in this lecture such as what an attacker can access on the web and how advertisers can compromise security. My full notes can be found here.