{"id":18,"date":"2009-04-26T18:12:37","date_gmt":"2009-04-27T01:12:37","guid":{"rendered":"https:\/\/blog.alienoverlord.com\/?p=18"},"modified":"2009-04-26T18:12:55","modified_gmt":"2009-04-27T01:12:55","slug":"encoding","status":"publish","type":"post","link":"https:\/\/blog.alienoverlord.com\/?p=18","title":{"rendered":"encoding"},"content":{"rendered":"<p>I have not written anything in a while. \u00c2\u00a0Too busy I suppose.<\/p>\n<p>In those two sentences are encoded all sorts of information. \u00c2\u00a0We as humans understand each other through words, through sounds, through our own experiences, shared or otherwise. \u00c2\u00a0So much information is <em>encoded <\/em>in our various forms of communication &#8212; it&#8217;s actually an incredible form of compression (probably lossy!) \u00c2\u00a0A picture is worth a thousand words, but words can represent pictures, smells, feelings, etc. too.<\/p>\n<p>As a programmer, I deal with encoding all the time. \u00c2\u00a0Some forms are implicit &#8212; such as a UI element that initiates an action. \u00c2\u00a0The user knows \u00c2\u00a0(if I&#8217;ve done my job well) that clicking a button called &#8220;Start&#8221; will do something in the context of the application. \u00c2\u00a0Other forms are more explicit &#8212; such as using bit fields in a struct to encode info about a network request. \u00c2\u00a0But there are layers and layers of encoding going on &#8212; it&#8217;s one of the fundamental features of how computers work, and indeed how we work as humans.<\/p>\n<p>This came up yesterday as my son (he&#8217;s 6) and I were taking apart an old mouse. \u00c2\u00a0He&#8217;s been watching Make TV video podcasts lately, as he&#8217;s fascinated by how things work. \u00c2\u00a0In one recent video, someone takes apart a mouse to get at the &#8220;rotary encoder&#8221; in the scroll wheel mechanism. \u00c2\u00a0We found an old IBM mouse from @1990 that has the roller ball inside (as opposed to the newer laser mice). \u00c2\u00a0The way these worked was pretty cool &#8212; there&#8217;s an LED facing a photosensor with a small wheel in between the two. The wheel contains a series of small slits around the circumference, and this is turned when the ball rolls. \u00c2\u00a0This lets the light go through at intervals as the ball rolls. \u00c2\u00a0There are two of these, one for the Y axis, one for the Y. \u00c2\u00a0Here, let me <em>encode<\/em> this in a link, which should take you to a picture of what I&#8217;m babbling about:<\/p>\n<p>http:\/\/en.wikipedia.org\/wiki\/File:Basic-Rotary.jpg<\/p>\n<p>So we were trying to figure this out and if we could use it for something else, and I used the word &#8220;decode&#8221;, which prompted him to ask &#8220;what is a decoder?&#8221;. \u00c2\u00a0 \u00c2\u00a0So we talked about morse code, and how letters encode sounds, and morse code encodes letters, and so on. Something like this:<\/p>\n<p>Say I wanted to send a secret message to someone, and only we knew Morse Code (ha!). \u00c2\u00a0I might wish to say:<\/p>\n<p>&#8220;Hello&#8221;<\/p>\n<p>Which translated into Morse Code would be:<\/p>\n<p>. . . . \u00c2\u00a0 . \u00c2\u00a0 . _ . . \u00c2\u00a0 . _ . . \u00c2\u00a0 _ _ _<\/p>\n<p>These dots and dashes are then encoded in sounds &#8212; short blips for dots, longer beeps for dashes. Specific amounts of space\/silence to indicate letter and word boundaries.<\/p>\n<p>The receiver of this encoded message would want to <em>decode<\/em> it, resulting in the message &#8220;Hello&#8221;. He&#8217;d know the code which would obviously enable him to do so.<\/p>\n<p>However, what if &#8220;Hello&#8221; was code for &#8220;Begin the revolution&#8221;? \u00c2\u00a0More encoding. \u00c2\u00a0And on and on it goes.<\/p>\n<p>This probably gets a little tedious, but it did get me thinking about machines and the human system. \u00c2\u00a0Take for example music. \u00c2\u00a0As a musician, I suppose I&#8217;m able to encode feelings and ideas into a musical form (if I&#8217;m doing it well, that is). \u00c2\u00a0Some ideas are probably easier to encode &#8212; such as anger or sillyness. \u00c2\u00a0Others are more complicated.<\/p>\n<p>So back to work&#8230; I&#8217;ve been working on a framework for <strong>easily<\/strong> transmitting data (generally images, video or sound files) and metadata about those media. \u00c2\u00a0Something that hides all the tricky stuff. \u00c2\u00a0The previously mentioned bitfields are part of a message header that users of this framework can use to specify what kind of message is being sent, request, reply, error, etc. \u00c2\u00a0Encoding this in a\u00c2\u00a0bit field\u00c2\u00a0makes it small, so the header can be transmitted quickly over potentially slow wireless networks. \u00c2\u00a0Basic stuff really. \u00c2\u00a0Another part of this is authentication and security. \u00c2\u00a0Security and encryption gets at the very soul of encoding (or at least it&#8217;s evil conscience!) &#8212; it gets quite complicated. \u00c2\u00a0A message contains a header and optionally a payload (e.g. it&#8217;s data). \u00c2\u00a0That payload may have metadata as well as some media, which in turn may be compressed or not, and so on. \u00c2\u00a0Then there&#8217;s the structure of the framework itself &#8212; there are classes for a &#8216;server object&#8217; and a &#8216;client object&#8217;, a &#8216;message&#8217; and a &#8216;message hub&#8217;. \u00c2\u00a0Part of the point of object-oriented programming is to encapsulate functionality into an object so that as humans we can deal with the inherent complexity in easier to grok pieces (objects). \u00c2\u00a0Without all this encoding, it would be a big mess.<\/p>\n<p>Conclusion? \u00c2\u00a0Errr&#8230; uh&#8230; I guess we&#8217;re complicated entities in a complicated system and capable of great beauty or great ugliness, or infinite variations thereof?<\/p>\n<p>I guess that&#8217;s enough for now.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have not written anything in a while. \u00c2\u00a0Too busy I suppose. In those two sentences are encoded all sorts of information. \u00c2\u00a0We as humans understand each other through words, through sounds, through our own experiences, shared or otherwise. \u00c2\u00a0So much information is encoded in our various forms of communication &#8212; it&#8217;s actually an incredible [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,7,6],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=\/wp\/v2\/posts\/18"}],"collection":[{"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18"}],"version-history":[{"count":1,"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":19,"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=\/wp\/v2\/posts\/18\/revisions\/19"}],"wp:attachment":[{"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alienoverlord.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}