Ionrock Dot Org

My Web Log

Get You're Feed Readers Ready

The other day I took the plunge and updated my blog with feeds from del.icio.us and my Google Reader shared items. First off, it was really easy to put together. jQuery is a great library that has done an excellent job providing a huge bang for the buck.

What is more important though about this bit of work is my decision not to include the items in my main feed. I thought about it and felt that each feed deserves its own context and resource. I also think it suggests the value of RESTful design. By providing different resources for different contexts, I give you, the reader, the ability to tweak what feeds you want to follow. Likewise, if I had twitter feed (don't hold your breath), I would definitely keep it off of my primary blog because the context is so different.

If you normally view my blogs from a feed reader, please take a minute to visit the actual site and possibly subscribe to my other feeds. In all honesty, I usually post more and they are shorter. Being a rather long winded writer at times, I hoping the brevity is considered a feature. Thanks for reading!

Posted on 2008-07-23 by Eric Larson

Social Networks Adding Social Awkwardness

A friend from my old job sent a friend request to me on Facebook . This was a kind gesture that presented a slightly odd situation. You see, I've never really used Facebook and only have an account because of a one time plan to build a Facebook application. The awkwardness is when a friend does try to give me a friend request. I could go along and accept, but that sends the wrong message, namely that I pay any attention to Facebook. If I ignore it, then I look like I'm a jerk for not accepting the friend request. I can't win for losing!

Fortunately, none of my friends really use Facebook, so it is really not a big deal. When I do get an occasional friend request, it is either spam or a friend of a friend, in which case I go ahead and accept it (if I remember my password of course). While it doesn't really affect me, I could see this sort of "cyber shunning" become more of an issue in the future. Caller ID had a similar affect in that it opened the door for accusations people were screening calls, which in turn made people wonder if the person they called simply was not interested in talking to them. I could see this sort of situation become more stressful with kids, but I also think kids should stay the heck off of social networks. Either way, I'm glad my own social circles and mediums are a bit more tame in terms of expectations. If I don't say hello on IRC or Jabber, it is nothing personal.

Posted on 2008-07-09 by Eric Larson

New CherryPy Release

CherryPy 3.1 was released today! Looking over the new features I'm pretty excited to dive in. The app engine is very interesting. Also, the whole cherryd and scaffolding seems like CherryPy and Paste will continue to overlap and provide two excellent options for working with WSGI apps. Congrats CherryPy Team!

Posted on 2008-06-30 by Eric Larson

Heading to YouGov

I've accepted a position with YouGov and will have my last day at nGenera tomorrow. It has been a short run for me a BSG/nGenera, but honestly, it has really been fun. When I came to nGenera, it was after a failed startup experience (for myself at least) and a whirlwind job search in hopes of finding mortgage money. I was somewhat desperate for a position when I started looking and by the end I had a tough choice accepting competing offers. The whole experience honestly weirded me out a bit when it was all said and done.

I honestly chose BSG because of the people. They had a great team that were a ton of fun. I tacked on a longer commute and a slightly confusing business model in exchange for great friends and a fun work environment. The problem space was also very service oriented, focusing on REST, which has been something of a focus on mine for a while. I felt poised for a great experience. The one hiccup was Ruby . I had previously been getting more and more involved in the Python over the past few years and really enjoyed the language and the community. Coming to Ruby, I hoped I would find a comparable experience in terms of language features and open source community. While there were definitely strong points, I found myself frustrated with the environment. The interpreter constantly seemed flawed. I was consistently warned to avoid threads and strings. There were parts of Rails I disagreed with. Generally, Ruby, while interesting at times and much better than Java or C#, just wasn't Python. I found myself avoiding Ruby where I could in favor of Javascript. I thought to myself, if I'm going to be frustrated with Ruby, I'll give a go at becoming a Javascript expert instead.

This actually worked out rather well because no one else really wanted to work with Javascript as extensively. At the same time though, I was contacted about applying for a job at YouGov. Seeing as it was a Python shop, had a few friends of friends and had a history of challenging web scale problems , I gave it a go. It was a challenging interview process and I felt I learned a ton by simply going through it. I was made an offer and decided that it seemed like a great opportunity.

While I'm really sad to be leaving my friends on the Apps Team at nGenera, I think I've made the best decision for me professionally. When it gets down to it, my heart is in the Python community and while I have a ton of fun at the office, the majority of my time is spent in my editor. I'm going to miss the laughs and hanging out drinking beer in the office, but the Ruby I don't mind leaving behind.

This whole process (starting with my startup experience) has been really interesting for me. I'm not the kind of guy to change jobs and usually I do everything I can to stay at a job. I'm glad I took some time to experiment, but I'm definitely ready to settle down for a while. I'm also ready to get deep into Python (and PyCon ) and be a more productive part of the community.

Thanks so much to my team at nGenera for the good times and great experience. I'll see you at the bar!

Posted on 2008-06-19 by Eric Larson

If a one liner is long...

Today I came across a rather large line of Ruby code and it made me think. The line was primarily a long string, but I have seen many lines that are really long doing a set of chained operations. So, the question is, if a one liner is exceptionally long, is it still considered a one liner? The term "one liner" refers to one line of code doing an extreme amount of work. Things like Golf are good examples of writing one liners.

Personally, I don't think it can still be considered a one liner. But I'm also pretty rigorous at keeping my lines in the 80 column category, so I'm rather biased. With that said, I would also argue that placing everything on one line doesn't really make it clever, which a one liner should generally be. The idea is that you've expressed an operation in an extremely concise way, that in most cases, uses the features of the language. So, my answer is no. What about you?

Posted on 2008-04-22 by Eric Larson

Ruby Priority Queue

Once again Uche brought an interesting bit of computer science to my attention in BC. He started using the Python heapq module to help speed up an index in BC. I had never used the module before and wasn't exactly clear at first glance how it worked. I took some time last night to implement something similar in Ruby to help get a better understanding. I ran some exceptionally unscientific tests to see if it was incredibly slow and as far as I could tell, it seemed quick enough to use. If anyone is interested in grabbing a copy you can download here . I don't plan on making any updates or maintaining something serious here, but if others have suggestions or notice any errors please send them along.

Posted on 2008-04-15 by Eric Larson

The Problem with Leaders

Like the rest of us, I've been hearing quite a bit about politics lately. I'm a staunch supporter of keeping my political beliefs to myself, so this is not about what or who I support. Instead, I'd like to point out a pattern that is difficult to overcome.

I think Lessig has essentially brought this up with the Change Congress movement. The issue being that people are expected to vote based on some semi-qualified basis. Yet, this means that they have the responsibility to educate themselves on the issues along with how the parties and candidates plan on dealing with them. In short this doesn't scale. We don't have time to do a lot of research so we depend on other sources to help us make a decision.

The two basic categories of sources are media and associations. The media provides coverage of the issues, candidates and generally everything people are interested in. They are commercial though and must cater to the desire, not the needs, of its audience in order to survive. Associations are groups such as churches, employers, unions, clubs, or anything else that functions as a group. The issue here is that as people participate in the group, they essentially offer their impact to the group leaders in the form of endorsements. A good example is when the Teacher Union, AFL/CIO, or the AARP endorse a candidate. The group has offered to support the candidate as whole, and while the members are free to choose as they wish, the group has been the target of persuasion by the candidates and political parties.

The problem is essentially a scalability problem. No one has the resources to effectively communicate because the resources are not available in one way or another. Candidates and parties cannot speak to the public as a whole, so they turn to groups in hopes the members follow the leadership. The media must present what will be watched by an uninterested audience in order to support itself through advertising. Again, the message becomes tainted and/or misdirected in order to meet orthogonal needs.

There really is no solution, but the recent social networking movement and technology has been somewhat helpful in changing the landscape. By empowering more people to be producers of content and news, there are more opportunities to communicate messages that are unencumbered by outside forces. This doesn't imply there is truth in the messages. It simply means they are not impacted by a need to survive. The problem now is that there is a wealth of information and no way to meter and decipher it all. Again, I don't really have a solution outside of continuing to improve our use of semantic technology to find meaning and allowing interfaces that meet the needs of users.

This is actually what makes technology so interesting to me. It is the center of information, which has proven to be powerful in almost all facets of life. While answers are not easy, it is exciting to think that, at the very least, I'm working towards changing the way society works by helping further the discourse.

Posted on 2008-04-11 by Eric Larson

XSLTemplates 0.6

The other day I released XSLTemplates 0.6. The big change is including a template constant middleware that accepts a dictionary of items to include in the template by default. It automatically includes the WSGI environ dict in the template params.

The big question is how to use it? Well, one tactic is to go ahead and add one instance around the whole app adding any configuration details. In Bright Content we list the URLs of some services that will be used in the paste config file. I then wrap my BC instance with a TemplateConstants middleware that places environment dict and application configuration details found in the .ini. You can also use it more granular by wrapping different classes with their own instances. Really the idea is to use it where you have the same parameters in many different calls so you don't have to always remember to add them to the set_params call.

The next big change is using the xsl:output element to set the content type of the output. Currently you set the content type using the calling middleware. This is not very WSGI-ish b/c there is an actually calling middleware in the sense an application controls the value. It would be more in the spirit of WSGI to pass along that control to the template renderer. With that in mind, you can set the media type attribute in the xsl:output element and that will be the content type used in the response.

This is probably the last release of XSLTemplates for a little while as we migrate things into Akara. After that, I hope we can create some built options to allow relatively granular installs of different Akara components for use in WSGI apps.

Posted on 2008-04-03 by Eric Larson

REST is not Made Up of Verbs

I have been doing a few interviews as of late for my day job and it really hasn't been going well. I'm going to go ahead and take responsibility for the fact that my interview skills need some serious work. Beyond this though, no one knows much of anything about REST and/or HTTP. While I wouldn't say I'm an expert, it is clear that my knowledge ends up faring well against most the senior developers that I've been interviewing.

The point here is not to place myself upon some kind of expert pedestal. In fact, the point is just the opposite. I'm not an expert. When I was learning PHP I heartily ignored HTTP any way I could because I felt it was a waste of time. When I was forced to edit a few Perl CGI scripts, I felt the explicit Content-Type headers were silly. Little did I know that the explicitness was not explicitness at all, but rather simply using HTTP in an application. I doubt the code I edited revealed this subtlety at the time, but, it still was an opportunity for me to dig deeper that was ignored.

In learning WSGI and Python web development, it became clear that I would need to deal with HTTP. The first part was using simple status codes. This seemed like a hassle at first. It became quickly apparent that I could use HTTP to communicate much of what I meant simply by providing a decent status code. My next big step was working with the content type. I saw very quickly why all the PHP scripts for forcing a download actually worked. In the past this was semi-understood, but now I saw the real value. I also learned about content negotiation and how powerful it could be in creating a RESTful service.

All of this was learned within the scope of the AtomPub spec writing process. I watched as folks discussed caching, URI templates and linking. It became clear how using and understanding HTTP makes creating RESTful services intuitive, simple and efficient. There is no silver bullet, but understanding RESTful Web Services does a great job of doing the most with what you have.

So, what are my suggestions for really understanding REST? The first step is realizing the world is not about CRUD. REST doesn't get you anything better than SOAP or XML-RPC in this case. One could argue that, since browsers don't support PUT and DELETE out of the box, RESTful services are more difficult. I'm not saying that RESTful CRUD is unimportant, but simply it is not the real hype.

The big deal about REST is Linked Data. When you consider the division between a resource and a representation along side using linking to define the flow of state, the stateless web becomes a more understandable application platform. You can think of resources simply as URIs and representations the file you get back from the request of the resource. This is somewhat over simplified, but more or less this is how you think about things in REST. The next thing to understand is a representation or resource is not an object. It sure can be, but it is not by default. This may seem odd from an OO perspective, but the web is a creation of documents, not objects. Sure, these documents are often compositions of object data, but from the standpoint of a RESTful service, they are all documents.

This distinction is huge because it sets expectations. You will never just assume you can point some function at a URL and magically get an object. I'm not saying you won't write a method or two to make a GET request and build an object. You will and that is fine. But the fact is, you understand that when the document changes formats, you might have to change your code. Might is the operative word here because being RESTful means making an effort to be robust.

When you think of the web in terms of documents, the work flow of how to deal with data changes. Instead of thinking in terms of an object, there is an actual document that you reference. Any sort of language specific tool you use to work with the document is separated from the document itself. When you consider manipulating something like XML, you have tools that let you maintain the document as a whole. Contrast this with ORM tools that take small pieces of data and place them in data structures. When you are talking about the web, working with documents is much simpler than thinking in terms of serialization between a view, data structure, ORM, and database.

Another area I think causes confusion and misunderstanding for REST comes from the fact that it is more functional (in the Lisp/Haskell/Erlang sense) than object oriented. Functional languages require that variables be immutable. This is a direct parallel to HTTP requests. A web application cannot pass along a reference to some object that is tethered to an instance on the server. This means programming in this fashion is only working against you.

What is interesting about REST as a movement is that it is not meant to be innovative. REST aims to analyze what is successful about the web and apply the principles to web application development. In a way, it is what folks came up with after a code review of the web. I am hoping that more people make an effort to understand REST for what it is. In many cases it really takes some effort to think in RESTful terms. This is especially true when you are accustomed to thinking in objects. Hopefully, more people will continue to catch on and see the benefits, so we can finally move on to even better misunderstood principles for the Web 3.0 code review!

Posted on 2008-03-21 by Eric Larson

Blogging From Emacs

Thanks to the magic of Pymacs I can now script Emacs with my favorite language. It's rather thrilling to think about in a way because I spend so much time in my editor. Part of me wonders if I am wasting my time with Emacs. Things like better auto-completion could be nice and there are times where a more robust viewport into the filesystem could really be helpful.

What makes it all worth while is knowing that I am learning how to solve problems. When you have an IDE that is configured for you to automagically put all the pieces together, there is always the chance you misunderstood what is actually happening under the hood. This is usually not that big of an issue. It is pretty harmless because you can usually figure out the problems when they arise. Yet, even though you have good documentation and some helpful hackers at your side, there is still a reasonable chance that you go down the totally wrong path because you made incorrect assumptions.

I think Emacs helps to avoid this kind of problem. I can't tell you how many times I've seen some slick screenshot of a cool mode I want to try. Most of the time they don't work, but everytime I give it a go, I learn a little more. While I really can't code elisp, I have been able to undestand a good deal more about it by working with Pymacs. It is these little battles that make me realize the struggles I have with Emacs force me to learn new things and think methodically about how to solve problems. It also makes it clear how important a user interface can be when trying to accomplish a specific task. None of this is rocket science, but as someone who loves to learn, it is a ton of fun.

Posted on 2008-03-20 by Eric Larson
next