Monday, October 31, 2016

Relationship Between DIKW Hierarchy and Ladder of Abstraction

 Data isn't information. ... Information, unlike data, is useful. While there’s a gulf between data and information, there’s a wide ocean between information and knowledge. What turns the gears in our brains isn't information, but ideas, inventions, and inspiration. Knowledge—not information—implies understanding. And beyond knowledge lies what we should be seeking: wisdom.
    — Clifford Stoll

After reading Learning How to Learn by Novak and Language in Thought and Action by Hayakawa. I noticed that both sides of Gowin's Knowledge Vee conforms to a specific form of Ladder of Abstraction that I have named as Knowledge Ladder of Abstraction. In the existing literature Knowledge Ladder of Abstraction is termed as DIKW Hierarchy.

The reason for the name Knowledge Ladder of Abstraction is that DIKW Hierarchy is related to Ladder of Abstraction described by Hayakawa in his book. This ladder feeds into the left side of the next Gowin's Vee in the sequence of Vee's, which generates the next ladder. The DIWK hierarchy consists of the following levels:
  • Wisdom
  • Insight
  • Understanding
  • Knowledge
  • Information
  • Data



Sunday, October 30, 2016

ActiveJob Basics in Rails 5

This week's episode on ActiveJob basics in Rails 5 is now available on iTunes

Version Compatibility Test

How many times have you run into version compatibility issues that takes up a majority of your troubleshooting time? Wouldn’t it be nice if we could come up with a specification? Who reads the details buried in the readme files? Even if you diligently did read it, is it possible to juggle all those compatible version numbers for different version of the library/framework in your head while troubleshooting? Wouldn’t it be nice to make it an executable script? Read this article to find out how you can cut down time spent in troubleshooting.
We spend 90% of our troubleshooting time in finding the cause of the problem.

Software Compatibility

Software compatibility is the ability of software components to work together. Write tests for forward compatibility and backward compatibility. A library or framework must create and maintain a list of:

1. Common Compatibility Issues
2. Resolving Application Incompatibilities

This will save lot of time troubleshooting broken systems due to version incompatibility issues. It is a good practice for frameworks and libraries to ship a version compatibility script that developers can run to find the cause of the problem quickly.

Forward Compatibility

Forward incompatibility due to minor release is caused by regression bugs. In a real world project example, I found it very difficult to fix a bug due to RSpec regression bug. I had to downgrade RSpec to fix this difficult problem. Forward compatibility due to major release cannot be taken for granted. Example, I had to work with a custom test automation framework that broke when the Chrome browser was upgraded. The Chrome driver was not compatible with the version of the Chrome browser that was released after the Chrome driver release date.

Forward and Backward Compatible Assumptions

We all know that assumptions is the mother of all fuckups. Assuming a certain version is forward or backward compatible is one of the biggest mistake and will cost you time when your application breaks. It is just a time bomb waiting to blow up when you accidentally upgrade either due to bundler or OS. That's why it is a good idea to lock the gem version in the bundler. Instead of mentioning the minimum version of dependent software required for the library or framework to function in the readme file that gets ignored, wouldn't it be nice if it shipped with a version compatibility test script that documents the version compatibility? This also prevents the developer from wasting their time hunting and reading the release notes for all the dependent software to narrow down the culprit.

For instance, Rails can ship with a script that checks for the compatible MRI Ruby version, OS version, RVM, testing framework version etc. It is not enough to run automated tests on a continuous integration server. We need to write a version compatibility test that must also be run to quickly find any backward compatible and forward compatible issues. This will prevent shipping software that causes headache for early adopters. The script should ideally take a software compatibility matrix as the input and output the success/failure message with detailed resolution.

Version Compatibility Gem Specification

If we take this one step further, it should become part of the gem specification. It should be run before the gem is installed on the system. Does the gem require native libraries? Does it compile only on certain version of the compilers? By running the version compatibility test, we can catch the errors even before it begins to create issues. This version compatibility test can be exposed as a gem command to be run when developers need to troubleshoot and write scripts for different environments.

Tuesday, October 25, 2016

Rails and Draper Railscast Sample Code

To get the Railscast example code profile-before to work, change the Gemfile to lock the redcarpet version:

gem 'redcarpet', "~> 1.17.2"

Otherwise, you will get the error:

undefined method `new' for Redcarpet:Module

The newer version of Redcarpet requires new syntax to instantiate, refer:

To get the Railscast example code profile-after to work, use the following Gemfile:

gem 'rails', '4.2.4'
gem 'sqlite3'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails', '5.0.4'
  gem 'coffee-rails', '4.1.0'
  gem 'uglifier', '2.7.2'

gem 'jquery-rails', '4.0.5'
gem 'redcarpet', '3.3.3'

gem 'draper', '2.1.0'

Otherwise, you will install the latest gems that is not compatible with the code.

Focus Question : Is the Draper version 1.4 compatible with Rails 4.x ?

Readme does not mention what Rails version is compatible with Draper 1.4. There is a clue in the Gemfile:

version = ENV["RAILS_VERSION"] || "4.0"

which means it must be compatible. Let's downgrade the Rails sample project to draper version from 2.1 to 1.4 and see if it works. Uninstall all versions of draper and lock the draper gem version to 1.4 in the Gemfile.

gem 'draper', '1.4.0'

The profile page still works. So it seems that draper 1.4 is compatible with Rails 4.x.

Ladder of Abstraction in Software

In the book Language in Thought and Action, Hayakawa discusses the Ladder of Abstraction. The ladder consists of several levels of abstraction, with the concrete things at the bottom and more abstract things at the top. The example he uses in the book is process level at the bottom, Bessie the Cow, Cow, Livestock, Farm assets, asset, wealth. One thing that is not emphasized is that each layer is from the perspective of someone. In the book example, the perspective is of someone who is a farmer, to a banker.

In software, certain concepts are at the topmost layer. For instance, Separate things that change from things that stays the same or Separate things that change at different rates. These principles are at the top and there are architectures like Layered Architecture and MVC that are at the lower layers of the abstraction layer. Similarly, concepts such as Program to an Interface is at the top and principles such as polymorphism, Open Closed Principle etc are below that level.

Domain Driven Design book is a great book. The problem is that it stays at the topmost layer of the abstraction layer for too long. For instance the chapter about domain model, shows an example at the very end of the chapter. A good explanation varies the abstraction levels within the same paragraph or even within a sentence. If the audience is familiar with the concepts, then it is ok to stay at a high level of abstraction. The book does have code samples in Java that makes the concept clear. Nothing is more concrete than showing code examples to illustrate the high level concepts.

The Ladder of Abstraction is a useful tool for writing. It can be used to organize the software development principles. We look for characteristics that are common among objects/concepts to go higher up the abstraction ladder. As we make the high level concepts concrete, we are adding context to the abstract concepts. By providing a context, the reader has a chance to see how it impacts their live. Explanation that shows a scenario that the reader has encountered in the past can make the abstract concept clear. Writers can use simile and analogy that fails in the ladder of abstraction to make things clear.

How does the Ladder of Abstraction relate to the Govin's Knowledge Vee diagrams? It would be interesting to compare them and see if we could get more insights into the way we perceive things in the real world.

Monday, October 24, 2016

The Usual Suspects in Troubleshooting Problems

Usual Suspects

1. Environment (Hardware and Software)
2. Code Issues (Bugs)
3. Data Issues (Corrupt or invalid data)
4. Software version compatibility issues. (Known issues).

Software Compatibility Matrix

Ideally we should create a Software Compatibility Matrix and write a script that will either pass or fail to enforce it. For instance, I was working with a custom testing framework written using Ruby, ChromeDriver to test the system from end to end using the browser. I had to spend almost an hour to find the cause of the problem. The workaround took just 5 minutes. It turned out that the latest version of Chrome broke the ChromeDriver. One hour could have been easily saved by creating a Software Compatibility Matrix that listed the versions of Mac OS X, Ruby, RVM, Chrome etc. This would state which versions are known to work with others without causing any problems. Any OS update that causes indirect update of any of the dependent software would be immediately caught by the script that enforces the software compatibility matrix for the custom testing framework.

When Rails is released, the compatible versions are usually specified in the release notes. This must be explicitly expressed in your project's software compatibility matrix. The usefulness will become obvious during minor/major upgrades to the gems and Rails. I had run into an issue where ActionMailer had locked the version of the depedent gem Mail to specific version that had a bug, it caused the rake script to crash everytime it tried to send an order confirmation email. The version of mail gem that had the bug fix could not be used because of the ActionMailer locking the version of the dependent gem. The only workaround was to set the SSL flag to true in the Rails configuration file.

Thursday, October 20, 2016

Update One Gem at a Time

For upgrade to major versions, it is better to update gems one at a time to resolve one issue at a time. Bundle commands:

bundle update gemname
bundle update ––source gemname


You Should Update One Gem at a Time with Bundler. Here’s How

Tuesday, October 18, 2016

Dumb RSpec Error

Why can't the dumb fucks provide a message that shows how to resolve the problem?

Stupid ass error:

Using `stub_chain` from rspec-mocks' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` instead

Ideal Error:

You can use the new syntax to resolve this error:
allow(double).to receive_message_chain("") { :baz }

Monday, October 17, 2016

GoRuCo 2014 - How to Debug Anything by James Golick

ames call ok
I I O violinist
pictures things on so i know i James Hallock I everywhere online Twitter
get Hobbes Instagram freenode
my blog is James Bond dot com very easy to find online
and I work 24/7 see you can always reach me there
%ah hour for a company called
are copied hola G I we make a product called package cloud
where we do I apt yom and ruby gem repositories
as a service if you have a need for public or private
our package repositories or both I'm definitely check this out i'm talking if
you want to talk about packaging
I I would venture a guess that I'll probably get more excited
then anyone else in this room about talking about packaging
say this right I am somewhat of 10
programmer say this right and there's been a lot of talk on my
Twitter recently in on some blogs and stuff about whether we should stop
saying yes or
suggesting that we should stop saying this and I think it's important to
distinguish between
people say this and sorta a moment of frustration an outburst personal
frustration is what we do for a living can be very frustrating writers pressure
on you I ship something somethings broken
get frustrated you tweet something whatever and people
thrashing legitimately believe that everything is terrible right
I was gonna pull my i phone in my pocket right now but I'm not allow to happen on
and show you my iphone to be like I have a super computer in my pocket that can
literally some in nearly any media that was
ever created %ah via the air
that's not terrible that's fucking awesome right by
as much as I think that you're wrong if you legitimately believe that everything
is terrible
I think that you're probably at the very least naive and possibly being a little
bit disingenuous if you don't admit
that everything is broken and I don't mean that nothing works obviously
Softworks right but the reality is the software is Bobby units flaky and it's
on reliable
on despite our our best efforts to make it better om
and this actually makes sense right
were innovating really fast we
software like software engineering is a relatively new field we're still
figuring out how to do it
om and we really just haven't caught up with the
pace and innovation and growth in our industry and you know we're still
working on it right
so it makes sense that everything's broken and
as a result in everything broke it being broken when you get engineers together
in a room
our online wanna the big topics of discussion as always we're hiring right
better car
right how do we how do we actually had we produce software that's less
unreliable or less more reliable a rather that's that's more correct that
that works better the handles edge cases better
all these different techniques for doing that right there's
you now testing obviously very popular in the roomie world static analysis
I and then you know stuff like what IMRB was talking about this morning where r
are with new languages have more sophisticated type systems that are
capable of
more accurately expressing the constraints have up different units
inside of our programs
but one thing that we don't talk about that much
or lease in my opinion that we don't talk about enough he is how do we call
where and water what are the strategies for dealing with our software when it
doesn't work
whether it's our caller or so or someone else's code I since your day on Twitter
arm if you wanna play high quality software that performs
you should expected said text box at every level
there's a very simple reason why bugs exists at every level
and sell given enough time getting enough complexity
you're going to run into those bob's and either graphics on
or they're so many broken so
over the last few years arm I fixed
a buncha bogs in a bunch of diff out a bunch of different love the stock
obscene lots of bugs in my
my own code are but bob's in the room TV and bugs and not memory allocators my
see Paul kinda places I always get this question
people asking me like law how did you how did you find that but how do you go
about finding a bob
in a code base you're unfamiliar with how do you go about finding a bob
in a language that you don't know very well and
I realize over the years that the methodology I use for debugging
is always the same doesn't matter where in the sack I'm looking
are it doesn't matter what the language is it doesn't matter whether I even know
the language really
it's always the same methodology for debugging and it's very very simple so
that's what the stock is about
every good debugging session starts with this quote this this is a mantra among
so someone major boss maybe it's the user
maybe it's a friend com CEO
and they reported the fact in something
and you pull up the called the you think is the offender
and you stare at it air like honors house is possible this can't be possible
this can't be happening you reread the calling you
you read according to read over and over again try to understand how it's
you keep saying miss Wright reckon back that
cell by the way there's no room in the stock sell sorry but not sorry
arm so this is a true story about a debugging session that I engaged in
op a few years ago I'm from Toronto Canada
a friend from my hometown who was running a PHP site
I and he called me up one day he's not happy at all he had a staff
are are people who are working with them I know where they were at this time but
he called me up and he's like
hey my site is down
I am I got a call so why you just like your team to fix it
he's like while they're not here because I reasons
so he's like you know can you fix it
so I don't have a source cards I didn't know anything about the system never
seen the source code
never even really talk to any visible burns I
written in PHP I had written PHP maybe like five years ago
very little familiarity with the language I I did happen at SSH access to
his service to the had diagnosed
some other thing for him at some point %ah that was unrelated
on so
he's like acne fixin unlike I don't know I guess I can take a look
saw I S H in one of the servers arm and
Michael K walton's probably running PHP under Apache
so I'll take a look in the Apache error logs that's where I figured the PHP
error logs would be
and of course there's an nothing in there
right and it's funny because
you know you might think this is like for a worst-case scenario now that the
site is down there's nothing in Los
but the fact of the matter is that there's never anything in the logs
and even if there is something in the logs your be really lucky
it's useful I mean if the program knew I was broken
probably wouldn't be fucking broken right
saw call what now this is what I did
I knew the PHP code was probably executing in one of these apache process
is so I found a key ID for one does patty processors
then I ran a program called esterase are to attach that running program
and give me some debugging output if you're not familiar with as trace
s race is a program %ah that will give you a trace on all the system calls
the get executed by programming you attach it to you self-knowledge system
call is
system cost create the interface provide the interface between israel and
programs after the
kinda programs are probably most of us in here right most the time
are and any operating system cell system calls are are used for all kinds of
things like
writing to files are two sockets om or
allocating memory are all kinds of of has a service is essentially that
the operating system our provides user land
s frees up what looks like this well basically asked what s race does
very simple little program are is that it captures the system call information
are using a colonel API and then reconstructs
in ASCII taxed are those system calls to look like C function call so you have a
name the function
arguments in parentheses and he will sign and then whatever that that's a
small happens to return
in this case our writing to file descriptor one to standard output
from us up offer which is in this case a c-string says hi has a new line
character at the end of it
author argument to write his number bites to write for map of her to the
file descriptor
and then the return value is the number of bytes the government successfully
to that bob Corker
most the system calls that you're probably getting I
that they're probably gonna provide useful information to you when you're
debugging like a roomie program or something like that
are gonna have a really simple names like right or open
I'm or read up by if you get confused about us what a system calling is you
don't know what it's called by name summons have some like really really
obscure names that probably won't mean anything to you
om if you've never done this kinda programming for are there all documented
in section 2
the manual so it's really really easy to find them manned space to
and then the the name in the system call and most them are documented pretty well
I thought a lot of people how to use as trace I and this is usually wear a
condom falls down
so you attack as for some processing your like a rotten find bud
and then you get like and this is like it's really small small mouth bass race
out but I've seen many megabytes
as trace output for like a small number requests on a web server
I as you look at this and you're like wallet how do I do now
right but it turns out there's actually like a really really straightforward
of war finding the causes of problems in
as trace output the first step is
well for small yup always have to work backwards so work from the bottom
and and and go up the first up is to try to find where the failure is actually
being reported
so in this example this is Apache writing
a $500 HTTP response back to a socket socket number 12 presumably
om and so you know what you find here being reported that probably everything
beneath that
is not very interesting cuba's obviously the cause of the failure happened before
the failure got
our report right
and then work back up and usually if you're gonna find
the I because you're bob in the ashtray south but its Kenny relatively close
to where the air actually gets reported to the client or to wherever it's being
reported to you
cell in this case we work back up we find this feeling called open and
there's a
a file called bar slash WWW slash TV die I and %ah PHP
are that's missing and then we get a 500 error right afterwards
i sorry to form a hypothesis like maybe someone type of that file
I and they deployed bad Carter I doubt they added the code right on Sir I don't
really know how
on how that works by Tom
there's luxor a hypothesis form right as you can slowly work backwards from there
in the output
until you find something that looks like it may be the offender right
and so there's a just above that are a few you ought not to be green but
arm just before that feeling open call
others a successful open call to bar slash WWW
slash index of PHP arm
and so you can imagine you know you had dinner at the site eyepatch attempts to
load a file called index of PHP
which has a a typo including net on
and that's causing $500 that's a a sensible hypothesis for
hot what's causing this outage
then try to prove your hypothesis cell look at look and see in the
index of PHP file are we attempting is this does our hypothesis or a bar
did camp did the first test our hypothesis prove true
yes we are attempting to include something called TV tie-in Doki HP
then look to see if %uh files there is up I'll actually there maybe the
permissions were wrong
turns out that follows not there but there is a file called TV die I N C dot
cell that make sense someone there's bad back or on the server
that's what's causing the 500 error next up is to fix the Bob
and then you now feel good about yourself
cell I think that the total time
hot that it took me to fix is outed from the time that my friend Toronto called
until the time his I was back up once like three minutes
and I i felt pretty good about myself and that he was really impressed me was
like wow
how did you how did you do that right so Molokini
you know songs any flowers or anything but he seemed appreciative
I am I will like some flowers
by Tom
you know later that night I Sun reflecting on that debugging session I
was like why was that so effective but I never find bugs in my own code that
right like once my car something stupid like that takes me like an hour to find
or longer
right unlike searching through files try see the air
and I realize it's because when you comin to a debugging session with all
these assumptions
they usually lead you astray write your assumptions were right
you probably would have written the right code in the first place right and
then there wouldn't be a Bach
susser 0 through all of my formula for how to debug
anything which is forget everything you think you know kisses all rock
in the first row of follows from that which is to get
a third party opinion so if you don't now anything
if you're blind then you need to ask someone for help me to ask someone for
some information about what
actually happening as opposed to what you think is happening cuz
if what you thought was happening was right then there would be no bach
so in this example and and mostly in the stock I'm I'm talking about the
esterase it's very very useful extremely useful
for debugging programs on Linux it's like such a great first thing to look at
but there's a whole bunch of other ways to get third-party opinions
on this is a great diagram it's a little bit intimidating
on but a lot of the school's depending on what kinda thing you're trying to
IOC and you can be very very useful and there are a lot of them are worth many
of them are worth warning if not all of them depending on
what kinda software you actually right and try to debug gonna put the slides up
online so %ah
on see you good look at this I grant you want to know I am
there's also other ways getting third-party opinions for example if you
suspect that the but might be in the operating system
finding another program that does what your program a spa studio
and running out and see if you get the same behavior I might be where
of sorta making a first step toward confirming
I that its the bug is is in the operating system rather or in another
layer rather than in your programs that can be very
useful technique is wall I'm sure there are other ones that I haven't thought of
that I've never used before om
so next but i wanna talk about
I its kind available whether as a bug in in
RPM package Potter buggin in apt the other package manager
on this is this is an interesting debugging session that lasted
up way too long arm
it started when we had a customer who tried to install package lot repository
on the latest Ubuntu and I know if you can see is output by
aside many of those URL's arm are the three letters I G N which means ignore
which means that apt
couldn't find anything there the request failed something like that I think
knowing those files many these files are like critical files so that their
the package index wasn't working right as pat action ex is working on
every other version of Ubuntu every other version Debbie and we had gone
around testing on
on the latest Ubuntu yet so we're like pretty confuse
South ok after staring at our own code
completely useless Lee for a while up last race
and this is a different way invoking ashtray so that the last way that I
that that I showed in the last example I was attaching to an existing process
I with this this way if you can actually start a process underneath best race
I and get all of the output off from that process in the the output from this
was really long it was like a couple megabytes on soles lot to decipher
but using our trusty methodology I
work backwards to find a failure so this is that there this is apt
I am writing to standard output what we saw so ignore
and then this this is a local copy a package bottles like this local
RVM IP address but for three thousand rails app
I'm and then trustee which is the
the distribution and then the name of the file that
that app was failing to find so we started working back up from there
and we found this law right which looks like
I'll if you can't read it says read 6
and then a long string that says four hundred you are I failure
and then the you are eyes assigned s3 you are all that we redirect to those
impacts cloud
and then after that a new line and it says message call and bad header line
okay so it seems like s3 is
returning a 400 that's kind of odd wonder what's up there
try confirm the hypothesis and make a crawl request %ah to that same
that same exact signed as three or all and get back to 100
call so
here we have a case where what happens reporting seems disagree with what's
actually happening in
I don't have space for tennis lies we actually ran TCP down
which danse out all the network traffic from their request to confirm that app
was in fact receiving a two hundred on from from s3
saw what now wall
this is where things start to get a little bit more real and you have to
actually download the source for whatever you're trying to debug
I and try to figure out how that thing works and and where the problems
now this step is actually a lot harder then in my otherwise sound
arm knowing where to find the source for
packages that are installed on your system depending on what flavor of my
next or
whatever operating system you're using might be a little bit richer than it
sounds and I've had a lot of
our late nights and early mornings that were caused by
me thinking that i was debugging a version of this the source code that was
running on my computer but it turned out to not be
even remotely similar versions %ah
distributions like a job Red Hat for example
heavenly patch source code so the version number that is on the package
could be completely different from the actual source code
are that they compiled to build that package so like if you do an opus
open SSL version off from there there version the package version gets
installed from the
from the Red Hat on our vendor package repose
it will look vulnerable right now but it's actually not as they
maintain their own set of patches
if you're on a happy face distribution apt-get source
and then the name of the package one pack the actual source that was used to
create that exact packets on your system
%ah into your home directories this is really really useful
and it's worth knowing for whatever platform apply on
now app is like a lot of lines c plus plus
lot more lines than its not like is not conceivable that we could just
enter the source directory even if even here the best he was caught program in
the world in just find the bug you need to find
a starting point I in in that in that code especially if you're unfamiliar
with the card base and especially
if you're unfamiliar with the language cell
the key here is to locate some kinda hawk sometimes straying or sequence and
bites you think might be
on hardcoded into the source code so
in my case I was kinda guessing that this error message bad header line
was probably somewhere I in in the App Store scarred and that proved to be true
its containing a bunch of these translation files that a
that perform kinda like internationalization for apt solids
translated works in a much different languages and then it's also in this
c plus plus file
so this work is a little tricky especially if you don't know c plus plus
but the fact of the matter is if you can read it really matter programming I
would venture a guess
that with enough effort or with a a small amount of effort you can
a few C-plus class methods on
if you stare at this for long enough in it it did take us awhile
I you'll see that it's looking for malformed headers or what it believes
are malformed hatter's
now taking one step back from there when you first read this code you like Way
implement its own HTTP quiet that's kinda weird
turns out it does on and it turns out that the way that it processes headers
is a lot stricter than most other HTTP clients
probably because a lot of other HTTP clients have been made a lot more
relaxed over the years I've
you know the the protocol being so popular in lotsa
misbehaving HTTP servers in the wild but
absence so specific on that it HTTP parser is just way stricter than
everyone else
so basically with this is looking for is a header that its
that ATB headers are the name header a call in
the value of the header I and then a new line right
and this is looking for headers that have no value cell name
coal and and a new line
turns out if we look back at our crawl I
maybe you can see it there but there's a header an empty Hatter
the content-type header %ah that was causing this thing to trip up
and report this error
we fix it by actually selling content type on all 4s three resources which
is probably a good idea any way obviously call
somebody's fax:
sock roll till locate the correct source code
easier said than done I'm and you know for two points off on a platform
learn how to do that I you know it won't take that long to figure out
I and knowing knowing how to find the correct source code will will save your
I guarantee identify hardcoded string
I or some way some hot that you can use
are to find a starting point in the source code off from which to work
so this is really important because if you like I remember what house debugging
in MySQL
its now two million lines of code or something like that
if you have starting point not finding anything
if debugging is a fine all if we think about it like
customer acquisition final I think step for
is where probably most people drop out the final you know they come to some
call this written some language the half million where
there a roomie programmer I and the cop on Cincy
or some c plus plus by the reality is
that with another effort you can learn this stuff and it's really not that much
you know its its a lot a lot he's called basis especially if you follow like
a good methodology for for reading through them are not that hard to
understand particularly if you're trying to find
and understand some small you know defect in them
on you know I would I would I would encourage everyone
I to not to not to fall out the final here too
to you
to to dive into code bases in languages that they don't know
because that's how you learn lot of people ask me like
I where to start learning C or worse are learning about systems programming stuff
like that
and you know the answer is that debugging is there really really great
artist wanna get your feet wet in that stuff
hopefully get to the stop getting a step that's a good time to have a beer
I am fix whatever is broken so
those are my sub for how to debug anything I forget everything you now
get a third party opinion locate the correct source code
I'm identify hoc stare at the car rental make sense
maybe learn a new language in the process and then fix whatever is broken

Thursday, October 13, 2016

Inventing Game of Life - Numberphile

t a no
player game a read a book called automata studies a whole series of
interesting things about automatic machines for the automaton in particular
John one Norman had been interested in colonizing the planets you see you can't
afford to take humans out to the planets
it's a long way away you've got to carry more food and everything that the weight
of the human by a long way
by the way you've also got to equip your planet with an atmosphere and one moment
idea was that you first send some machines over his model was that you
really going to to send them to Mars and Mars called the Red planners and that's
because it's got a lot of iron ore basically rust and so what these
machines do is initially
well a whole other stages but in a big important stage is they smelt the iron
ore and get I'm and then they're quite clever machines they start using this
iron ore to build new machines whose job is to smelt more and more and so on
not another you doing that but rust is I'm oxide and so when you separate it
into the you get oxygen as it
and so now you can build up an atmosphere containing oxygen
I don't think he helped to equip the whole of Mars with such an atmosphere
but maybe you have some kind of shell or dome and in that dome
you can have an atmosphere and then after a considerable time when these
machines will be chugging away and
making more machines and so on and smelting more i'm producing more oxygen
you send the guys over for us you know
then he realized that you had to have a machine capable of building a copy of
itself and that seems a bit difficult and may be in order to build a machine
you need a more complicated machine and in order to build that more complicated
machine you still need an even more complicated machine but one Norman
thought know maybe that's not so and and he proved it wasn't so he proved it
really i don't know whether he was a word of this by copying what's done to
us with RNA and DNA inside every cell of your body
you've got some RNA mud molecules and they contain complete instructions for
building another one a copy of you it i call that the tape that you know you so
you have a machine and you put a tape in it and it builds a copy of whatever
machine is specified by that tape and then if you can do that and it's fairly
easy to do that in a way you can now feed it with a copy of its own tape and
then you can Billy in that way you can manage to design a machine under tape
which will build a copy of that machine and copied some tapes as it will build a
copy of itself
voluminous machine each square had 29 states in the game of life you only have
two states on and off or alive and dad whatever you want to call them in one
Norman's that could you have 29 states if we wanted to do something different
let's have some other facilities you just added a few more states in other
words his machine was designed
now my life game wasn't designed I just thought of thought if you couldn't
predict what it did then probably that's what
because it was capable of doing anything for about 18 months of coffee times and
I'm not sure that you know we used for sure that we didn't use every coffee
time we tinkered with the rules the rules as they finally came out were if
you have exactly three live now if your empty or dead or that with this and you
have exactly three live neighbors then something gets born at the next time if
you are alive and you have two or three live neighbors then you survive that i
mentioned the birth pool first to be born you need exactly three live
neighbors to survive you need either two or three
so there were other iterations of the game could have been different yea
you know what was different for quite a long time we think it with these rules
and finally came up with the ones i said and they really seemed to have a very
nice properties namely didn't seem to be able to be to predict what would happen
and in the end we succeeded in proving essentially anything could happen
these things could do any kind of computation wanted to do and you could
design configurations that we built themselves or built more complicated
machines themselves all sorts of things you had no computers when you were doing
this early were no computers at all
after a time there was a computer which had to screen the PDP eight and before
the PDP seven forgot Mother's pd peace
probably the dps data processing or something and then somebody immediately
program the game of life for it and but the initial thinking was all done before
I told Martin garden about this he's the person who run this mathematical games'
column in the scientific american for the 25 or 30 years
I thought it would interest people I didn't think it was the interest people
his readers as much as it actually did
well first of all his first column
the scientific american was considerably before this about
hexaflexagon rooms and it got more reader mail than any previous article in
the entire hundred and something year old history of the magazine up to that
time and so the editors wanted him to write a monthly column and he said he
said to me because he was so broke that he just said yes before he knew whether
he could write a monthly column but anyway he wrote that monthly column very
and then when the life game cut came up guess what I've got more reader
correspondence that anything in the entire history of the magazine including
this extra flexican column from my point of view though it wasn't real
it was flattering to have so many readers interested in this and so on and
but I i personally didn't think all that much of it but it's nice you know it's
nice to have other people value something that you know I didn't really
value in a way
overall now that I'm getting old I'm really very pleased that this did happen
it's one incident in my mathematical life and I shouldn't be so annoyed about
it and I'm trying not to be has a big builds upon is that one of it that the
mathematics and and I know it's finished
I mean that's another thing really you can build upon it in the following sense
you can study particular configurations you can find alternative rules that
still have the same properties himself but nothing I think that followed on it
was just as interesting as the basic fact that this set of rules did exist
fairly simple and how these astonishing properties which weren't astonishing to
me some configurations just died off after a time
there's nothing left on the board some configuration seemed to go on forever
can you tell which of those is going to happen but what really
if you and if you put it put a configuration on on the board and
followers and followers and the followers and after a thousand moves it
hasn't died off
oh well maybe it's going to die off next move there's no way of telling no
make way of telling whether a thing is definitely going to die off following it
you see doesn't tell you if you follow it for a thousand moves and it hasn't
died off yet
well maybe it'll die off in a million move so billion moose or a gazillion
moves without without this and and we do now and it's this is not due to me it's
a theorem of mathematical logic dating from the nineteen thirties the halting
there's no way of absolutely guaranteeing to tell whether think will
go on forever or fade away completely
that's one of the astonishing properties you would think that if the thing is
governed by very simple rules that would be a very simple way of telling whether
this very simple thing is a consequence of a very simple rules but there's no
way of telling the inventor of game of life for people who have studied that
deeply have a deeper understanding that can you look at the configuration say
something what is it still there for you - well I might be able to sort of
recognize some little portion of it and say well that's not going to have any
effect we can proceed as if that's not there because it's going to die and 23
moves anyway but no in general
no you can't I mean this condition that you know you cannot tell is not a
question of not being able to tell because you haven't got the beginning of
brain or something
it is an absolute condition you know it doesn't matter how clever you are
there's no guaranteed way of telling ok
I don't taste this but you don't love it no I don't know
really don't
yes it made me happy is the only one of those different things
I you know I sit in a corridor in the mathematics department in princeton and
I think about things and I imagine that the young graduate students that think
you know this guy's a lunar he did something good once and i don't care i
really don't care
I've been released from worrying about what other people think about
probably i've often said I've said for 25 or 30 years that the one thing i'd
really like to know before i die is

Stephen Hawkings The Meaning of Life (John Conway's Game of Life segment)

back in the nineteen seventies an unexpected breakthrough was made by a
mathematician named John Conway here in Cambridge
he devised something called the game of life
a simple simulation that shows how a complex thing like the mind might come
about from a basic set of rules
the simulation consists of a grid a bit like a chessboard extending infinitely
in all directions
each square of the grid
can either be lit up which he called alive or dark which he called yet
whether a given square is dead or alive
depends on what is happening in the eight other squares that surrounded
for example if a living square like this one has no living squares nearby
the rules say will die of loneliness
if a living square is surrounded by more than three other living squares the
square will also guide of overcrowding
but if a dead square is surrounded by three living squares
it becomes lit for his book
once you set an initial state of living squares and let the simulation run these
simple laws determine what happens in the future
the results are surprising
as the program progresses shapes appear and disappear spontaneously
collections of shapes move across the GRIK bouncing off one another
there are whole kinds of objects species that interim some can even reproduce
just as life does in the real world
these complex properties emerged from simple those that contain no concepts
like movement or reproduction
it's possible to imagine that something like the game of life with only a few
basic laws might produce highly complex features
perhaps even intelligence
it might take a grid with many billions of squares but that's not surprising
we have many hundreds of billions of cells in our brains

What is meant by Data Abstraction

what is meant by data
abstraction most of the time in the interviews we do face a question what
this abstraction and in real time programming most of the people are
confused with the term waters data abstraction and how be a children's in
this video I will try to brief you about what abstractions say for example if i
say an employee you will be getting an idea that an employee means he should
have some employee number you should have some name he should work in some
particular job you should earn some sadly we are not bothered about whether
that employs a manager or the sales man or any kind of represented people to
understand the concept of abstraction in a simple terms when they wanted to work
with data abstraction I don't concentrate on an employee for example
shaker or I don't concentrate on an employee called tests trainee was say
assume that shaker is an employee and strenuous is a employee he will have
some particular number and he may be working as a salesman with the salary of
say for example 7,000 and he may have some employee number and he may be a
club earning a salary of a toaster we don't create an individual class for
shaker or straining was what we try to do was we will try to concentrate the
one which is going to be common for both I need something for maintaining the
employee number so i try to pull this into a class scored as employee
so i will have a class employee when i try to maintain employee number i try to
identify that the job we are going to have it so it's going to be the job so i
will try to identify that i need something called as a job and we have
something like salad so i would like to maintain the salary and the shaker and
mrs. Sweeney was these are the two employees so i need to maintain
something called as employing me know I don't concentrate on any specific person
we try to concentrate on something which is going to remind common for all
whenever we say our data abstraction we don't think about the unnecessary
information we always focus on the essentials we try to concentrate on the
relevant data we try to abstract the 11th information and unnecessary data we
try to remove it when we try to say our data abstraction we don't think about
our employee class should look like what we think about this in this particular
requirement if I wanted to have an employee class what are all the details
I required based on that particular thing we try to define this so when we
try to define it
we consider this asset data abstraction we will try to capture the entire
information and we try to say employee for this organization all the common
because we will pay to maintaining hope you understood waters data abstraction
thank you

Abstraction by Professor David J. Malan

my name is David Malan and i teach a course called cs50 which is our
introductory course in computer science for concentrators and non concentrators
alike and it's of course I myself took albeit not initially sometime ago indeed
when I arrived on campus here I wasn't sure what I wanted a study in fact that
course catalog itself was completely daunting in so many new fields and so I
frankly rather gravitated naturally toward what I already knew I thought
back on high school and I liked history a bit and i really like this
constitutional law class and so when I was slipping through the catalog I
realized well maybe government is what I should concentrate in and i still had
this this curiosity about computer science but then and now to some extent
it was very much this discourse and more generally this field to to be where I
just kind of figured that everyone who's taking the introductory course cs50
surely have been programming or taking computer science they were 12 years old
I remember looking through the glass of the window of the computer science
classroom in my high school and not really knowing or caring what like my
own friends were doing in there just seems so foreign and so unfamiliar to me
it wasn't until sophomore year that i finally got up the nerve to put my toe
in the water and even then it was only by enrolling in the class pass/fail lest
i fail the class or or get a be in the class it was my way of getting up the
nerve to try what was a very unfamiliar field and what I realized immediately is
that even though i had this perception from high school especially the computer
science is programming and writing code and sort of heads down typing away on
the keyboard it's actually much more than that it really is about ideas and
it's about problem solving and in fact is about using techniques and using
ideas that were actually pretty familiar to me already
in fact the idea one such idea that I'd like to propose is just this today just
one of several ideas that of abstraction and abstraction is a fancy way of saying
taking something that's really complex and sort of taking a step back and
packaging it up in a way that simpler and that from the top down you could
just understand for instance I to this day have absolutely no idea how a car
works or underneath the hood what's inside the engine if something broke
would have no idea how to fix it but I've gotten pretty good at using that
machine and interfacing with this API or application programming interface
whereby get in the chair
and I turned the wheel and the things start turns and I push the pedal down
and I understand that and that's what's key
I've abstract away as have all of us we've abstracted away what a car
actually is to only needing to understand and care about and master its
interface and in fact underneath the hood all of those details can change it
can go from gas to electric at the end of the day other than filling it up
doesn't really matter to me when operating that device
what's going on underneath the hood and consider some other examples for
instance what is a country when we talk about a country well in this country a
country is a collection of states
well what are what the state well as state is a whole bunch of town
well what's the town a town is a whole bunch of houses
what's house so it's like four walls and a roof but what's a wall in a roof well
it's you know previously wood and from a forest or trees that have been turned
into two-by-fours the like
so if you get down to the nitty-gritty you could actually build the thing from
the ground up but we humans generally don't have to care about reconstructing
things from those basics we have the luxury of talking about fairly complex
ideas from the top down in a way that just makes them so much more manageable
and so much understood more understandable now let's consider things
that are a little more technological like in a computer at the end of the day
a computer's only input sources like a power cable or maybe a battery and even
if you don't understand how the computer works
you probably know that there's electricity coming out of that cable
battery so there's like electrons flowing in and out but then today that's
the only input to this device and how can it do so much
how can i write my essays on it and send emails and browse the web and watch
videos and listened to music how do we get to such complexity when the only
input at the end of the day is power or electricity and in fact what's going on
underneath the hood in this case if we can land there just quickly you have all
these little switches inside of a computer transistors as they might be
called millions these days they're just little switches that given some
electricity allow you to turn something on or off on or off and a computer
scientist we typically call on one and we call off 0 and it would seem that our
only vocabulary is zeros and ones but how do we get from zeros and ones to our
emails into images and two videos and music well let's consider just what we
humans no more familiarly
it is like the number 123 this is just a pattern of symbols 123 but why is it 123
think back just a few years to grade school and you might recall that this is
the ones column the tens column and the hundreds column and now how do we get
from these columns to an actual met value we understand well this is what
100 times 1 plus 2 times 10 plus 1 times 3 which of course is 100 plus 20 plus 3
ah there's my 123
well turns out the computers aren't as fancy as we humans we have 0 and nine at
our disposal typically so-called Decimal System computers just have the binary
system by meaning to because they just have zeros and ones often on so in the
world of computers underneath the hood the best we can do is not having powers
of ten up there up top 110 hundred thousand but rather the ones column the
tools column the force column on up in other words we can only use powers of 2
in this case so how in this world my represents the number we humans know a 0
a computer underneath the hood just turns off three switches so it off 000
this then is 0
how do we represent using a pattern of switches or lights the number where
humans would no is one again even if you're unfamiliar with computing and
binary the end of the day you just need those columns so what's the pattern
something something something will give me the number we humans know as one
what's that pattern 001 it's really as simple as that
well how about the number we humans know as to how instead we write this not just
001 but rather 010 and if i want to count up further I can do 011 which now
gives me three so that's it that's binary now we've gone from this low
level input just electricity flowing in and out of the device to being able to
represent numbers and in fact if I just keep adding more zeros and ones to the
left just like you can make decimal numbers bigger i can represent any
number i might want but how do you represent an email then how do you send
for instance the message hi ! or draw something like a flower on the screen
is an image that you might see on facebook or the like well how can we
decompose this well you know what why don't we just decide and society that
this pattern of zeros and ones is just going to represent three numbers in fact
I could do up the math the ones place to his place for his place 8 16 32 and so
I can convert those if i did a little quick math into these decimal values
which is a little more manageable in my mind 72 73 33
well it turns out that humanity just decided some time ago that this number
72 in the context of an email or Microsoft Word of the light just going
to be known as representing the letter H followed by followed by ! an arbitrary
mapping but one we humans all agreed upon some time ago
meanwhile if i take the same pattern of bit and think of it in the context of
like the web browser or adobe photoshop or something like that
now these patterns of bits just by nature of the software I'm using can be
considered in a different context so yes it's still the numbers 72 73 and 33 but
what this really means in the context of graphics software is give me a little
bit of red a little bit of green and a little less blue again 72 73 and then 33
and this is an RGB triple red-green-blue if you've ever heard the expression RGB
combine those three colors together and you get this sort of very very murky
yellow-brown that just barely shows up on the screen here but now henceforth i
do not care how murky yellow is implemented you really can't see it I do
not care how the word high is represented I just want to get real work
done and send an email and I've abstract away those low level implementation
details so to speak such that i know the computer can do it but I just don't need
to care now I can function at a higher level so to speak so from there we have
unfortunately a realization that abstraction is really really useful and
it's kind of hard to operate without it and in fact if you can't take for
granted what something is but instead have to consider lower-level how to make
it you realize a challenge in fact that i invite one brave prefrosh to come on
up on stage and appear before all of his or her
potential classmates you have to be comfortable appearing on cameras and
therefore the internet but if that hasn't set to har I of a bar anyone but
there's like three hands in this audience total 456
now this is a little litmus test ok IC bouncing in one ctor that works come on
down and meanwhile
meanwhile if those of you still seated can pick up that white sheet of paper
that has been sitting near you and if you have not received one tear someone's
in half next to you and grab pencil we gave you or something else
what is your name this is Catherine Catherine this is your future classmates
come on over here and what i have for Catherine here is the following in just
a couple of moments time i'm going to show Catherine a picture and Catherine
your charge is not to tell everyone what to draw but how to draw it in other
words if you in the audience cannot take for granted what this higher level
object is we're gonna find that it's quite hard to function without
abstraction so if you would into this microphone described for the audience
exactly how they should draw what only you see there that is the only role you
should not say what it is just how to draw it they have a pencil and a sheet
of paper to which they can apply that pencil
okay step one alright so you have to keep in mind that all of the lines will
be equally spaced apart arm so first you should draw a why in the center of your
ok and then from your right hand side from that are from the end of the top
right-hand side of your why draw a straight line down towards your belly
button not diagonal straight line make sure it's parallel to the paper arm do
the same to the other side so that the entire drawing is symmetrical and then
arm from the bottom of your why draw a line parallel to ok so when you first
started out with the why you'd you have three lines right so there's one on the
Oh No
okay no okay i hope no one saw that
ok so you have one on the top right hand corner and one on the top left hand
corner so you want to connect the lines from that you drew a parallel to your
belly button to the bottom of the why can you guys do that I feel like the
slip is it that you've this is that is what terrifying
yes it is now click ok so give them another instruction or two and then i'll
collect some of the answers and we'll see how close we just got okay and then
so you guys all know what the roof of the house looks like it's like a
triangle so give your wife a roof of that house so that the Y looks like a
square coming a little less abstract now but and how about two more instructions
to get them to the end I me I don't know what wouldn't people then let me do this
let me get you off the hook here it's actually a wonderful reinforcement of
the message which is that life is hard without abstraction but let me out round
of applause for Catherine here let me come out and play and real fast if I
could just steal a few of the incarnations of these drawings 120 come
down here real sorry 3456 that'll do it let's see just how close we came then to
what catherine was encouraging you to draw and I'll do so by swinging into
video mode here so we have one such drawing
alright so we have one such draw all of them actually look pretty similar
so a little something like that this one too pretty similar missing something on
the bottom and this one here and actually amazingly whether by sheer
application of those commands or a little bit of a flip of the paper there
we have what was indeed before Catherine which was this image here which might
jump off might jump off the page into as of course
hey draw a cube but when you don't have that higher level abstraction and
actually need to do it from the ground up
that's why this idea of abstraction is just so key and this then is just one of
the ideas that you would learn in the world of computer science and just one
of the ideas that you would learn at the coming fall starts and allow me to
conclude here with a look at some of the other ideas and experience that awaits
you in a course called cs50
is cs50 harvard university's introduction to the intellectual
enterprises of computer science and the arts of programming
if you walked in here today and see hundreds of people crowded around their
laptops smiling laughing thinking
that time

Computer Science 10 - Lecture 1: Abstraction

he right to know
thing I no I'm Jane Garcia and I'm delighted to be cocky
this course this semester on this is a brand new course
she probably knew I from Lakeside answer from other
PR I'm if you are here because up there have to put in the newspaper
came it later turned had newspaper had
didn't work right I know and for so
well I'm serious 10 there are looking you're welcome who saw the ad in that
case in the daily cap
okay well to okay okay
I so the tunnel the course the beauty and your computing
and this is a brand new court
a year ago we hot to university this course
its kinda pilot offering to see it if scratch the language you using
and BYOB the extension could hold up the University
pounding on and it did held up wonderfully so we decided
let's go 446 span the language makeup or your course in fact replacing the other
introduction his course yes 3l
titled and Russia symbolic from symbolic programming
so see Austria was gone never going to be
hot another I we're really excited about gonna be computer science
sharing the love and the joy and beauty enjoy up
computing with not majors and review actually the
push to make this the course that everyone takes coming through we're
really excited about that
just some context this course was chosen as one
5 national pilots for the new advanced placement course on computing called
apcs principles and that's really exciting
if you watched it the website CS Principles .org
Dorell Wright after this arm is a place to describe that project and we are
one university example a course that make and model
back at the high school level at ten thousand new high schools to brand new
course in high school so they're trying to expand 10,000
high schools and that's really exciting that our course might be a model for
really a fun thing wattages again next semester that hopefully every semester
after that so really
very happy about this we've got two outstanding teaching assistants
republish introduce
are so you can seven churches selves into the camera can get over to
with the folks are go ahead tell us
when rices are you doing first for your study up
group alright I
well growth sir Brian just tell you more about the
doubt so I we have if you look at our website we've got so many wonderful
happy faces to help you with read with regard to readers
and lab assistant we've got so many excited people about this course this
course is really got a lot of energy
and the CSI really happy about that brought a more details have covered the
course being
computing and have programming ap have the
talking about the social impact computing history and happen learning to
program this wonderful language right to play more
but that just one last yr the AP we're gonna be I'm poking prodding you cuz i
really wanna know
whether this coursework right comparing this course five other courses across
the country
to be having some surveys before and after was to work with them
to figure out the exact details the servo more service that
probably surveyed more than other alright
solid device is priced lecture but I gotta kinda sharing the lectures are
also gonna be having some guest speakers
outstanding faculty from across campus and maybe even supposed ministry coming
back and telling us
how their particular technology works yet where we already have
Twitter coming to talk to us that's really exciting maybe some other folks
I for Minister coming as well so to me really thanks mister and went back to
okay so as you can tell dan is in charge of joy so that makes me the beautiful
up I'm Ryan r-wi
I'm I am interested
in the use of computers in teaching kids
younger than you that sorry makefield I'm and
I so I had a lot to do with the development a
BYOB which is the extension to
scratch they're going to be using scratch in a language whose
this is scratch before people
okay scratches a computer programming language designed for kids
I'm so it was designed to be really really easy to get started in
which is why we thought it would be good for non-computer science majors
I'm but because scratch is designed for kids there are some things that he
didn't do
and I so some other schools who have courses like this
I'm use scratch for like the first week or two
and then switched to some real language I'm
which is a kind of bait and switch it back I'm
and we wanted instead to extend scratch that I could actually do the whole
curriculum in
that's what we've done and I'm really excited about it um
okay okay so is dan said
um there's the practical half for the course which you do in lab
learning to program computers and then there's the big ideas
I component are which involves the lectures and the discussion see or spend
some time sitting around in a small group
i'm talking about things I'm I really do talk in the discussions by the way are
also kinda defeats the purpose
don't leave it all up to the tast carry the ball I'm
right so one other reasons for this
all-new courses we want you to understand that there is more to
computer science
then just had a red a computer program home
it's true that there's a lot of programming in the curriculum but there
are other things to do
and we want to give you a broader introduction om
to it cell are so we're going to talk about
on San aspects is social context of computing and also some other
theoretical computer science ideas about
measuring how good a an algorithm is a process for computing something or other
arm summer the limits of computation
our summer the history of computer science for example in a few weeks
you're going to learn how one of the first ever computer scientists
more or less single-handedly won world war two after the good guys
I'm by breaking
secret German code and getting patient
allies about the Germans were up to without that
we would have probably lost the war so this week's big ideas abstraction
pounds is probably the central idea of computer science
arm so it's worth talking about and
on I also teach 61a which is our first course
for CS majors Tom that assume some programming background sir
so into actually there's a question how many people are as if now planning to
take 61a
and spring are a lot of great okay so you get to see me again
I'm and you will hear me say computer programming is really easy Klein and
yeah I'm computer programming is really easy
as long as the program your writing is small
so the world is full of 12 year old computer programmers and and they do
interesting work
on but not great big programs or industrial strength
you know can write characters from right to left for Chinese people
stuff like that programs from
when you write big programs what's hard is controlling complexity
an abstraction is about controlling complexity and I know that
that's a lot of big words you have no idea what I'm talking about but bear
with me
and you will arm so the solution to the problem of complexity
is Chongqing or layering so instead of thinking about your problem
in a TBD little piece its you take something anybody pieces and put them
together and give them a name
and then you can think about your problem enters a bigger pieces you keep
doing that
until you have a very big pieces that I'm you can
can I think about all at once search ranking is one metaphor for abstraction
the other is layering where you start with very low level things and you build
on top of that
higher level things on top of that I love of ass
so the classic example is thinking about
I what's under the hood in a car Oroville
I'm so water cars made out well really if you look carefully
cars are made of nuts and bolts and and metal rods and
little paper gaskets and and
rubber hoses and things like that I'm
each piece of metal by the way is made and Adams
right which are made a electrons and protons and neutrons
which are made of quarks so there's lotsa levels of abstraction
even below the things that you ordinarily think I've
as the basic units like a bolt
I'm cats may do something to but if you're trying to repair a car
are you don't think about it in terms of quantum physics
right the you think about it in high level terms you think about things like
this is the engine this is the alternator this is the transmission
I'm an
thats abstraction okay so taking the
little pieces in the car and grouping them into bigger units
and thinking in terms of the bigger units and there are two reasons that
that helps
one is that there are so many of the bigger unit C you don't get lost
and the other is the bigger units are more meaningful you can say
what the purpose if the transmission yes
right whereas it's hard to say anything interesting about
what's the purpose if this particular bolt
you know inside the car arm
okay so the march of technological progress which has been going on for
you know a couple millennia is at least in part
a march toward greater and greater abstraction
so arguably its abstraction that enables
technological progress in every field it's certainly true about computer
um sustaining with cars
in the earliest days a vote amid bills everybody who drove a car
had to know at least something about how to fix them cuz they broke down all the
time right
and so you couldn't drive an automobile
unless you understood the card a pretty low level love abstraction
and cars got more reliable after a while but you still had to know
some things about how the car worked in order to drive it
in particular the main example I'm thinking I've is
I'm the transmission I mentioned before so
I'm it used to be that there were only manual transmissions not automatic
and so in order to drive a car
you had to think about why the car has different gear ratios and what that's
all about and
low gears for more power and high gear is from where speed
you're cruising speed and all that stuff and you had to know
things about how to shift gears which involves pushing down the clutch in that
there's a lot of complicated timing involved
and in the really old days I'm
are you had to know had a double clutch if you want to be able to downshift
anybody know a double clutching is nobody's heard
right I'm Noack
exactly exactly if you wanted to do what you had to do was
hit the clutch get into neutral rev the engine
it the clutch and get into the lower gear that you want it
I'm otherwise the gears grind you know
as the each other and anyway it was really really hard to drive a car
because you had to think in low level terms about how it worked
me invention the automatic transmission was the main
enabling technology for a really wonderful abstraction that we have today
today basically you want to drive a car there to payrolls
the one on the right mix the car go faster the one on the left makes the car
go slower
and that's all you have to know right arm
an suddenly anybody could drive a car
is really a big deal when that happen now
side comment the widespread use of cars has turned out to be a mixed blessing
because a pollution and global warming and you know having to fight wars in
Iraq to get more oil and things like that
I'm drunk driver yeah there there are reasons
I'm so just like computers
cars are not a completely
wonderful no problems technology they are wonderful
but their problems associated with them and you're gonna learn is course that
the same thing is true about computers
about the use of computers and the social impacts of computers
arm so in fact many historians of science
don't like to use the word progress at all
because they think progress brings in implicitly the idea that every new
technology is completely good
you know I instead they talk about technological change
which is a more neutral and language
I'm so
two pedals that the gas pedal on the brake pedal
are what's called an interface a user interface
there so the means of communication
between a human being and the Machine the car
om so
on the driver's side have this abstraction bar so
an interface is also called an abstraction barrier
it's like a wall and one side or the way you think and I'll a book
well horizontal and once I do you think in high level terms and
down the bottom you think a low level terms about how it works so
above the abstraction barrier the driver just asked to now
right pedal faster left little slower arm
and that is about the behavior of the car what the car does in response to the
person the pedals
now once that interface became standard
that wasn't the end of inventing new technology
so above the abstraction barrier things haven't changed very much
the automatic transmission made a big change in the user interface
there haven't been many changes in the user interface
NEC as significant is that since then but they're being huge changes
on the other side of the abstraction barrier
I'm so original a for example
when you push the gas pedal you were mechanically operating a little lever
that adjusted as valves that control the ratio
a gasoline to air going into this on there is in the engine
so you made the car go faster by
making the fuel/air mixture have more fuel and less air
okay he did a very mechanically by pushing the pedal
that's not true today today when you push the pedal
all it does is I send a signal to a computer
in the computer can sense exactly how far down you push the pedal
and the computer takes that into account
in adjusting the fuel/air mixture but it looks at other things too it looks at
how fast you're going
and what you're you're in and whether you're going up or down on many other
things that
that affect what it what it does and
I'm also the
forming a that fuel air mixture is now done separately for each engine cylinder
so instead of having with that used to be in all cars the carburetor
that's there was 1i have now every engine cylinder has its own fuel
that does this fuel/air mixture attack so they've been huge changes
underneath the extraction barrier but I'm
the engineers who built that new technology
could have for every change in the underlying technology put some lights
and switches
on the dashboard to help you control the technology more finally
but they wisely didn't do that
they didn't change the interface about the abstraction barrier
okay not they changed a lot below the objection very but they tried to make it
said it was still true you push the pedal more a car goes faster
and you didn't have to think about I'm
how that works need the surface
the same thing is true about the brake pedal
used to be originally that
you push the brake pedal and you were mechanically
squeezing the wheels
okay you're operating old had that rubbed against the wheels to slow the
car down you did that with the street if you're for it
from see how to be strong originally drive a car
and now wasn't so good so they invented power brakes
so you push down on the brake pedal your operating
I hydraulic cylinder which is is a machinery
that essentially amplifies the power up your foot
and it's the breaks under that actually squeezes the wheel to stop the car
I'm except that isn't quite true that was true for a while when they first
power brakes I was at work your for it
went through intermediary to get to the
actual breaks and then there were few accidents because people's engine
failed on the road and so
on the hydraulic system stopped working and so they push the brake pedal and
nothing happened
you know they had car crashes so now you know actually have power brakes
when you have his power assisted breaks
in which you push the pedal
and you're doing two things your operating hydraulic cylinder that does
most of the work in stopping the car
but also there's a direct mechanical linkage for me refer to the break
so that you know if your engine dies and I where you can stop the car
arm these days
they have anti-lock brakes which means
between your foot and hydraulic cylinder
there's a computer and that computer
I'm looks at various aspect to have the wheels are turning
to decide if you're about to go into a skid
and if so it overrules you
you're slamming on the brakes and the computer in the car saying no
if I actually operate the breaks that fast this guy's gonna go into a skid
and so it kinda Paul says the brakes in you can feel the AI Craig pushing back
on the pedal I'm and so
again there's a very complicated interface using
various levels of abstraction are
underneath the brake pedal but as far as you're concerned it's still
push the payroll stop the car cap
I'm and the point of all this technology is to make that more true
so that no matter what the road conditions are the purse the parallax
was the car down your pressure
ordered stops the car I'm
and again with the brake system they could have put a lot of lights and
switches on the dashboard
help you control it but they wisely didn't
I'm although a footnote to that
these days there are
automatic transmissions that pretends to be manual transmissions
I'm because young man
like to feel that they're controlling the car
and so they're all these extra widgets that you can
operate if you want to this order
normal mode where the car just drives itself and
pseudo manual mode where you can actually change the gear shift
and make your fuel economy worse and make your
engine performance worse but feel like you're in charge
okay so there too
aspects to abstraction that you have to know about the 1 I've been talking about
up to now mainly is
hiding details see you doing something very very complicated
and you find a way to develop a simpler way of thinking about it where you
sweep allow to details under the rug
arm the other aspect a abstraction is generalizing patterns
arm so I
to illustrate that I wanna talk about the wheels of the car
you know this for other right the front lines in the back ones
and um they're actually different from each other
the front wheels are the ones that steer the car
footnote technology marches on you can now get cars
in which the back wheels also turn a little bit
om and this is opposed to improve your turning circle and help prevent skids
I but mostly the front wheel steer the car
I'm cuz if you think about it he steered from the back
car would go the opposite other way think it's going and
when Rivera I'm depending on what model car you get
the front wheels may also be polling the car providing the power to run the car
or the back wheels might be pushing the car that's our front wheel drive
and rear wheel drive and then there's also four wheel drive where all four
wheels are
car under power I'm so the front wheels in the rear wheels are different from
each other that's the point
but in many ways they're the same
there round there you know for made at a rubber with air inside
I'm and so
as a kind of abstraction I
you is a car driver are allowed to think about it is if the wheels were all the
they make the wheels all look the same and they're all the same size on its
that there have to do they remember those
and where you don't remember but have you seen pictures
a really old bicycles they have a huge rear wheel in a tiny front wheel
I'm but its front wheel out any real
okay whatever yeah Wireless
I'm well
they could done in front wheels and rear wheels have cars
something like that they probably wouldn't do it to such an extreme extent
but it could have turned out
to be a slightly better now engineering
yet to have the Pro is bigger
or something I'm but it's much simpler to have them all the same size
so that's taking things that are almost the same but a little different
and combining them into one
pattern so we can say use this pattern
and then you only have to talk about those details which are different in
different cases
okay so
I you're gonna be working with I'm this
Scratch programming language on the computer and
you wanna dry square so
you could write a program to draw a square that's an inch
by an inch and then you could write a separate program to draw a square that's
two inches by two inches
and so on I'm but the other thing to do
is driver write a program that says draw square
and when I use this program a given an input saying how big it should be
aka so it's they're having a lot a separate programs to do a different
kinds is great
we just have one program to draw any square thats
also abstraction arm and it's the kind of abstraction that's about generalizing
a cautionary note here abstraction is not the only
concern when you're doing engineering and sometimes I'll see situations which
engineers decide
not to generalize patterns so
my example if that is I'm some cars
I am recently have different size
wiper blades for the 2i provides in the front of the car
I'm so they'll be think this is right
small one on the driver side in a bigger one on the passenger side
typically and to make this work
there's a lot of complicated engineering at the motion of the passenger side 1
so it doesn't just go bloop bloop because ruden
Mike back I'm to it sort of cover more the windshield
really anyway so the cost if that
is when it's time to replace your ways you can just
they give me too 14 in Draper blades right you acted
get this one for the left in this one for the right I'm so it's a little bit
harder to think about
but I'm it cleans the windshield better so that's an engineering trade-off
arm all else being equal
it's better to abstract to find common patterns
arm to find ways
chunking things together and use them but every once in a while
are for some efficiency reason people decide not to do that
from that's a upper division computers and
okay arm
now I may finish early so
how does abstraction work in computer programming
well let me describe scratch a little bit com which you're gonna see I guess
today this afternoon on so
your computer screen an of fun the left
is a menu things that it knows how to do
at right there's a stage which is a little
window where there's I'm a cat
and it doesn't have to be a cat you can change the shape but when you start it
up it's a cat
also named scratch I'm who carries out
the instructions that you say to do like you say I'm
move ten steps and the cats are
jumps ten steps over on the screen and whichever direction it's
facing and there's a turn
demanded changes what direction it's facing but here's this cat
and you see a cat book like that move on the screen
okay well
there isn't really a cat inside your computer
I'm with the is is pixels
an abbreviation for picture element dans the graphics guy said he's gonna tell
you all about that later on
but I'm what looks like a cat is actually a
to pixels have different colors and
were in Intel's what has to happen when you say to move the cat
is we have to erase all those pixels where the cat was
meaning turned into white or whatever this color the screen background is
and then dry a new center pixel someplace else
and that actually happens dot by died
right deep inside I scratch
which is itself a computer program it's a programming language
so that's an abstraction as far as you're concerned
scratches just given and your programming in scratch your taking these
blocks like move
so many steps and linking them together
to make what's called a script om that tells
the cat to do a bunch of different things I'm
and scratch is the underpinning of allowing you to do that programming in
that way
but scratches itself computer program
written in terms of a lower level abstraction
I'm actually happens to be written in a language called small talk
I'm that's pretty obscure otherwise
on better interest you hear a little bit about it and sexy 18
you do that um and small talk
is sort of closer to how the computer hardware works
but still pretty high level and their lower level languages and then finally
at the language the machine actually speaks
so scratch is an abstraction every single thing you do in scratch
involves busily is it abstractions the you don't even have to think about as
far as you're concerned
that's a cat there really is a cat inside the computer
writing you can tell it to do things and I'll do I'm so I guess it really should
have been a dog
because you know cats don't do it it on Twitter but
I'm that impact your know why
okay so if the abstraction is working well
then you don't even think about it as an abstraction so
you know think about all the things you do with computers that have nothing to
do with this class
okay I'm so you run a browser
you're in. Firefox or Safari or chrome or something
any better and Internet Explorer
don't do it bad idea
at a gay bears is on your computer I'm
02 browser an
either you type in your Google that calmer else maybe you click on a
thing at I'm bookmarks toolbar
it says Google and up pops this thing on your screen
it says you know enter your search query here
um well how did that happen you take it for granted but it's hugely complicated
we're going to be talking about client server stuff
later on it's in the dan actually has this on the right side
I'm but not only is a lot a complicated stuff going on on your computer
but all are complicated stuff is going on Google's computers on which there are
a lot
and many many different computers in between so you know
I'm if you do it on campus I
their other computers on campus at berkeley whose job it is
to forward your message from the computer on your desk
on your lap to the outside world
and then I'm we get our
internet from used to be spread the one point might be anyway
let's say it's Brett their computers have to figure out where Google is
try and that's actually a little tricky cuz Google's everywhere
I'm but so there's all this complicated handshaking going on
and all you see is this career pops up in you type something in
are and then it does the search
and you get results more or less instantly right think about how amazing
that is
arm and making that work is layers and layers and layers about traction okay
so thats abstraction in computer programming
on okay so let me tell you
a little bit about BYOB to because that's the silly into the story about
I'm in scratch you can take
a bunch of commands that scratch knows how to do and soda
cook them together there they're kinda cute they're shaped like Lego bricks
you're supposed to think if it is snapping Lego bricks together
I'm sorry they are Birmingham and you can say do this
and does the first one is echoing other one and so on which you can't do
in scratch is take that sequence if things and give it a name
to make it a new block
they will appear in the menu so that you can use it
to build other blacks and that abstraction right instead of
talking about the little low level things so like
I'm move so many steps in turn so many degrees is stated that
you make it so that you can talk about square right that's a kind of
which you can't do in scratch I'm buchanan BYOB the name BYOB actually
does not stand for what you think it does
it stands for build your own blocks and the main thing that lets you do is
add blocks to the scratch menu
I'm so huge missing feature
I they're actually gonna put it in scratch
in version 2.0 which is coming out someday
I'm but it's not clear that they're gonna put it in full generality
and really decided yet how they gonna do it um that basic
enabling technology com lets you do something called recursion there
among the big ideas in this class
two of them really are about
how you write a computer program the others are bad you know social things
or what computers are good for kinds of things number two in armor
are about programming in the first one is called recursion I'm
which you learn about later a man im gonna tell you it means right now I'm
but recursion and being able to build your own block is the enabling
technology for that
and the other big idea they were gonna talk about
is I'm russia has two names to aspect to the same thing higher-order functions
and procedure as data
and the enabling technology for that is being able to take
a block that you created her black that came with structure whatever
and instead of putting it a program
put in a data structure so make it
use it the way we use a number or string of characters or something like that
make it data and procedures as date is the other big
on programming idea that's in BYOB thats not a scratch
om and that you're going to be learning about in lecture as well as in lap
okay we have 12 minutes
now you can have stretching your computer you can have beer I being your
they're both Reserve Corps I'm track
and I up
up yep
aka up okay so fine from the course of age
get there I'm about a
I'm the word of thanks to other person who
actually did all the programming worker making BYOB
I'm his name is yen's manic I'm he's not here he lives in Germany
is a lawyer have all things on
BRB is kinda his spare time happy and
he's done amazing is at work or
I've done a lot of design and documentation and stuff but
he did all the actual programming so banks Jens questions
yeah you next yes
I'm the prerequisite for 61 a
is knowing how to program a recursive function as a recursion the first to
those big ideas
about programming I mentioned is the key idea that you need for 61 area
yes a
mean making making moving it okay you had the quest yes
the answer is yes how many how many vacant
chairs do we have in this reality 23 456
89 yeah are you guys would actually of it and chairs so next time
I mean it's not worth it right now but next time I'm
it would be really good at people who come early no
I know I was like to sit by the aisle to
it's a pain in the neck so yeah
there's yeah there's cs3 s which is a self-paced version of the old
class still exists I'm their mind they were teaching this class for the first
our plan is that this class will
totally prepare you for 61 as well as 3s whit I'm
3s has a slight edge
in that the programming language that they use
is scheme which is the same language 61a is I'm
but our idea at berkeley
is that after the first time learning a new programming language is not a big
so you know at the end we'll do some
talking about scheme a little bit but I'm but
essentially what we've done with BYOB
on because all the ideas really came from scheme odin is taken scheme in
disguise it
a scratch I'm see really gonna see the same ideas
and discuss would be more fun
because we talk about all that other stuff too and because
danas you've seen up
by the way danza PowerPoint guy a PowerPoint
I'm so when he is up you'll see all kindsa pictures and everything
I'm when I'm lecturing either are they just like this
or Adobe I'm typing it BYOB to show you
you know how a week earlier or something there
a power dang can tell you why I have spare point a PowerPoint because
it kinda makes you always say the same thing and not pay any attention to your
and you talk too fast you doing PowerPoint
down they are in my
in my class social implications have computers one of the things we read is
I'm a New Yorker article there was an interview
but the guy who invented PowerPoint about how terrible it is
because he thinks it's terrible to so they are other questions
yes math when there's a coal requisite for sixty one day
I'm yes see you really are supposed to do that
are you mad hatter hater
your now I'll great when you wanna take oh i should say I'm sorry
this something I should say I'm I'm in can I race this
okay in ordinary non-computer science vocabulary
when people talk about something as being abstract
they mean to removed from common experience
the opposite that is concrete something you can actually look at
so in ordinary language people would mostly say
up things like this are concrete
you can't C atoms are protons are quarks
those are abstract and the big pieces abstract also
so concrete is kinda in the middle that's normal usage in language
that's not computer sciences in July
in computer science we mean what's built in terms of what
so the higher up you are on this chart
the more abstract in the lower than you are the more concrete so concrete
his quirks there's a kind of the fundamental building blocks
and then as a lair abstraction and you
put quarks together in certain ways we get protons and neutrons electrons
you put those together in certain ways and you get Adams and molecules
and then you get materials and then you get
little parts you combine the parts store
and then you get big functional units and then you get even bigger functional
units are
okay so we talk about abstraction it doesn't mean
far removed from your experience
it means built in terms about this
aka sir
try not to get confused by that yet well
a richer up you can yeah I mean you know
lingo below quarks you know they're the string things maybe
or something I'm
I below I'm not a physicist but I believe the current state of things
is they know that corks can't be the bottom but they don't know exactly for
what comes next I'm and yeah we can take you know budgets have cars and make a
road elements our
okay I'm one more question
early radio right welcome to the cow it one question yes
is the course
can it be take can it be taken makes major
yes absolutely I'm if
mostly X majors won't need it because you learn to program a nice person yes
is there a lotta madness cars now
matter of