<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-2271541549037776358</id><updated>2008-08-11T18:03:34.581-04:00</updated><title type='text'>Ushanka</title><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-6407430931388456230</id><published>2008-04-14T09:06:00.002-04:00</published><updated>2008-04-14T09:18:02.957-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='amazon'/><category scheme='http://www.blogger.com/atom/ns#' term='s3'/><category scheme='http://www.blogger.com/atom/ns#' term='ec2'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Amazon EC2: Persistent Storage</title><content type='html'>Amazon has just started a private beta program for a new persistent storage API in EC2. According to their documentation, they provide an API to create and manage volumes between 1GB and 1TB in size that behave like unformatted disks. Each volume is persistent and independent of EC2 instances and a single EC2 instance can mount multiple volumes. Their disks are supposed to be low-latency and high throughput with calls to store snapshots onto S3.&lt;br /&gt;&lt;br /&gt;A lack of persistent storage has been the biggest challenge for developers as EC2 (in my experience) has rather high failure rates. With this persistent storage API (scheduled for public release later this year), Amazon has just made EC2 a dead-easy buy-in.</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/04/amazon-ec2-persistent-storage.html' title='Amazon EC2: Persistent Storage'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=6407430931388456230' title='5 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/6407430931388456230'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/6407430931388456230'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-7339900679963502095</id><published>2008-03-01T16:31:00.006-05:00</published><updated>2008-03-02T13:15:03.686-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='amazon'/><category scheme='http://www.blogger.com/atom/ns#' term='ec2'/><title type='text'>Amazon EC2: The Potential</title><content type='html'>&lt;img style="float:left; margin:0 10px 10px 0;" src="http://sharvil.nanavati.net/uploaded_images/datacenter-722032.jpg" border="0" alt="" /&gt;Amazon's Elastic Compute Cloud (EC2) is easily their most powerful web service offering. With EC2, you get flexible, on-demand computing resources: by launching an &lt;i&gt;instance&lt;/i&gt; you get full access to a brand-new machine and its resources. Each CPU-hour costs $0.10, which equates to less than $80 per month if you run an instance 24/7! What's more, you can launch as many instances as you'd like so you can have your own network of machines hosted by Amazon. The clincher? All data transferred between EC2 instances and S3 is free!&lt;br /&gt;&lt;br /&gt;The default configuration has the following specs:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;CPU: 32-bit, 1.0-1.2 GHz Opteron/Xeon equivalent&lt;/li&gt;&lt;li&gt;RAM: 1.7 GB&lt;/li&gt;&lt;li&gt;Disk: 160 GB&lt;/li&gt;&lt;li&gt;NIC: 100 MBit&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;They have additional configurations if you need more resources on a single machine. For details, see the &lt;a href="http://www.amazon.com/b/ref=sc_fe_l_2?ie=UTF8&amp;amp;node=201590011&amp;amp;no=3435361&amp;amp;me=A36L942TSJ2AJA"&gt;EC2 site&lt;/a&gt;. To make all of this work, EC2 allocates a &lt;a href="http://en.wikipedia.org/wiki/Virtual_machine"&gt;virtual machine&lt;/a&gt; running on the &lt;a href="http://en.wikipedia.org/wiki/Xen"&gt;Xen hypervisor&lt;/a&gt; instead of a physical machine for every instance launched.&lt;br /&gt;&lt;br /&gt;Amazon designed EC2 primarily to perform many computationally expensive operations - something like batch video encoding or image recognition. Instead of making large hardware investments to perform these (potentially one-shot) tasks, you run the tasks in parallel on a few (hundred?) EC2 instances. Once the tasks are complete, just shut down the instances and your billing stops there.  While Amazon's vision for EC2 is pretty sweet, the reality is that there's so much more potential there.&lt;br /&gt;&lt;br /&gt;EC2 is the next-generation data center.&lt;br /&gt;&lt;br /&gt;Instead of doing capacity planning as with a traditional data center, with EC2, I could monitor the load on my server and programmatically launch parallel instances once it reaches a threshold utilization. When the utilization drops again, I can terminate the extra instances and go back to a fairly quiescent state. With free traffic between EC2 and S3, I can churn through collected data as many times as I need to as in Amazon's vision. Amazon could even issue hardware updates (e.g. more RAM) to running instances without rebooting! With the inexpensive per-hour prices, any small business can afford to keep an active standby. The flexibility offered by programmatically managing machines running in a virtualized data center is tremendous. Coupled with Amazon's pricing model, this sort of service is poised to take some serious market share away from the traditional, physical data centers.&lt;br /&gt;&lt;br /&gt;While EC2 has the potential to be all of this and probably much more, it's not currently ready to displace traditional data centers. In a subsequent post, I'll discuss some of the issues preventing EC2 from realizing this dream.</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/03/amazon-ec2-potential.html' title='Amazon EC2: The Potential'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=7339900679963502095' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/7339900679963502095'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/7339900679963502095'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-7780937633264599065</id><published>2008-02-22T17:52:00.004-05:00</published><updated>2008-02-24T14:45:20.634-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ocaml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='authentication'/><title type='text'>OCamlPAM 1.0 Released!</title><content type='html'>&lt;img style="float:left; margin:0 10px 10px 0" src="http://sharvil.nanavati.net/uploaded_images/passport-783939.jpg" border="0" alt="" /&gt;&lt;a href="http://www.kernel.org/pub/linux/libs/pam/"&gt;PAM&lt;/a&gt; is a slick policy-based authentication mechanism. It abstracts away the method of authentication from applications and makes it possible to change the authentication method for a deployed application/service while running instead of making that decision at compile-time. I've come to love PAM because it makes &lt;a href="http://en.wikipedia.org/wiki/Single_sign_on"&gt;single sign-on&lt;/a&gt; a possibility and lets me focus on my application logic rather than the details of, say, &lt;a href="http://tldp.org/HOWTO/LDAP-HOWTO/authentication.html"&gt;LDAP authentication&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Since I've been playing around with &lt;a href="http://caml.inria.fr/ocaml/"&gt;Objective Caml&lt;/a&gt; lately and I needed to do some authentication, I wrote an OCaml wrapper for PAM. &lt;a href="http://sharvil.nanavati.net/projects/ocamlpam/"&gt;Take a look, give it a go, and authenticate away&lt;/a&gt;!</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/02/ocamlpam-10-released.html' title='OCamlPAM 1.0 Released!'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=7780937633264599065' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/7780937633264599065'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/7780937633264599065'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-8562182725572604962</id><published>2008-02-21T23:39:00.003-05:00</published><updated>2008-02-22T01:44:52.875-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='energy'/><title type='text'>Power Profiling: Saving Energy in Software</title><content type='html'>&lt;img style="float:left; margin:0 10px 10px 0;" src="http://sharvil.nanavati.net/uploaded_images/electricity-772285.jpg" border="0" alt="" /&gt;I came across a pretty nifty profiling tool a little while ago called &lt;a href="http://www.lesswatts.org/projects/powertop/"&gt;PowerTOP&lt;/a&gt;. It gives you a live view of the power consumed by applications running on your Linux machine in an interface that resembles &lt;i&gt;top&lt;/i&gt;. As a system-level power profiler, it gives you an idea of which applications or drivers are waking up the CPU or preventing it from entering a sleep state.&lt;br /&gt;&lt;br /&gt;I think this kind of tool is awesome for both developers and end-users. As a user, it tells me which applications are draining my laptop's battery so I might close those applications if I'm not using them or I might find an alternative altogether. From what I understand, some people have gained significantly higher use-times for their laptops by just killing innocuous-looking apps that don't let the processor enter a deeper sleep state. As a developer, this is good news because it will give me a quantitative measure of my application's power consumption, giving me a means to determine the power-efficiency of different designs. This tool has also managed to &lt;a href="http://www.lesswatts.org/projects/powertop/known.php"&gt;expose bugs in a few applications&lt;/a&gt;!&lt;br /&gt;&lt;br /&gt;Check out PowerTOP, fix your applications, and keep this planet green (and my laptop running longer and cooler)!</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/02/power-profiling-saving-energy-in.html' title='Power Profiling: Saving Energy in Software'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=8562182725572604962' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/8562182725572604962'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/8562182725572604962'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-3445286709878071995</id><published>2008-02-10T19:12:00.000-05:00</published><updated>2008-02-11T17:47:26.938-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='amazon'/><category scheme='http://www.blogger.com/atom/ns#' term='s3'/><title type='text'>A Closer Look: Amazon S3</title><content type='html'>&lt;a href="http://sharvil.nanavati.net/uploaded_images/harddrive-774250.jpg"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://sharvil.nanavati.net/uploaded_images/harddrive-774243.jpg" border="0" /&gt;&lt;/a&gt; One of the most mature Amazon web services, Amazon Simple Storage Service (S3) provides a virtually &lt;i&gt;unlimited&lt;/i&gt; data storage service. That's right: you can upload as much data as you'd like and it will be held on their machines with all the network capacity you could ever want and with redundancy built-in. Hard drive failures are easily the primary cause of server downtime and Amazon has taken the burden upon themselves to manage all the devices and failures that go along with it. As the name implies, the service is designed to provide simple access so you can't do funky things like mount the virtual filesystem directly.&lt;br /&gt;&lt;br /&gt;I've been using S3 for over a year and I haven't had any reliability issues with it. Others have had brief outages but they were mostly when the service was first introduced. I'm quite happy with S3 but there's one missing feature that keeps it from being the ultimate simple storage service: range-PUT.&lt;br /&gt;&lt;br /&gt;Suppose I've got a file on S3 and I want to update a small part of it. Without range-PUT, I would normally have to transfer the entire file again using the HTTP PUT method to store it on the remote host. Using the &lt;i&gt;Content-Range&lt;/i&gt; header, I could specify just the range of bytes that have changed within the file and transfer just that portion. This feature would save a lot of bandwidth (and, consequently, money) if files often get modified partially.&lt;br /&gt;&lt;br /&gt;Of course, supporting &lt;i&gt;Content-Range&lt;/i&gt; opens up a can of worms. What happens if the file doesn't exist and the start of my range isn't offset 0? What if the file &lt;b&gt;does&lt;/b&gt; exist but the start offset is beyond the end of file (i.e. not a simple append)? I can think of two solutions that seem reasonable: return an error or create the file if it doesn't exist and zero-pad the holes. The former would be easier to implement while the latter would produce a behaviour like Linux sparse files.&lt;br /&gt;&lt;br /&gt;There are two major application classes that range-PUT would be suited to. The first would be the class of applications where we always append to the end-of-file. Log files would fit into this category but, more importantly, we could resume broken transfers. When uploading large files (S3 supports file sizes of up to 5GB), I've found that my connections often get dropped so if I could just append to an existing file, I could write an upload tool that would auto-resume. The second class of applications would be the ones that only update part of a file. In most cases, I'd imagine this kind of update would take place to change some file metadata. For example, if I modify the metadata for my MP3 file, I'd rather just upload the few changed bytes instead of uploading the whole MP3 again. The music is the same, it's just the metadata that has changed. This problem is even worse when dealing with video files.&lt;br /&gt;&lt;br /&gt;S3 is a fantastic storage service. It's reliable, it's cheap, and it takes away the hassle of managing your own hardware or creating a highly-available, redundant persistent store. If S3 supported range-PUT, it would save a huge amount of bandwidth resulting in an even lower cost of operation.</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/02/closer-look-amazon-s3.html' title='A Closer Look: Amazon S3'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=3445286709878071995' title='6 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/3445286709878071995'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/3445286709878071995'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-6164385634858371373</id><published>2008-02-10T16:14:00.001-05:00</published><updated>2008-02-10T18:38:08.235-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='amazon'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>A Closer Look: Amazon Web Services</title><content type='html'>&lt;a href="http://www.amazon.com/"&gt;Amazon&lt;/a&gt; has been doing some pretty nifty stuff lately. They've exposed their computing infrastructure to the rest of the world via &lt;a href="http://en.wikipedia.org/wiki/REST"&gt;RESTful&lt;/a&gt; web services. I think it's a brilliant move by &lt;a href="http://en.wikipedia.org/wiki/Jeff_Bezos"&gt;Jeff Bezos&lt;/a&gt; and it realizes some of the technology promises of the last decade or so.&lt;br /&gt;&lt;br /&gt;&lt;img style="FLOAT: left; MARGIN: 5px 10px 10px 0px;" alt="" src="http://sharvil.nanavati.net/uploaded_images/amazon_web_services-763111.gif" border="0" /&gt;&lt;a href="http://www.amazonaws.com/"&gt;Amazon's web services&lt;/a&gt; have been getting a lot of great reviews from many bloggers and deservedly so. With their pay-as-you-use model, it's amazingly easy to scale up or down based entirely on workload; there's virtually no need for capacity planning and no need to manage physical systems at all! I've been using their web services for over a year now for a variety of tasks and it has been, for the most part, quite pleasant. They've saved me a lot of time and money but their services do have their faults. I'll be talking about some of the issues I've encountered with the design or implementation of their services over the next few posts.</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/02/closer-look-amazon-web-services.html' title='A Closer Look: Amazon Web Services'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=6164385634858371373' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/6164385634858371373'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/6164385634858371373'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-1619382984119479535</id><published>2008-02-07T18:24:00.000-05:00</published><updated>2008-02-10T15:59:38.191-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='industry'/><category scheme='http://www.blogger.com/atom/ns#' term='yahoo'/><title type='text'>Company Loyalty</title><content type='html'>&lt;a href="http://en.wikipedia.org/wiki/Jerry_Yang"&gt;Jerry Yang&lt;/a&gt;, CEO of Yahoo!, recently sent out a company-wide memo in response to Microsoft's $44bn hostile bid. &lt;a href="http://daringfireball.net/2008/02/yahoo_translation"&gt;Here's a rather hilarious "human readable" version&lt;/a&gt; of the memo courtesy of John Gruber.&lt;br /&gt;&lt;br /&gt;While I don't 100% agree with the translation, I find it amusing that we actually &lt;b&gt;need&lt;/b&gt; to translate. You'd think that such an important message would be a bit more... accessible.&lt;br /&gt;&lt;br /&gt;The memo makes me wonder, though: how often does senior management actually point out the importance of their employees outside of annual company meetings and circumstances such as this? Yang is really asking for loyalty through a difficult time for his organization. Did he build that loyalty or is he just asking for it? I don't know, but I'd be curious to find out.</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/02/company-loyalty.html' title='Company Loyalty'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=1619382984119479535' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/1619382984119479535'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/1619382984119479535'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-3800196462036363546</id><published>2008-02-07T16:26:00.000-05:00</published><updated>2008-02-07T16:52:39.978-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='games'/><title type='text'>Protector</title><content type='html'>&lt;div&gt;A while ago, I had come across this Flash game called &lt;a href="http://www.jeannettevejarano.com/games/tower-defence.html"&gt;Tower Defense&lt;/a&gt;. The idea of the game is to put up guard towers along a path to the castle to prevent enemy attackers from killing your citizens. It was fun but got frustrating as the levels wore on because the income didn't keep up with the increasing strength of the attackers.&lt;br /&gt;&lt;br /&gt;Then, a couple of days ago, I came across &lt;a href="http://www.kongregate.com/games/undefined/protector"&gt;Protector&lt;/a&gt;, a game based on the same principles but with an RPG-style twist. It's actually pretty awesome! I have to admit, for a Flash game, it's quite polished with a tutorial mode and everything. Here's a screenshot of the game in action:&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://sharvil.nanavati.net/uploaded_images/protector-737901.png"&gt;&lt;img style="CURSOR: hand" alt="" src="http://sharvil.nanavati.net/uploaded_images/protector-737876.png" border="0" /&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;I find that console games have gotten too complex to appreciate. They try to create an immersive experience but most of the time, I just want a quick fix so I can relax. Sure, there are first-person-shooters, but they're all about the same and they get pretty boring pretty fast. I have a feeling that the success of the Wii and its throw-back to the classic, simple games of the 90's show that there's still demand for quick gaming. &lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/02/protector.html' title='Protector'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=3800196462036363546' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/3800196462036363546'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/3800196462036363546'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-4020785733825760089</id><published>2008-02-06T00:27:00.000-05:00</published><updated>2008-02-06T01:53:23.593-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Google Web Toolkit: a quick look</title><content type='html'>While writing the last blog post, I had a miserable time trying to get the Java snippets formatted correctly. I suppose the problem is that I'm using Blogger instead of a full-blown publishing platform like &lt;a href="http://www.movabletype.org/"&gt;Movable Type&lt;/a&gt; which has plugins for code highlighting. Once I got the post up, I decided to build a web service that would take a code snippet in your language of choice and return highlighted HTML code.&lt;br /&gt;&lt;br /&gt;Along the way, I found a neat package called &lt;a href="http://qbnz.com/highlighter/"&gt;GeSHi&lt;/a&gt;, a generic code highlighter that would make my life a lot easier. I then got the idea of making an AJAXed front-end to that along with other useful web services... Eventually, I came across the &lt;a href="http://code.google.com/webtoolkit/"&gt;Google Web Toolkit&lt;/a&gt; and it looks like the Google folks are really on to something!&lt;br /&gt;&lt;br /&gt;Now, I'm sorry to say that I've done my share of AJAX code before, both client side and server side, and it has been one of the most painful coding experiences of my life. The runtime errors, the lack of decent developer tools, the browser incompatibilites, the ridiculous workarounds... web development has been just one enormous nightmare. The guys and gals at Google managed to take a large part of that away with GWT; they're actually compiling &lt;b&gt;Java&lt;/b&gt; code to JavaScript with all of the compile-time checks (hooray, no more typo-bugs rearing their heads at runtime!), development tools (including a &lt;b&gt;debugger&lt;/b&gt;!), and patterns kept intact! The really nice bit is that they abstract all of the cross-browser differences via their core library. Now &lt;b&gt;this&lt;/b&gt; is a step in the right direction for web development!&lt;br /&gt;&lt;br /&gt;Of course, it's not a perfect system. They're building this on top of Java 1.4 so we still don't have safe container classes or enumerated values (sigh). What's more, since AJAX is event driven by nature, I think it would be so much easier to use a functional source language so we can pass functions and closures around instead of anonymous inner classes.</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/02/google-web-toolkit-quick-look.html' title='Google Web Toolkit: a quick look'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=4020785733825760089' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/4020785733825760089'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/4020785733825760089'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-2271541549037776358.post-1633928596423477944</id><published>2008-02-03T18:38:00.000-05:00</published><updated>2008-02-04T02:34:54.840-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>When goodbyes aren't enough...</title><content type='html'>The Java core classes have a pretty nasty habit of throwing &lt;em&gt;IOExceptions&lt;/em&gt; in &lt;em&gt;close&lt;/em&gt; methods. Since &lt;em&gt;IOException&lt;/em&gt;s are not derived from &lt;em&gt;RuntimeException&lt;/em&gt;, you either have to catch them or declare them as thrown from the method calling &lt;em&gt;close&lt;/em&gt;. Now, suppose I have a class that holds a couple of resources, &lt;em&gt;r1&lt;/em&gt; and &lt;em&gt;r2&lt;/em&gt;. Let's see what happens if I try to release them together:&lt;br /&gt;&lt;br /&gt;&lt;pre class="java"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    r1.&lt;span style="color: #006600;"&gt;close&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;    r2.&lt;span style="color: #006600;"&gt;close&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://www.google.com/search?hl=en&amp;amp;q=allinurl%3AIOException+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;IOException&lt;/span&gt;&lt;/a&gt; e&lt;span style="color: #66cc66;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #808080; font-style: italic;"&gt;// Do whatever I need to here...&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;If &lt;em&gt;r1&lt;/em&gt;'s &lt;em&gt;close&lt;/em&gt; happens to throw, &lt;em&gt;r2&lt;/em&gt;'s &lt;em&gt;close&lt;/em&gt; will never be called and I might (in a long-running application) leak resources. The same problem occurs if I don't bother catching the exception and declare it thrown from my method. Putting the &lt;em&gt;close&lt;/em&gt; calls in the &lt;em&gt;finally&lt;/em&gt; clause won't fix the problem either. A working solution could be:&lt;br /&gt;&lt;br /&gt;&lt;pre class="java"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    r1.&lt;span style="color: #006600;"&gt;close&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://www.google.com/search?hl=en&amp;amp;q=allinurl%3AIOException+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;IOException&lt;/span&gt;&lt;/a&gt; e&lt;span style="color: #66cc66;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #808080; font-style: italic;"&gt;// Do whatever I need to here...&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    r2.&lt;span style="color: #006600;"&gt;close&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://www.google.com/search?hl=en&amp;amp;q=allinurl%3AIOException+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky"&gt;&lt;span style="color: #aaaadd; font-weight: bold;"&gt;IOException&lt;/span&gt;&lt;/a&gt; e&lt;span style="color: #66cc66;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #808080; font-style: italic;"&gt;// Do whatever I need to here...&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;This code looks worse than checking for return codes! What's more, I, as a programmer, am &lt;strong&gt;getting rid of a resource&lt;/strong&gt;. I have decided that the given resource is no longer of any use to me. I am throwing it away. And it's coming back!&lt;br /&gt;&lt;br /&gt;I can't think of a single reason an exception (checked or unchecked) should be thrown from a method that is releasing a resource. In situations like this, a return code should be used instead of exceptions because the programmer has, by the very act of calling your method, declared that she is no longer interested in the resource.</content><link rel='alternate' type='text/html' href='http://sharvil.nanavati.net/2008/02/when-goodbyes-arent-enough.html' title='When goodbyes aren&apos;t enough...'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2271541549037776358&amp;postID=1633928596423477944' title='4 Comments'/><link rel='replies' type='application/atom+xml' href='http://sharvil.nanavati.net/atom.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/1633928596423477944'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2271541549037776358/posts/default/1633928596423477944'/><author><name>sharvil</name><uri>http://www.blogger.com/profile/10837472563653338726</uri><email>noreply@blogger.com</email></author></entry></feed>