Monday, February 08, 2010

Linking data in XML and HATEOAS

To continue in that vein, we start with Tim Berners-Lee. Tim Berners-Lee was talking at TED about linked data as being the next step for the web. He's thought deeply on the formats and protocols of the web, and I think he's right about the overall benefits of linking data. If you could link data together, you can easily join different datasets together simply by traversing it.

However, for a programmer implementing a web app, there's no immediate benefit of linking data. It doesn't show up in web browsers, usable semantic browsers are pretty much non-existent (maybe Disco), and none of the web frameworks makes it easy to link data. The fact that none of the maintainers of Rails, Django, etc do is indicative of the high cost to benefit ratio of doing so.

Taking a look at the Linked Data homepage, I felt the barrier was pretty high and heavyweight just to link data together. You'd not only have to learn RDF, but also OWL and SPARQL. And a simple search for RDF projects in github only reveals one project (reddy) with any attention from other devs with 3 forks and 39 watchers. It seems overcomplicated to have a separate RDF file linking data together.

While having ontologies is great, I don't think it's a low hanging fruit. I was searching about REST when I tripped on a concept called HATEOAS. It is a design constraint of REST that gets overlooked as using hypermedia as the engine of application state.

Given that idea, here's the punchline: Why don't we link data directly from within the XML data? Instead of messing around with RDFs, why can't we link in XML? Here's part of the data returned by the Sunlight Foundation's API when I query for a single legislator.



Notice that some of the fields are pointer to URLs, but for the twitter_id, it only gives the twitter id. With the state, it only states "HI" for Hawaii. Why not point twitter attribute at the URL of the twitter API? Instead of stating the state, why not link it to geonames.org? It might look something like this:



This way, you can traverse from XML document to XML document. So if you needed to look up further information about the attribute "state" with value "HI", you can do so by following the link to http://ws.geonames.org/search?name_equals=hawaii&country=US. So in your application, you can traverse it as if it was composed data. Now, when you execute @legislator.state, you don't only get back "HI", but you get back another set of data with attributes returned from geonames for the state of Hawaii.

You don't need to link to just other web services, but you can link back to your own API. Instead of having just the district number our legislator works in, Sunlight should link back to its own API for districts. When you do this, you push the burden of maintaining application state to the client. The state of the client is merely the XML document it last requested.

And more importantly, if different methods in your API need a specific order to be called, no longer will you need to state this in the documentation of your API. The only allowable methods to be called are the only href links in the XML document. It's best described by an example quoted by subbu:

There are three pages in a UI. The first page has a link to go to the second page. The second page has a link to go to the previous page as well as the third page. The third has a link to the second page and another link to the first page.

A client starts from the first page, and then through the link on that page, goes to the second page. The fact that this page has one link to the first page and another to the third page implies that the current state of the application (i.e. the interactions) is that "the client is viewing the second page". That is what it means by hypermedia as the engine of application state. It does not necessarily mean serializing application state, such as "<page>2</page>" into representations.

Right now, our REST APIs are returning XML with just IDs. It's up to you to figure out what they're pointing to. It's like if we had webpages that just said "next page" and expect you to know which URL to go to and just change it in the address bar of your browser

Obviously, I'm not the first to think about this. Tim Bray has talked about linking plain ole XML, and others have mentioned the xlink for xml, but nowhere in my searches did there seem to be any explicit connection with Tim-Berners Lee's Linked data or with finding a consistent way to access REST APIs. None of the XML data returned by REST APIs had links to them, and none of the API wrapper libraries I've used tried to traverse to a different REST API URI using links in the XML documents.

It seems like a really simple solution to linking data and it's way overlooked. When it all came together for me, it seemed like something people would be excited about, but doing a search on google, google trends, and google adsense keywords, no one seems to be talking about it.

Anyone know why XLink was abandoned, or why linked data doesn't follow this concept?

Posted via email from The Web and all that Jazz

Friday, February 05, 2010

If you forked technomancy's emacs-starter-kit, upgrade nXhtml

UGH.  I recently forked technomancy's emacs-starter-kit, and all was well, until I started editing erb files.  After a while, it would stutter (hang and then go), eating up 94% cpu while editing erb files.  I didn't know exactly what was causing it.  Emacs kept complaining about "MU new post-command chunk" in the *Message* buffer, and something about "not safe forward word".  It took a whole night's worth of digging to figure this out.  
Solution: make sure you upgrade to the latest version of nXhtml (2.05-091202), if you forked technomancy's emacs-starter-kit commit 452c395556e0aac213b0d7d1653f2673554a4b73 or earlier
Sometimes, I hate emacs.

Posted via web from The Web and all that Jazz

Tuesday, February 02, 2010

I want to use SASS, but not HAML.

The title of the post is more-or-less a verbatim quote from a coworker, as well as from an unrelated colleague of mine from a previous job. I was asked that question and, to be honest, I was a little thrown both times. I didn’t actually know why I use HAML.  I guess I’d never really considered it much after I started doing everything with it.  It just seemed better and more fun.

Oddly enough, I want to do Sass, but not Haml.  Html isn't too hard to begin with, and I guess it's never bugged me.  

What I do dislike about Haml is the indentation on a larger piece of code.  When I want to shift elements around, suddenly, I'm not sure which level of indentation to put it, let alone make sure all the sub-levels are indented correctly as well.  haml-mode in emacs didn't seem to help much.

This means either two things:

  1. web markup should be more shallow and I'm doing it wrong.  Perhaps with rails helpers and partials I can compress it more to keep myself DRY.
  2. The very Nature of web markup is a deeply nested tree, and haml's indentation's not a right fit for it.  This seems more likely, though again, it depends on the design of the page.  If a page is designed to be with heterogenously abundant page elements, then this is true.

I've yet to decide on either.  Perhaps I'll give Haml another shot.

CSS, on the other hand, has a fairly shallow structure.  In fact, it doesn't have nested structures at all, and you have to re-declare parent tags.  This lends itself to really long files that I can't keep track of.  I've often wished for color variables too.  SASS indentation is good here because it gives you a way to group your css together in a more compact way with hierarchy.

Hence, HTML is too deep for whitespace indentation, and hence in my opinion, not a good fit for HAML.  And CSS is too shallow, and hence perfect for SASS.

So it's not that I don't want to learn HAML because it's something-new, but because it doesn't seem to fit a need I have for the markup I'm working with.  SASS, on the other hand, solves a pain problem I've had with CSS.  

 

Posted via web from The Web and all that Jazz

Friday, January 29, 2010

How to add paths to your emacs shell

Actually this is probably because start-process can't find your git
executable. Try doing something like this in your Emacs configuration
(adjust the path if needed):

(setenv "PATH" (concat (getenv "PATH") ":/usr/local/git/bin"))
(setq exec-path (append exec-path '("/usr/local/git/bin")))

If you're trying to use magit in emacs, and you can't figure out why it's not recognizing your git repos, it's probably because it can't find git. And it can't find git, because it's not in the path.

Just set the path, as it's show above, and add your own directory, wherever git is being held. If you're on a mac, you can add /opt/local/bin for the rest of your utilities.

Posted via web from The Web and all that Jazz

Erlang mode on Emacs

Although there are a few other editors for Erlang, I prefer to use Emacs for Erlang and its the only major reason I use Emacs for. Erlang now has an eclipse plugin too, called Erlide.

Erlang comes with the emacs mode as part of its standard distribution, so you only need to customize your emacs settings to use the erlang mode. Once you have Emacs installed (I have Carbon Emacs on my Mac OSX), create a .emacs file in your home directory (or use the one that you already have).

$ vi ~/.emacs

Then insert the following lines of Lisp code into your .emacs file.

;Erlang Mode  (setq load-path (cons  "/usr/local/lib/erlang/lib/tools-2.6.1/emacs" load-path))  (setq erlang-root-dir "/usr/local/lib/erlang")  (setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path))  (require 'erlang-start)

/usr/local/lib is where my Erlang is installed, and /usr/local/lib/erlang/lib/tools-2.6.1/emacs is the location where erlang.el and erlang-start.el files are, which actually define and initialize the Emacs Erlang-mode.

Update the path and version of the tools in the above code as per your installation, and enjoy the amazing features - including the Erlang shell right from Emacs.

Just something to remind me.

Posted via web from The Web and all that Jazz

Thursday, January 28, 2010

A REST service description language not a good idea

There's a lot of public data out there, and more being added everyday.  However, they're added in all sorts of oddball formats, like HTML in crazy formatted tables, CSV, PDFs, Excel files, etc.  For web services, at least the data format is easier to parse, like XML and JSON through SOAP and REST APIs.  

And there's no uniform way to access and parse all this data.

Even when you just focus on REST APIs, there's no uniform way to access all the APIs.  Right now, if you want to use an API, you need a separate wrapper library for each API.  Even though REST is simple enough that all you need are URIs and HTTP verbs, without documentation or a service description, you don't know what methods are available to you from the service.  Therefore, if you wanted to join data from two different REST APIs in a mashup, you currently need two separate wrapper libraries, then join the data in your application.

Taking a first crack at the problem, you might think that we should have machine-readable descriptions of these web services.  There have been some tries at that.  One is YQL, which treats the web as a database in which you use SQL-like statements to get and join data from REST APIs. 

Another is WADL, a machine-readable description of REST resources--like a WSDL for REST.  The idea is if you have a machine readable description of a resource, you can generate API wrapper code for it.  Then to join data from two different REST APIs wouldn't require two different interfaces. 

These two solutions have the problem of requiring programmers to write an explicit mapping of which service has which URI methods available, along with what parameters they take.  YQL uses a global repository of table mappings in a github repo to convert SQL statements to REST methods.  With WADL, it requires maintainers of the REST API to both update their API, their documentation, and a WADL file.  When the service API changes, the WADL/WSDL could be out of date, unless their web frameworks generates WADLs for them.  To my knowledge, none of the major web frameworks do such a thing.  

There's even a blog post by Joe Gregorio about whether we need WADL.  He says no.  I think I agree, though what he proposes is to have a limited number of service descriptors, the same way that we have a limited mime-types.  That way, when we see a web service resource description type, we expect it describe a REST API with certain methods, the same way we expect an image/png or text/html file to have certain properties and operators.  He may have something, but if descriptions of REST APIs are not the way to go, what's an alternative?

Posted via email from The Web and all that Jazz

Tuesday, January 26, 2010

A simple guessing game in Erlang

Recently, I found out about a book called Inventing your own computer games with Python.  In it, there's a "Guess the Number" game.  Man, it takes me back to when I was toying around in GW-Basic.  I've been meaning to do Erlang again, and was going through Learn You Some Erlang for Greater Good, when I wanted a simple project to practice some Erlangian.  I had forgotten a lot of the basics, and this was a good way to get back into it.  Not a very fun game to play--maybe I'll try Bagels later on.  For now, it's just "Guess the Number".





What's interesting is that basic process and components of the game map very well to each decision that must be made, so you don't need to use an if statement at all.  All you need are the guards for each function.  Also, the entire game state needs to be carried in the parameters of each function.  I can see how that can be a pain for more complex games.

Posted via email from The Web and all that Jazz

Lorem ipsum for images in French Maid

Just yesterday, I saw a post on HN about the lorem ipsum for images, and I thought, "Hey kinda neat, but it shouldn't really require a server. All you really need is a place holder." So I decided to add it to French Maid, and it didn't take long...considering I was watching TV at the same time.

French Maid is just a small little javascript wrapper library that injects common behaviors into web pages using unobtrusive javascript, based on jQuery. All you ever need to do is set the attributes of html to standard html5 or microformats, and it'll give you some behavior that makes sense. I started this because while working in Sinatra and Django, there wasn't built in javascript behaviors for templates like in Rails. Turns out that was a good thing, but a bit annoying, so I wrote something to help me out.

Lorem ipsum for images is the only non-standard in there right now. When you're laying out a page, put:



And you'll get an image placeholder 200 px wide by 100 px height. There's only a few options:



This is pretty useful for having placeholder icons. I usually spend lots of time picking icons when I'm laying out a page, when I really shouldn't be.

I haven't yet made a homepage for French Maid. Figured I would when it's more mature, but hey, if you're not embarrassed when you release something, it's too late, right? So while I haven't gotten around to implementing all the microformat and html5 specifications, it's been useful so far, especially for standard pattern AJAX calls. The screenshot is from the test/example/documentation page in the project. You need Sinatra gem to run it. Then just fire up the server by running the test file, then navigate to localhost:4567 and start clicking around.

Have fun, and if you find it useful, lemme know. It'll be motivation to get a homepage up for it.

Monday, January 25, 2010

Getting a kid started with programming

I recently had a kid that wanted to program as well. He's about 12. Wanted to program games, but didn't get very far in a directX book.

I had a couple choices for him, due to some requirements: 

  • Something easy to install or didn't have lots of things to install 
  • Something with a all-in-one gaming library 
  • Something with some sort of community around it. 4) It'd be nice if there was a book for it.

So with those there, there was: 

Ruby and HacketyHack. http://hacketyhack.heroku.com/ It also has a app framework called shoes that you can use to build both games and apps. However, since _why left, all this requires a lot of hand hold to set up.

Lua and Love. http://love2d.org/ Lua is an easy language to pick up as it's pretty minimal, and love's 2D engine is pretty fantastic. I've used it before and it's pretty easy to get started with, and plenty of examples, as well as a vibrant community.

Python and Pygame. http://www.pygame.org/news.html Pygame has all of the above, and for me, the final winner, since there was a book that walks the kid along from basic text games to the graphics part. http://inventwithpython.com/ 

Just in case there are those of you out there that are looking for things to help out your little programmer.  Are there others you'd recommend?

Posted via email from The Web and all that Jazz

Wednesday, January 13, 2010

Some of the best people are the ones you never hear about

“The superior doctor prevents sickness; The mediocre doctor attends to impending sickness; The inferior doctor treats actual sickness;” - Chinese Proverb

I remember the story was actually a little bit longer.  Since I can't find it on the web, I'll repeat it via oral tradition in an imperfect form:

As the story goes, a famous doctor was called a house to cure a sick wife/kid.  When he cured the disease, the husband/dad remarks what a great doctor he was.  The doctor looks at him and retorted, "Not at all."  When the husband asked why he wasn't a great doctor, since he was able to cure all sorts of diseases.  The doctor explained, "I have an elder brother who's a much better doctor.  He attends to impending sickness, but he's less famous because people don't call a doctor until they're sick.  And my eldest brother is the best doctor of all, but no one's heard of him, because he prevents sickness from happening in the first place."

Ever since I started trying to be a better engineer/programmer/designer/architect, I've looked for good hackers to emulate.  Surely someone else has figured out things that I haven't yet.  It's good to learn from them.  But where do you find them?

In the last couple of years, I've found that some of the best people are the ones you've never even heard of, often better than the self-promoting blowhards out there might seem like they're really good, but in fact, aren't that great.  Not that some famous programmers aren't great.  Just that there are ones you've never heard of that are really good too.

Just like a doctor that doesn't get famous for preventing sickness, a hacker doesn't get credit for removing code.

The fastest code is the one you don't run, the easiest code to understand is the one that isn't written.  As in graphic design, sometimes what's great about a solution is not what's there, but all the stuff that's not.  

This should be of no surprise to people working for a while with different types of people.  But it's hard to keep in mind, and makes hiring just that much harder.  Some of the best people aren't ones that wrote something, but knew what not to write, and attack the problem from another direction instead.

Posted via email from The Web and all that Jazz

The bumps on the road to javascript

 

I'll say it.  

The Rhino Book is a bad way to learn Javascript.  It often gets recommended as the de facto book on javascript, but it's too much heft that doesn't point out what really separates Javascript from other languages.

 

When I first heard about javascript, it was back in the 90's, when most examples for it was to put snowflakes on the screen and trails of kittens that followed your cursor.  In the last 4 years; AJAX, jQuery, V8 javascript engine, node.js, server-side js with Rhino all contributed to javascript's growth.  I'm picking javascript for client-side implementation because of its ubiquity, flash doesn't have a future(1), and its ability to teach me something about programming.

I haven't brought some of the newer js books like the good parts, or ninja, but I was able to spend time going over John Resig's Advanced Javascript tutorial.  Resig is as much of a force for good for Javascript as _why was for Ruby, by being able to teach others.  I'd recommend going over that tutorial, as it cleared some bumps along the way I had about understanding basic parts of the language.  

Here's some of them.  Maybe it'll help someone else out.  I'll keep 'em short.

Scope

Javascript scope had always tripped me up.  In languages like C, Java, and Ruby, scope was usually pretty apparent, because you can see it in the code, sectioned off by block delimiters.  Variables can see out, but they can't see in.  In javascript, it's the same, except this (or in other languages, self), changes when you call a function.  This was especially frustrating in cases where I was using map functions in javascript.  This would change inside of the anonymous block passed to map.   

 

 

There are already a number of scope tutorials on the web. I won't repeat what they say, but what helped was understanding that This changes depending on who calls the function. Scope and context of this can be controlled on a function by function basis

Prototype-based Object Orientation

Reading the Rhino book's Prototype based inheritance was confusing.  Instead, it was easier to think of javascript's object model was more like how CSS worked.  You have an object that served as a template (or aptly named, prototype), and if you need to override any properties, you do so.  Anything missing is looked up in the prototype.  I don't know why this was that hard.  It must have just been the name.  I thought it was something completely different.

Javascript has very few core elements

That you can use to build what you need.  At the core, there are functions, arrays, and objects.  All three of them have properties, thought of as 'slots' you can put variables, functions, arrays, and objects in.  What makes it more like lisp is that you can treat functions as data you can pass around, as first class citizens.  Javascript's core minimalism really reminds me of Lua.  I much prefer Lua, and would have preferred it to be the lingua franca of the web, but Javascript is good enough for now.

That said...

Naked javascript really sucks.  Some mix of jQuery, Underscore, Functional, Prototype, MochiKit, or Closure should really be parts of the core language.  Without each, map, and reduce, I find having to write for loops to be a pain.  If people from multiple libraries are implementing the same basic things, that's a good indication it's a weakness of the language.  I'll use for loops when I need to optimize something later.

Javascript is still missing some features from other languages, like tail-call optimization.  It's like it doesn't want to admit it's a functional language (albeit unpure).  It also has no method_missing call.  Firefox has implemented a __noSuchMethod__ call, but it's non-standard.  I haven't found a way to replicate it with its current features yet either.

I'm sure there are others, but I haven't gone deep enough into the rabbit hole yet.  I still find some things about javascript pretty grating, but the platform it sits on--the browser and the web--makes it pretty exciting.  

(1) When I say doesn't have a future, it'll still be around, but like the way radio is still around as a medium when TV and internet came around.

 

Posted via web from The Web and all that Jazz

Sunday, January 03, 2010

The hard part about unit testing

There are lots of things for people to argue over on HN.  When it comes to unit tests, I think that you should do it, judiciously, of course.  

I don't write unit tests when I'm sketching a program.  Or when I'm just playing and when I'm not sure if this is exactly what I want.  Sometimes, this is the case when I'm doing a feature as well, because chances are, the direction of the startup might change, so the tests and features that I write might not make the next revision.  

Along with that is the discipline to shape up and write the unit tests when you know that you're going to be stuck with the program and feature for a while.  It's far too easy to fall into the trap of not cleaning up a sketch.  I believe this is especially true when you're working on a code base with other programmers.  When you write a program, you're not just writing something for a computer to execute--you're writing something for your fellow programmers to understand.  Unit tests definitely help with that.  

The important thing is to know what your goal is, and write accordingly.  Just as in drawing and writing, you can draft and sketch, and then start checking the elements of style when you know this is exactly what you want.  

This morning, I read a Perler's attempt at making TDD like an addictive game.  It's a neat idea, as it keeps him in the "game" and has him bouncing back and forth between setting goals and meeting goals.  Looking at this workflow chart, I thought about how I did things and whether this worked for me.  

For the most part, I've stuck to the basic test framework Test::Unit, and it's worked pretty well for me as long as I was disciplined about it--use descriptive names, test one thing, keep it simple, etc.  But currently, as the codebase got larger and larger, I found that I hated doing tests, and that's lead to some minor bugs slipping into production.  Why was that?

Reading tests are a pain.  There is often too many details when doing assertions, and when you're just skimming code, they all look the same.  Tests are also rather repetitious.  Sometimes, you have a scenario that you want to test with multiple parameters, like access for different users for different methods.  You can either use cut and paste, which ends up with a lot of boilerplate.  Thoughtbot's Shoulda alleviates this somewhat by allowing you to have nested conditions.  Cucumber has a test matrix, but the whole system is usually more cumbersome than I need.  

But really, the most difficult part about writing tests is the setup.  Setting up the conditions of the program so that you can run the test.  Writing fixtures is a pain.

And reading this post about OOL, I realized that it held parallels in testing with machinist blueprints of activerecord objects.  

Joe Armstrong (Erlang) once said "The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle."

When you have a banana class to test, and you'd like nothing better to instantiate it.  But, in order to do so, you need to tie it to a gorilla, which in turn assumes that it's living in a jungle.  This is what's meant by coupling objects to each other.  It not only muddles up your design, but also makes testing way harder.  When you're writing constructors, don't rely on having other objects passed in as much as you can.  The only exception is when you're moving up a layer in abstraction.  

The less that you have objects that need each other to get started, the better.  Have defaults that make sense that the client object can adjust later.  To avoid having to create special objects, and use them as parameters, avoid having data classes and use hashes and arrays instead.  Just as Unix commands communicate by text, your class instantiations should communicate by arrays, values, and hashes.  Every object would know how to read them without instantiating and passing in another class object.  

I'm not exactly sure how to solve this testing problem.  While you can design around it with the coupling of your code, I'm sure it won't get everything.  Pure functional programming languages say they don't have this problem, but I don't have enough experience with one to know for sure.  For now, I'll architect my way out of it, but there should be a better way.

Posted via email from The Web and all that Jazz

Thursday, December 31, 2009

Bubbles and triangles

Lately, I've been looking at more information visualizations, and it's not been said enough that simple geometry is often ignored.

Often times, I'll see visualizations like this, where bubbles are employed to visually compare different records. It seems likely that people judge and compare difference in size by area. However, the artist/designer makes the mistake of mapping the data to the radius instead. This doesn't work for circles because of your old 4th grade math, stating that A = pi * r^2, where the area doesn't increase linearly as a proportion of the radius.

For the record, it's done correctly here in the visualization above, as far as I can tell.

Here, the designer decided to use triangles. If he mapped the data to the height of the triangles, that's fine, because for triangles, A = 0.5 * b * h, and hence area varies in linear proportion to height.

However, looking at Hungary, the red triangle doesn't seem quite a quarter of the black triangle.

Beyond that, for these two examples, I really see no reason to use circles or triangles. People are able to judge spatial difference much more easily, as opposed to size. It would have been far more effective to use bar charts and rectangles instead of shapes like triangles and circles. In my opinion, you only use that if the spatial x and y axis are already being used to convey other information already.

Posted via web from The Web and all that Jazz

Wednesday, December 23, 2009

Practice coding faster

map_with_index. Why is there no map_with_index in ruby? Ends up it's because you don't need it. You can simply do this:


Even now, I'm learning things about Ruby. The rabbit hole is deep.

Anyway, a post about learning how to code fast came across my desk. I knew that I wasn't quite as fast as other coders, but I had always thought that I thought deeper on the solution. But I think what he says makes sense. I know that violinists slowly ramp up their speed to a point where they're almost making mistakes, faster than they'd actually play the piece to practice playing it at the correct speed. Same with drawing. The more you practice drawing faster, the better you get at being economic with your strokes. So I figured I'd try the same with programming, since I've never done much of this type of exercise.

I decided to do the first Ruby Quiz, since I was most familiar with Ruby, and I should be able to do it quickly. It took me about three hours, including reading the instructions, going on bathroom breaks, etc. I think I should have been faster, and I noticed where I slowed down. I found myself trying things out in irb a lot because I didn't know the exact behavior of some array and string functions. Also, I spent some time in the beginning pondering how to structure it--should it be a class, or just a collection of functions, or should I extend the classes?

I'm not thrilled about how it's structured, but it works. Well, there's a small bug in there, but I'm going to refrain from fixing it. It'll tack on another 30 mins. The point of the exercise is that I can see what I need to work on. I'll try again next time with the next ruby quiz.



Posted via email from The Web and all that Jazz

Monday, December 21, 2009

On to the new old thing

Ever since I quit my job at the lab 4 years ago to pursue a startup, I'd been fumbling around learning all sorts of things. And though I had determination and persistence, I simply didn't know a lot of things outside of coding. Who wants this? Why would they pay money for it? Where do you find them? How do you change your idea if it doesn't work? Going into it, I knew I didn't know anything and that I'd learn, but I also didn't know what I didn't know.

For the past year and a half, I've been with a startup that went into the YC program. So as much as I wanted to pursue my own ideas, I was advised to join up and watch other people and learn. And learn a lot I did. What to do, and what not to do. And just seeing founder from other startups helped. What their thought processes and attitudes about their line was work was. Meeting role models are easier than reading about them, I guess.

And yet, while I've been learning about things outside of code, I felt like I've been sailing downwind when it came to technical things. Sure, I'd mess around with chickens flocking (which embarrassingly, I haven't gotten back to), but for the most part, I was consumed by work. Getting the tickets done and getting better at communicating with other team members.

However, much of my creativity was sapped. It was hard to fire up the editor afterwards and explore something new. I have a whole list of things I wanted to dive into more deeply. Haskell's type system. Erlang servers. Spatial trees for Frock. Arc language. Potion language. Prof Strang's Linear Algebra lectures. Visualizations and info graphics. Mobile web apps. 3D printers. And though I've dabbled in all of the above, it's not yet been enough to satiate my cravings.

But I have learned that it's also a lesson in keeping things small and simple at first. Much kudos to those working a full time job and are able to get a side project up and running.

This blog also suffered as a result. I was afraid that the things I was learning outside of code might reveal too much about the internals of the startup I was with, so I just left nothing to chance. I simply fell out of the habit of blogging about what I've learned, and as a result I feel like my writing skills have deteriorated.

But now I've left the startup, moved to Mountain View, and I'm pursuing my own once again. It's not a secret what I'm working on, but I'd just rather talk about it in a separate post. I've also started exploring other technical topics as well, as I hinted in the last post about Potion. I'll start finishing up the backlogged technical posts.

So for those of you that still are subscribed, well, thanks for your faith. I'll be writing more, and I hope you'll be able to learn something from reading this blog as well. Have a great holiday!

Posted via web from The Web and all that Jazz

Saturday, December 19, 2009

Playing with potion

For fun this morning, I cloned _why's potion and started going through the tutorial. After cloning it, I was able to compile it on my mac, and then I tried to run:

"hello world" print

and it seg faulted. Boo. So in case any of you are looking for a work around, this worked:

And looking through the source, I found the about function's easter eggs. Humorous.

   
1 times:
about("_why") print
about("stage fright) print
.

Posted via email from The Web and all that Jazz

Friday, November 13, 2009

jQuery live events can only bind once

I've been doing some more javascript on the side as of late, and I ran into a snag with jQuery.  It was an odd case of live events that didn't seem to be taking hold.  In addition, it only looked like it was happening on Chrome.  As always, it helps to read the docs.
 
Unlike .bind(), only a single event can be bound in each call to the .live() method.

That means that my overlapping live binding were getting overwritten, and that Firefox and Chrome were merely adding the events in different orders.  If it's not apparently in the docs, start looking in the code.  As an aside, I've heard that the JQuery code is a good example of great javascript code.  I don't understand a lot of what I saw.  Well, tip.  Been working on some other things on the side, and will reveal them in due time.

Posted via email from The Web and all that Jazz

Wednesday, November 04, 2009

Tarsnap docs as an example of confusing typography

Because in 1960, the Bureau International des Poids et Mesures decided that the SI prefix G- meant 10^9.

But it means 2^30, really!

No it doesn't. Let's look at some examples:

Just a quick thought. It's pretty basic, but this was the first time I had a front-row seat demonstration of basic design principles and why they're suggested.

You can't really see it in the quotes, but if you follow the link, you'll see that the headings and text are the same size. Not only that, but the spacing between paragraphs is the same between headings and paragraphs.

That confused me and I had thought that the bolded statements was part of the text, and hence it was something the author was saying, rather than as intentioned, something we are readers would be saying as headings of different sections.

We differentiate importance and grouping by weight, size, color, and spacing. It takes a combination of these to discern what we're reading.

Posted via web from The Web and all that Jazz

Thursday, October 29, 2009

You probably don't need an OLAP

It's a "well known" that relational databases are bad at multi-column "slice and dice" calculations.  So when you have data that you'd like to represent as an aggregated trend, it's easy to reach for that OLAP.  Chances are, you don't need it.  Here's an example of something where you want a count of the number of comments from an author by day.

select DATE(created_at) as DateOnly, count(*) 
from comments 
where author_id = 877081418 
group by DateOnly
order by DateOnly

The trick here is the DATE() function provided by various database vendors.  This returns any datetime as simply a date that can be aggregated.  

To be honest, I looked into this way too late and didn't contest the OLAP architectural decision until it was late.  We ended up having the legacy of dragging a big fat OLAP with all its trappings of complicating our architecture.  If you end up with a complex architecture, there's probably a simpler way you're not seeing.  The simpler your setup, the easier it will be for you to hold it all in your head and understand it when things go wrong.  

The only OLAPs we've found to be available was the open source Mondrian and Microsoft's Analysis Services.  To be honest, I found both to be way harder to use than it should have been.  If someone else wants to write another OLAP that's simpler to use without a lot of luggage to blow those two out of the water, the time is nigh.

Posted via email from The Web and all that Jazz

Thursday, October 08, 2009

Scope in JavaScript is just from which door you entered

Put simply, we entered BigComputer via new, so this meant “the new object.” On the other hand, we entered the_question via deep_thought, so while we’re executing that method, this means “whatever deep_thought refers to”. this is not read from the scope chain as other variables are, but instead is reset on a context by context basis.

Javascript's scoping has been one of most confusing things about it, just as Ruby's metaclass and object model is the most confusing things about it. If you're looking to expand the horizon of what you understand about programming languages, it's worth it to figure out javascript scoping.

The paragraph gave a good way to think about it:  this changes based on the object that calls the method.  It only gets confusing when you start passing around functions and using callbacks, which is most of the power of functional programming.

As an example, here, I was using an anonymous function as a callback in the request() method.  But it doesn't work!

So that's just one way to solve it.  If you're using Prototype, you can also try using the bind() method.  jQuery doesn't have an equivalent bind method, as hard as I looked for it at one time.  I was just about to write it myself (as it's not too hard), but according to the a list apart article on Getting out of binding situations in javascript:

jQuery does not provide such a binding facility. The library’s philosophy favors closures over binding and forces users to jump through hoops (that is, manually combine lexical closures and apply or call, much as other libraries do internally) when they actually need to pass along a piece of code referring to “instance members.”

So while I use closures extensively in Ruby, I haven't had to explicitly think about the scope until I was using closures in Javascript.  Huzzah.  Hopefully, it'll prompt you to take a deeper look at Javascript.

Posted via web from The Web and all that Jazz