<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1831008827141976577</id><updated>2011-07-07T19:29:34.813-06:00</updated><category term='Mobile'/><category term='Hardware'/><category term='XML'/><category term='Scala'/><category term='Disaster'/><category term='&quot;Mac OS X&quot;'/><category term='VCS'/><category term='General'/><category term='JavaScript'/><category term='Java'/><category term='Wrting'/><category term='OS'/><title type='text'>Blasted Machine!</title><subtitle type='html'>In which the author relates information on technology, software, and the wonders therein.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-2440643551712351610</id><published>2009-11-10T08:34:00.004-06:00</published><updated>2009-11-10T08:47:30.719-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VCS'/><title type='text'>More on Modern Version Control</title><content type='html'>Lately, I've been trying to select a modern choice of VCS for personal (and freelance) work, as well as picking a recommendation for my current place of employment.  I'm leaning towards Git (see my previous post), but I would still like to head off any potential arguments for the other contenders - in this case, namely Mercurial. &lt;br /&gt;&lt;br /&gt;Here's a very &lt;a href="http://www.infoq.com/articles/dvcs-guide"&gt;detailed comparison&lt;/a&gt; of the top three DVCS solutions: Git, Mercurial, and Bzr (which I'm not considering).  It doesn't necessarily make the choice for me, but it gives a good idea of what the advantages and disadvantages are. &lt;br /&gt;&lt;br /&gt;One sticking point of Git, when it comes to making a recommendation at the office, is that it has very poor Windows support.  It is really only available via Cygwin and doesn't really have any decent GUI tools outside of  Linux.  Given that I use OS X for personal and freelance work, this isn't an issue.&lt;br /&gt;&lt;br /&gt;Mercurial (or Hg, which is its command-line executable - and the atomic symbol for Mercury -- very clever) has great support on Windows, but this isn't surpising: it's written in Python.  This means that, in general, it is fairly cross-platform.  There is also good a GUI tool for Windows, namely &lt;a href="http://www.selenic.com/mercurial/wiki/index.cgi/TortoiseHg"&gt;TortoiseHg&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The one thing that's not clear for me from this comparison is which tool has the better branching and merging model.  Git has it's rebasing and can do complete historical merges, as well as more of a standard branch/merge model.  Mercurial's model is less well known to me at this time, so perhaps the next step in this decision process is finding an equivalent of Pro Git for Mercurial.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-2440643551712351610?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/2440643551712351610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=2440643551712351610' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/2440643551712351610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/2440643551712351610'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2009/11/more-on-modern-version-control.html' title='More on Modern Version Control'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-5872331969714182469</id><published>2009-11-04T08:55:00.004-06:00</published><updated>2009-11-10T09:16:15.256-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VCS'/><title type='text'>Getting Git</title><content type='html'>&lt;a href="http://progit.org/book/"&gt;Pro Git&lt;/a&gt; is an excellent book on the Git version control system.  It covers all aspects of Git from the day-to-day basics and branching to the use and setup of remote repositories.  It is concisely written with excellent examples.  The diagrams are particularly helpful in understanding branching, particularly in the context of merging and rebasing.&lt;br /&gt;&lt;br /&gt;A must read for anyone considering a distributed VCS.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-5872331969714182469?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/5872331969714182469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=5872331969714182469' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/5872331969714182469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/5872331969714182469'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2009/11/getting-git.html' title='Getting Git'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-304731552493815449</id><published>2009-10-21T02:47:00.002-06:00</published><updated>2009-10-21T02:51:50.681-06:00</updated><title type='text'>Double Disk Failure</title><content type='html'>You'd think I'd be good at this. You'd think I'd be disciplined.  I've had enough catestrophic hardware failures in my life, that you'd think I'd have a regular backup strategy of the important files on my main computer (a Macbook). You'd be right.  Well, at least I did up until my back-up drive died...over a year ago. &lt;br /&gt;&lt;br /&gt;Pretty useless strategy when your main hard-drive dies.&lt;br /&gt;&lt;br /&gt;Normally, this wouldn't be as catastrophic as it sounds.  Except that I'm in Germany, and I don't know where to go to find parts or restore the data on my drive.  Nor do I even have my OS X disks (or any disks, for that matter, to even try Ubuntu) or the tools to repair the laptop. Fortunately, I have an iPod Touch, which proved invaluable for finding information and stores. I was able to try a number of steps to see about recovery, even with these obstacles.&lt;br /&gt;&lt;br /&gt;First, I tried to install Ubuntu to a thumb-drive and boot from there.  I have a thumb drive on hand, and could download Ubuntu (using my flatmate's laptop), so this was a good, free option.  Following this &lt;a href="http://www.howtogeek.com/howto/linux/create-a-bootable-ubuntu-usb-flash-drive-the-easy-way/"&gt;guide&lt;/a&gt;, I had no problem setting up the thumb-drive.  However, it turns out, that Macbooks won't boot Linux from USB drive. I haven't yet looked into whether or not it needs to have the right partition table, but looking around the web, it doesn't seem to be possible.  &lt;br /&gt;&lt;br /&gt;Second, I found an electronics store - Saturn - and bought some CD-R's&lt;sup&gt;[1]&lt;/sup&gt; and a copy of OS X: Snow Leopard.  My second, less-then-free-but-still-cheaper-than-buying-a-new-hard-drive strategy was to install Snow Leopard to an external USB hard-drive, which I happen to have on hand. Following this &lt;a href="http://www.maciverse.com/installing-snow-leopard-onto-an-external-hard-drive.html"&gt;guide&lt;/a&gt;, I began by formatting and repartitioning the disk.  Remember when I mentioned that I'm in Germany?  Well, it seems that this disk did not exactly survive the flight here in my luggage.  The format failed repeatedly, using Disk Repair failed repeatedly, and even when it seemed to work, the install would fail immediately when attempting to write to disk.  At least, I was able to verify that it was only the Macbook's disk was broken. &lt;br /&gt;&lt;br /&gt;Third, I found another electronics store - Conrad - where I could buy a new hard-drive (double the size of the old one, so there's one silver lining) and the tools to replace it. 70 Euro later, and I have the parts to fix things&lt;sup&gt;[2]&lt;/sup&gt;.  Thanks to &lt;a href="http://www.ifixit.com"&gt;iFixit&lt;/a&gt;  and their tutorial for &lt;a href="http://www.ifixit.com/Guide/Repair/MacBook-Core-2-Duo-Hard-Drive-Replacement/514/1"&gt;replacing the hard-drive&lt;/a&gt;, I was able to easily install a copy of Snow Leopard. &lt;br /&gt;&lt;br /&gt;So, I'm left with a clean laptop&lt;sup&gt;[3]&lt;/sup&gt;, and the task of restoring all my applications.  This is a bit of a pain, since some of them don't run on Snow Leopard (I'm looking at you Microsoft Office 2004), and I don't have the disks on hand for others (Adobe Creative Suite). I'll have to find some open-source alternatives, in the mean time.&lt;br /&gt;&lt;br /&gt;It's a relief having it back up and running.  Aside from being my personal development space, it currently is my communication platform and my entertainment platform. I've lived with out a computer before, but it takes a week to get over the hole it leaves in my life.  I'm glad it only took a few days to plug that whole back up.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;[1] The CD's were for creating a bootable Ubuntu CD, as a backup plan.&lt;br /&gt;&lt;br /&gt;[2] Total cost: 102.70 Euro - Not too bad really&lt;br /&gt;&lt;br /&gt;[3] I have yet to find a place to recover the data from my old disk, but I may wait until I'm back in the States.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-304731552493815449?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/304731552493815449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=304731552493815449' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/304731552493815449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/304731552493815449'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2009/10/double-disk-failure.html' title='Double Disk Failure'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-955264305579700054</id><published>2009-08-05T13:11:00.002-06:00</published><updated>2009-08-05T13:13:41.934-06:00</updated><title type='text'>Twing of Jealosy</title><content type='html'>It's stuff like this that makes me want to give up working in business-related applications:  &lt;a href="http://www.technologyreview.com/blog/editors/23940/"&gt;SIGGRAPH2009&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Frankly, there some pretty cool concepts there.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-955264305579700054?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/955264305579700054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=955264305579700054' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/955264305579700054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/955264305579700054'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2009/08/twing-of-jealosy.html' title='Twing of Jealosy'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-4639884023347228227</id><published>2009-05-27T20:10:00.004-06:00</published><updated>2009-05-27T20:24:47.469-06:00</updated><title type='text'>File Madness</title><content type='html'>One thing that has already driving me nuts about the iPhone OS is the file system interaction.  It's not necessarily something that I'll have to deal with very frequently, but the way standard directories are defined is a bit of a hodge-podge:&lt;br /&gt;&lt;br /&gt;Getting your Application bundle directory (where all of your resources are going to be written):&lt;br /&gt;&lt;pre&gt;NSString *resourceDir = [[NSBundle mainBundle] resourcePath];&lt;/pre&gt;&lt;br /&gt;Getting the Application's Home directory, where its documents, cache, and temporary directories are (as well as the above mentioned bundle directory):&lt;br /&gt;&lt;pre&gt;NSString *homeDir = NSHomeDirectory();&lt;/pre&gt;&lt;br /&gt;But to get any of these other directories it get's uglier:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;NSArray *paths =&lt;br /&gt; NSSearchPathForDirectoriesInDomains(&lt;br /&gt;     NSDocumentDirectory, NSUserDomainMask, YES);&lt;br /&gt;NSString *documentsDirectory = [paths objectAtIndex:0];&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The least they could have done is given us a simple function to get that document directory, something like NSGetDocuemntDir(), for example.&lt;br /&gt;&lt;br /&gt;Now, all this is in the documentation, but the bundle directory (where all your project resources go) are not considered files, so therefore, are only mentioned in passing in the File section of the documentation. I have been less then impressed by the developer documentation from apple.  It's complete, but I just don't find the organization to be all that intuitive.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-4639884023347228227?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/4639884023347228227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=4639884023347228227' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/4639884023347228227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/4639884023347228227'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2009/05/file-madness.html' title='File Madness'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-628255991192598954</id><published>2009-05-24T15:58:00.007-06:00</published><updated>2009-05-24T16:45:52.874-06:00</updated><title type='text'>First iPhone App</title><content type='html'>I finished the first pass at a working iPhone app. It's a port of the &lt;a href="http://www.mozilla.org/js/spidermonkey/"&gt;SpiderMonkey&lt;/a&gt; Javascript engine from Mozilla.  I've put together a simple UI with an editor and output text areas.  Currently it only has an &lt;tt&gt;alert()&lt;/tt&gt; function and a &lt;tt&gt;print()&lt;/tt&gt; function for displaying results in the output text view.  It does have all of the default functions and objects for JavaScript 1.7.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7n9omckRPek/ShnLijD9RNI/AAAAAAAAADA/lKW0DHk8R-U/s1600-h/JsPhone_screenshot.png"&gt;&lt;img style="cursor: pointer; width: 172px; height: 320px;" src="http://3.bp.blogspot.com/_7n9omckRPek/ShnLijD9RNI/AAAAAAAAADA/lKW0DHk8R-U/s320/JsPhone_screenshot.png" alt="" id="BLOGGER_PHOTO_ID_5339522627612263634" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Source available &lt;a href="http://sites.blastedmachine.com/source/projects/jsphone-initial.tar.gz?attredirects=0"&gt;here&lt;/a&gt;.  I am looking to host the project somewhere, but I haven't decided on a &lt;a href="http://www.selenic.com/mercurial/"&gt;Mercurial&lt;/a&gt; hosting solution that's free and allows me to upload an existing repository.&lt;br /&gt;&lt;br /&gt;Now,  I can't actually submit this to the App Store (it uses a separate language interpreter). I did it as an exercise in porting an existing application as a first step for porting another application which uses SpiderMonkey as its scripting engine.  That one has a lot more graphical and file issues, so it'll be a bit more of a challenge.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-628255991192598954?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/628255991192598954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=628255991192598954' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/628255991192598954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/628255991192598954'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2009/05/first-iphone-app.html' title='First iPhone App'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7n9omckRPek/ShnLijD9RNI/AAAAAAAAADA/lKW0DHk8R-U/s72-c/JsPhone_screenshot.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-5576527977171956930</id><published>2009-04-25T15:25:00.006-06:00</published><updated>2009-05-03T15:26:16.171-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='&quot;Mac OS X&quot;'/><title type='text'>Back to Mobiles</title><content type='html'>I spent a good chunk of time, early in my career, working on mobile handset programs. They were J2ME programs, and there were a tremendous amount of limitations.  In order to get back into the waters of mobile development, I recently bought an iPod Touch.   &lt;br /&gt;&lt;br /&gt;Boy, times have changed.&lt;br /&gt;&lt;br /&gt;The iPhone OS provides quite a suite of libraries: sound, animation, data, OpenGL, and a rich UI library.  You also get a whopping 8 GB of space on the base models of either the phone or touch.  On the earlier Motorola J2ME handsets, we had to keep our app under 150K - a real challenge with a java app as feature rich as that one.  &lt;br /&gt;&lt;br /&gt;Of course, the major difference in device development for me is that my previous experience was in business applications. Most of my ideas for getting my feet wet on the iPhone OS are small games.  &lt;br /&gt;&lt;br /&gt;Frankly, I don't know a whole lot about this sort of thing. But it's only a matter of learning some new API's and remembering how to do some simple math transforms.  &lt;br /&gt;&lt;br /&gt;I think one of the reasons I'm drawn to this platform (as well as the Wii - one at a time, people) is that it has some potentially novel input methods.  The first is the multi-touch screen, while not a new idea, widens the types of interactions one can have with the device. One can build games with innovative gesture controls which may become more intuitive then using the mouse and keyboard is now.&lt;br /&gt;&lt;br /&gt;Second (and far more interesting), the tri-axis accelerometer provides a new level of gesture-based interaction.  The device itself may be used as a steering wheel, it may be shaken to clear the screen, or it may be used to perform some other intuitive physical action. &lt;br /&gt;&lt;br /&gt;I have a lot of ideas on paper, so now it's just a matter of getting those ideas in code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-5576527977171956930?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/5576527977171956930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=5576527977171956930' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/5576527977171956930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/5576527977171956930'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2009/04/back-to-mobiles.html' title='Back to Mobiles'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-7173675508144553154</id><published>2008-12-13T21:20:00.003-06:00</published><updated>2008-12-13T21:47:45.730-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scala'/><title type='text'>Non-Functional</title><content type='html'>I've started to look at the &lt;a href="http://www.scala-lang.org/"&gt;Scala&lt;/a&gt; programming language.  It's a very interesting language created by Martin Odersky who was responsible for addition of Generics to Java.  It is both an object-oriented and a functional language. This makes it incredibly powerful, and incredible difficult at the same time.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;The Awesome&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It has two features that I find are incredible powerful.  The first is Scala's solution to the multiple inheritance problem.  A piece of functionality can be placed into a &lt;tt&gt;trait&lt;/tt&gt;, which is akin to a interface, but may contain implementation.  Now an object can gain pieces of functionality, without having either a polluted hierarchy or a set of interfaces with repeat of the functionality throughout the code base.&lt;br /&gt;&lt;br /&gt;The only way to really accomplish this in Java was to use Aspects (which I do happen to like, for this very reason), but there are a variety of libraries to do this, all of which do it in their own way (AspectJ, AspectWerks, etc).&lt;br /&gt;&lt;br /&gt;Secondly, Scala provides the ability to create your own language features.  One of example of this (courtesy of &lt;a href="http://www.ibm.com/developerworks/java/library/j-scala03268.html?S_TACT=105AGX02&amp;amp;S_CMP=EDU"&gt;Ted Neward&lt;/a&gt;) is with exception handling:&lt;pre&gt;&lt;br /&gt;/ This is Scala&lt;br /&gt;object Application&lt;br /&gt;{&lt;br /&gt;def generateException()&lt;br /&gt;{&lt;br /&gt;  System.out.println("Generating exception...");&lt;br /&gt;  throw new Exception("Generated exception");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;def main(args : Array[String])&lt;br /&gt;{&lt;br /&gt;  tryWithLogging  // This is not part of the language&lt;br /&gt;  {&lt;br /&gt;    generateException&lt;br /&gt;  }&lt;br /&gt;  System.out.println("Exiting main()");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;def tryWithLogging (s: =&gt; Unit) {&lt;br /&gt;  try {&lt;br /&gt;    s&lt;br /&gt;  }&lt;br /&gt;  catch {&lt;br /&gt;    case ex: Exception =&gt;&lt;br /&gt;      // where would you like to log this?&lt;br /&gt;// I choose the console window, for now&lt;br /&gt;ex.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;printStackTrace&lt;/span&gt;()&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;We've actually created a function which takes a void function as it's argument.  Due to the way &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Scala&lt;/span&gt; allows us to call functions, it can look like a part of the language.  This is really powerful if you are in the business of creating Domain-Specific languages.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Difficult&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Again, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;Scala&lt;/span&gt; mixes object-oriented and functional paradigms.  The functional aspect has me in a bit of an intellectual twist.  I need to unwrap the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;OO&lt;/span&gt; part of my brain, and try and think like a functional coder.  I was halfway there when I was doing a lot of Javascript programming, however I was busy doing what everyone else was doing: enhancing what &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;OO&lt;/span&gt; capabilities are in the language.&lt;br /&gt;&lt;br /&gt;Functional programming is different, and takes a different mindset.  I'm doing some &lt;a href="http://www.cs.chalmers.se/%7Erjmh/Papers/whyfp.html"&gt;reading&lt;/a&gt; on the subject, but it's a struggle. I have to battle some long-set ideas in my own thinking.&lt;br /&gt;&lt;br /&gt;Still, there has been an interesting explosion in languages, and it's a rather exiting time to be a programmer.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-7173675508144553154?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/7173675508144553154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=7173675508144553154' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/7173675508144553154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/7173675508144553154'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2008/12/non-functional.html' title='Non-Functional'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-4025882425573699234</id><published>2008-12-06T16:45:00.004-06:00</published><updated>2008-12-06T16:50:59.080-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>New Domain</title><content type='html'>I've renamed this blog to Blasted Machine,as well as moving it to a custom domain.  Good ol' Google has made that remarkably simple (only $10 - it's almost an impulse buy).  Not sure what else will go under the Blasted Machine logo.  &lt;br /&gt;&lt;br /&gt;Heck, I even need to produce a logo, and a new template.  Best get crackin' with &lt;a href="http://www.inkscape.org/"&gt;Inkscape&lt;/a&gt;...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-4025882425573699234?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/4025882425573699234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=4025882425573699234' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/4025882425573699234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/4025882425573699234'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2008/12/new-domain.html' title='New Domain'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-5419770374343080394</id><published>2008-09-28T15:47:00.005-06:00</published><updated>2008-12-06T16:22:58.945-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Going Native: Structures and Callbacks</title><content type='html'>&lt;span style="font-style:italic;"&gt;This is a continuation of a simple overview of the &lt;a href="https://jna.dev.java.net/"&gt;Java Native Access (JNA)&lt;/a&gt; library.  In the first &lt;a href="http://schpatzdevelops.blogspot.com/2008/09/i-have-new-project-and-new-work-which.html"&gt;part&lt;/a&gt;, I looked at the basics of mapping native library functions, with simple types.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;JNA provides two key elements for the mapping Java to C libraries, namely structures and callbacks.  Structures are automatically mapped from the native values and may be used as a type-safe pointer to a instance of the structure.  Callbacks are provided via an extension of an interface, and the appropriate method is defined on the new interface. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Structures&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Mapping native &lt;code&gt;structs&lt;/code&gt; into Java classes is fairly simple via the  &lt;a href="https://jna.dev.java.net/javadoc/com/sun/jna/Structure.html"&gt;Structure&lt;/a&gt; class.  This class may be extended, and and any fields may be declared as public members of the new class.&lt;br /&gt;&lt;br /&gt;For example, let's take the following C struct&lt;pre&gt;&lt;br /&gt;  struct {&lt;br /&gt;     char* name;&lt;br /&gt;     int count;&lt;br /&gt;     char* desc;&lt;br /&gt;   } record;&lt;/pre&gt;&lt;br /&gt;and map it into Java&lt;pre&gt;&lt;br /&gt;  public class Record extends Structure {&lt;br /&gt;     public String name;&lt;br /&gt;     public int count;&lt;br /&gt;     public String desc;&lt;br /&gt;  }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Once we have our structure defined, we can now create mappings for functions which operate on the record struct.  In C:&lt;pre&gt;&lt;br /&gt;  int save(record* record);&lt;/pre&gt;&lt;br /&gt;and in our Java library interface:&lt;pre&gt;&lt;br /&gt;  public int save(Record record);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;What if we want to pass this struct into a function to be populated?  For example,&lt;pre&gt;&lt;br /&gt;  int load(record* record);&lt;br /&gt;&lt;br /&gt;  // and it's usage:&lt;br /&gt;  record r;&lt;br /&gt;  load(&amp;amp;r);&lt;br /&gt;  printf("record found: %s", r.name);&lt;/pre&gt;&lt;br /&gt;in which we load the record from a data store. We need a way, in Java, to pass this object to the native code, by reference.  Fortunately, JNA provides a simple way of doing this.&lt;pre&gt;&lt;br /&gt;  public class Record extends Structure {&lt;br /&gt;     public class ByReference extends Record implements Structure.ByReference {}&lt;br /&gt;     ...&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  // and it's usage:&lt;br /&gt;  Record.ByReference record = new Record.ByReference();&lt;br /&gt;  MyLibrary.INSTANCE.load(record);&lt;br /&gt;  System.out.println("record found: " + record.name);&lt;/pre&gt;&lt;br /&gt;This tag interface provides a very simple way of giving us this functionality. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Callbacks&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Callbacks are provided by the &lt;a href="https://jna.dev.java.net/javadoc/com/sun/jna/Callback.html"&gt;Callback&lt;/a&gt; interface.  By extending this interface we can add a method which will be used by the C library as the call back method. &lt;br /&gt;&lt;br /&gt;Let say we have a method in our C library which will notify the application if a record has been deleted by another process.   It provides us with a method to add a callback, &lt;pre&gt;&lt;br /&gt;  int register_delete_monitor( void* fn);&lt;/pre&gt;&lt;br /&gt;and the callback expected takes a parameter of a &lt;tt&gt;record&lt;/tt&gt;.&lt;br /&gt;&lt;br /&gt;In our Java library, we would create a &lt;tt&gt;Callback&lt;/tt&gt; for this method:&lt;pre&gt;&lt;br /&gt;  interface DeletedRecordCallback extends Callback {&lt;br /&gt;    void callback (Record r);&lt;br /&gt;  }&lt;br /&gt;  ...&lt;br /&gt;  // and in our Library Interface:&lt;br /&gt;  int register_delete_monitor (DeletedRecordCallback drc);&lt;/pre&gt; &lt;br /&gt;Now we can pass in an implementation of our &lt;tt&gt;DeletedRecordCallback&lt;/tt&gt; and have it registered as a callback in the C library. &lt;br /&gt;&lt;br /&gt;There are one caveat with the use of callbacks in JNA.  The callback must not be garbage collected unless it's been unregistered.  This is especially true for long lived callbacks.  A call to a garbage-collected callback will crash the vm.  This can be simply avoided by hanging on to the instance of the callback - a singleton will work quite well in this context.  Otherwise, it is important to have the callback instance deregister itself in it's &lt;tt&gt;finalize&lt;/tt&gt; method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Overall Impressions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Coupling the power of JNA's type mappings, with its structure mapping and callback access, it is a very useful library for taking the difficulty out of mapping native code to java.  It makes rapid development with existing native libraries much, much easier.  Java-to-native mapping has never been easier.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-5419770374343080394?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/5419770374343080394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=5419770374343080394' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/5419770374343080394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/5419770374343080394'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2008/09/going-native-structures-and-callbacks.html' title='Going Native: Structures and Callbacks'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-7485971948280039130</id><published>2008-09-18T22:23:00.007-06:00</published><updated>2008-09-28T16:30:57.382-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Going Native</title><content type='html'>I have a new project (and a new work) which involves starting and interacting with a python interpreter from the JVM.&lt;br /&gt;&lt;br /&gt;I did my requisite Google search.   At first, I thought I would do this using an existing library, &lt;a href="http://jpype.sourceforge.net/"&gt;JPype&lt;/a&gt;, but this works the other way around - the JVM is embedded in Python.   So I moved to the next option, JNI.  JNI is a pain in the ass, so after spending half a day trying to compile the generated stubs - not even talking to the Python C library, mind you - I decided to go back to Google.&lt;br /&gt;&lt;br /&gt;I thought that, perhaps, someone had written a way to generate JNI headers and native methods.  There are a few options out there, actually, but the one I settled on is &lt;a href="https://jna.dev.java.net/"&gt;JNA&lt;/a&gt;.  It's open source, cross-platform&lt;sup&gt;[1]&lt;/sup&gt;, and surprisingly easy to use.  An added benefit is that Timothy Wall, a major project contributor, is pretty responsive on the user mailing list.&lt;br /&gt;&lt;br /&gt;It's simple to use:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;package com.sun.jna.examples;&lt;br /&gt;&lt;br /&gt;import com.sun.jna.Library;&lt;br /&gt;import com.sun.jna.Native;&lt;br /&gt;import com.sun.jna.Platform;&lt;br /&gt;&lt;br /&gt;/** Simple example of native library declaration and usage. */&lt;br /&gt;public class HelloWorld {&lt;br /&gt;&lt;br /&gt;  public interface CLibrary extends Library {&lt;br /&gt;     CLibrary INSTANCE = (CLibrary)&lt;br /&gt;         Native.loadLibrary(&lt;br /&gt;            (Platform.isWindows() ? "msvcrt" : "c"),&lt;br /&gt;            CLibrary.class);&lt;br /&gt;&lt;br /&gt;     void printf(String format, Object... args);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public static void main(String[] args) {&lt;br /&gt;     CLibrary.INSTANCE.printf("Hello, World\n");&lt;br /&gt;     for (int i=0;i &amp;lt; args.length;i++) {&lt;br /&gt;          CLibrary.INSTANCE.printf(&lt;br /&gt;             "Argument %d: %s\n", i, args[i]);&lt;br /&gt;     }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;That's it.  You now have native access to &lt;code&gt;printf&lt;/code&gt;.  All of the native calls are handled through a proxy generated at run time.  You don't have to write all the methods in the library, either.  The resolution is done on the fly.  If you need to add another native call, simply add it to the interface.&lt;br /&gt;&lt;br /&gt;The library begins to get a little hairy when dealing with pointers and references. For the most part, pointers are handled for you (it's Java, every things a pointer).  But what about primitives, you ask?  JNA solves this through a nice set of &lt;a href="https://jna.dev.java.net/javadoc/com/sun/jna/Pointer.html"&gt;Pointer&lt;/a&gt; and &lt;a href="https://jna.dev.java.net/javadoc/com/sun/jna/ptr/package-summary.html"&gt;PointerType&lt;/a&gt; classes.&lt;br /&gt;&lt;br /&gt;So now if you have a C function like the following:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; void setSomeValue(int* retValue)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;you can map it via the following:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; public interface MyNativeLibrary extends Library {&lt;br /&gt;    ...&lt;br /&gt;&lt;br /&gt;    public void setSomeValue(IntByRefrence retValue);&lt;br /&gt;&lt;br /&gt;    ...&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In Java, we can now call the method like so:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; IntByReference retValue = new IntByReference();&lt;br /&gt; MyNativeLibrary.INSTANCE.setSomeValue(retValue);&lt;br /&gt; System.out.println("retValue = " + retValue.getValue());&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There is also a &lt;a href="https://jna.dev.java.net/javadoc/com/sun/jna/ptr/PointerByReference.html"&gt;PointerByReference&lt;/a&gt;, which can be used to do the same thing with pointer-based arrays, or String values.&lt;br /&gt;&lt;br /&gt;Structures and callbacks are also very simple to map. I'll take a look at these in a followup post.&lt;br /&gt;&lt;br /&gt;I don't know why anyone would write JNI anymore&lt;sup&gt;[2]&lt;/sup&gt;.  This library has made access to native code amazingly simple, and surprisingly intuitive.  I would would highly recommend it to anyone who is avoiding a solution, simply because they don't want to make native calls.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;[1] Linux, Mac OS X, and Windows, for now.&lt;br /&gt;&lt;br /&gt;[2] Ok, there is some overhead, but through clever caching of the function pointers, it's pretty fast.  I'll have to find some numbers on it.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-7485971948280039130?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/7485971948280039130/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=7485971948280039130' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/7485971948280039130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/7485971948280039130'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2008/09/i-have-new-project-and-new-work-which.html' title='Going Native'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-2395661234424738734</id><published>2008-04-07T15:20:00.002-06:00</published><updated>2008-05-26T19:14:08.565-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Simple SAX</title><content type='html'>Greg Reimer has put together a very nice &lt;a href="http://blogs.sun.com/greimer/entry/a_sax_parser_built_on"&gt;SAX parser&lt;/a&gt; in JavaScript.  While it's preliminary, it certainly could add a much-improved way of dealing with XML. &lt;br /&gt;&lt;br /&gt;There are certainly times when SAX parsing is a much better choice for parsing.  I'm curious to see if someone expands on this idea, as well as makes some more thorough performance measurements of this implementation.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;(via &lt;a href="http://ajaxian.com/archives/javascript-sax-based-parser"&gt;Ajaxian&lt;/a&gt;)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-2395661234424738734?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/2395661234424738734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=2395661234424738734' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/2395661234424738734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/2395661234424738734'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2008/04/simple-sax.html' title='Simple SAX'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-8038737457216205040</id><published>2007-11-17T14:22:00.000-06:00</published><updated>2007-11-17T14:31:39.053-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OS'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Mobile'/><title type='text'>Another Hearder of Electric Sheep</title><content type='html'>Once more there's a new library for writing applications on small devices.  &lt;a href="http://code.google.com/android/index.html"&gt;Android&lt;/a&gt;, from Google and the &lt;a href="http://www.openhandsetalliance.com/"&gt;Open Handset Alliance&lt;/a&gt;, is a new OS and SDK for mobile devices (primarily for phones, by the look of the emulator).&lt;br /&gt;&lt;br /&gt;It looks like it's built on a small Linux kernel, but, more importantly, all the functionality is accessible from a fairly full featured Java API.  Depending on it's adoption, it could be a pretty serious contender for both J2ME, as well as BREW (mostly on Verizon devices).&lt;br /&gt;&lt;br /&gt;Going forward, it might be useful to have a port of the J2ME application libraries to Android, in order to transition existing mobile apps.  A good idea for a some enterprising&lt;sup&gt;[1]&lt;/sup&gt; open-source developers...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;[1] Wait, are open-source developers "enterprising"?  Or is the sharing of the application and source code more of an artistic action?  Perhaps a philosophical discussion will have to be made. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-8038737457216205040?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/8038737457216205040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=8038737457216205040' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/8038737457216205040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/8038737457216205040'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2007/11/another-hearder-of-electric-sheep.html' title='Another Hearder of Electric Sheep'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-8721581618496944463</id><published>2007-08-15T08:58:00.000-06:00</published><updated>2007-09-09T12:12:57.850-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><title type='text'>Definitions for the Lazy</title><content type='html'>&lt;a href="http://peter.michaux.ca/article/3556"&gt;This&lt;/a&gt; is bloody interesting (via &lt;a href="http://ajaxian.com/archives/lazy-function-definition-pattern"&gt;Ajaxian&lt;/a&gt;).  It involves creating functions at call time, where some expensive initial operation us computed and placed in a new function, which is then used to replace the original one. &lt;br /&gt;&lt;br /&gt;For example, &lt;br /&gt;&lt;block&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;function MyObject() {&lt;br /&gt;    this.someFunction = function(x) {&lt;br /&gt;        var a = someComplexCalculation();&lt;br /&gt;        this.someFunction = function(y) {&lt;br /&gt;            return a + y;&lt;br /&gt;        };&lt;br /&gt;        return this.someFunction(x);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/block&gt;&lt;br /&gt;&lt;br /&gt;Pretty sweet.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-8721581618496944463?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/8721581618496944463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=8721581618496944463' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/8721581618496944463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/8721581618496944463'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2007/08/this-is-bloody-interesting-via-ajaxian.html' title='Definitions for the Lazy'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-7116131062877370526</id><published>2007-06-27T09:05:00.001-06:00</published><updated>2008-09-28T16:32:39.220-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Wrting'/><category scheme='http://www.blogger.com/atom/ns#' term='General'/><title type='text'>Writing (About) Development</title><content type='html'>&lt;a href="http://www.medill.northwestern.edu/medill/admissions/programmers.html"&gt;This&lt;/a&gt; would be interesting for programmers.  It's a journalism program through Northwestern's Medill School.   Its designed around creating better technical journalists from technically minded people.&lt;br /&gt;&lt;br /&gt;I think there is a certain about a of merit to creating a pool of developers who can communicate about technology in and around their particular disciplines. Communication not only helps people understand what is going on in software, but it also helps alleviate fears from new technologies.&lt;br /&gt;&lt;br /&gt;One thing that seems to be on the decline is strong science and technology reporting.  Things are usually over-reported or over blown. One might wonder if the whole of the Y2K scare was as a result of poor technology reporting.&lt;br /&gt;&lt;br /&gt;This same poor understanding and fear of technology inspires such works as &lt;a href="http://www.amazon.com/Cult-Amateur-Internet-killing-culture/dp/0385520808/ref=pd_bbs_sr_1/105-9944703-8645240?ie=UTF8&amp;amp;s=books&amp;amp;qid=1184279798&amp;amp;sr=1-1"&gt;Cult of the Amateur: How Today's Internet is Killing Our Culture&lt;/a&gt;&lt;sup&gt;[1]&lt;/sup&gt;.  It's premise is that sources become untrustworthy, as the ability to disseminate information essentially becomes free (via blogs, MySpace, etcetera).  This undermines traditional media, which is supposedly superior through editors, publishers, marketing professions - the whole of the industry. He (at least according to critics) widely misses the mark in proving his case.&lt;br /&gt;&lt;br /&gt;(I'm not saying that these are now unnecessary.  A good editor is certainly a great value. I, for one, would like a little editorial review now and then.  It would keep me from saying some of the ridiculously stupid things that happen to fall out on my keyboard - like this aside, for example).&lt;br /&gt;&lt;br /&gt;I tend to view the current state of user-driven content (and by these, I mean blogs) as similar to the early days of the printing press.  Widely available and affordable print media helped to disseminate new and powerful ideas - the Reformation, for example.  The changes that came with print media brought with it an equal set of drivel and highly untrustworthy reporting - political reporting has been a biased and bile-filled subsection of the media from day.  The market of readers helped to drive the quality of the publications.&lt;br /&gt;&lt;br /&gt;Returning to the Medill program, it could help to further bridge the gap of technology savvy with excellent reporting.  Trustworthy sources become so through good journalism. &lt;br /&gt;&lt;br /&gt;[1] See &lt;a href="http://www.boingboing.net/2007/07/09/shirky_explains_why_.html"&gt;this&lt;/a&gt; for a response.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-7116131062877370526?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/7116131062877370526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=7116131062877370526' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/7116131062877370526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/7116131062877370526'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2007/06/writing-about-development.html' title='Writing (About) Development'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-7272629912842338579</id><published>2007-05-06T13:19:00.002-06:00</published><updated>2008-09-28T16:31:48.576-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hardware'/><title type='text'>No Such Luck</title><content type='html'>&lt;div style="float: right; margin-left: 10px; margin-bottom: 10px;"&gt; &lt;a href="http://www.flickr.com/photos/pschwarz/479115811/" title="photo sharing"&gt;&lt;img src="http://farm1.static.flickr.com/211/479115811_dff771deea_m.jpg" alt="" style="border: 2px solid rgb(0, 0, 0);" /&gt;&lt;/a&gt;&lt;/div&gt;I picked up the tools I needed to try and perform a little clean up of the teriyaki spill that has taken down my PowerBook.  Opening up the laptop was really straight forward once I had the (ridiculously small) Torx T6 screwdriver.&lt;br /&gt;&lt;br /&gt;Alas, all this was to no avail.&lt;br /&gt;&lt;br /&gt;My plan had been to crack it open, spray some contact cleaner onto the now-encrusted teriyaki.  Following the instructions from iFixit.com, I was able to open the laptop with much trouble.  These instructions were for the model previous to the one that I own.  This turns out to differ slightly from the latest model&lt;sup&gt;[1]&lt;/sup&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div style="float: left; margin-right: 10px; margin-bottom: 10px;"&gt; &lt;a href="http://www.flickr.com/photos/pschwarz/479116469/" title="photo sharing"&gt;&lt;img src="http://farm1.static.flickr.com/213/479116469_a120ee8e0f_m.jpg" alt="" style="border: 2px solid rgb(0, 0, 0);" /&gt;&lt;/a&gt;&lt;/div&gt;There are a few extra screws that hide underneath the right side speaker.  Not being aware of these, I tugged on the logic board a few times before poking around a bit more for those extra couple of screws.  It could be one more cause for the permanent damage to the unit.&lt;br /&gt;&lt;br /&gt;Getting the logic board out is a bit of a trick.  It has to be angled just right (about 45 degrees) to pull it out.  There's a little hook shaped bracket that sits over the board just to the left of the DVI connector.  This is what one has to work around.  This is another place where there might have been a little jostling on my part.&lt;br /&gt;&lt;br /&gt;&lt;div style="float: right; margin-left: 10px; margin-bottom: 10px;"&gt; &lt;a href="http://www.flickr.com/photos/pschwarz/479101066/" title="photo sharing"&gt;&lt;img src="http://farm1.static.flickr.com/198/479101066_2710191a2f_m.jpg" alt="" style="border: 2px solid rgb(0, 0, 0);" /&gt;&lt;/a&gt;&lt;/div&gt;Looking over the board, it really looks like it was hardly touched by the teriyaki invasion.  Mostly, the sauce pooled in the bottom corners, around the power connector, and a little by the DVI connector.  Spraying the contact cleaner in those places seemed to clean away most of the mess.  It was a bit difficult, however, as there was a considerable number of sesame seeds&lt;sup&gt;[2]&lt;/sup&gt; that got stuck in the power connector.&lt;br /&gt;&lt;br /&gt;Putting it all back together was just a matter of reversing the process (as usual).  I missed a connector or two  along the way but, after a few attempts to power it up, I figured out where all the pieces go.&lt;br /&gt;&lt;br /&gt;I pressed that button, that pretty silver button, and nothing.&lt;br /&gt;&lt;br /&gt;All that was left was to rifle through its pockets and look for loose change.  I pulled out all the useful bits and pieces - hard drive, optical drive, and the memory.  I'll have to see if I can part the thing out on Ebay.&lt;br /&gt;&lt;br /&gt;This isn't exactly a Bad Thing, of course.  I'll have to get a shiny, new MacBook.  The G4 was starting to show its age and those Core Duos are speedy.&lt;br /&gt;&lt;br /&gt;Only, I'll have to wait until October.  Stupid Leopard delays.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;[1] And by the latest model, I mean the last model of PowerBooks.  This is before the switch to the MacBook/Intel line of laptops.&lt;br /&gt;&lt;br /&gt;[2] It's a really tasty sauce, Veri-Veri Teriyaki by &lt;a href="http://www.soyvay.com/"&gt;Soy-Vey&lt;/a&gt;.  I recommend using it on a nice piece of salmon - marinate the salmon for at least a half hour, broil it for ten to twelve minutes, and enjoy.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-7272629912842338579?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/7272629912842338579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=7272629912842338579' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/7272629912842338579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/7272629912842338579'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2007/05/no-such-luck.html' title='No Such Luck'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm1.static.flickr.com/211/479115811_dff771deea_t.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-6963053530012677855</id><published>2007-04-18T16:07:00.000-06:00</published><updated>2007-04-18T17:41:21.551-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Disaster'/><category scheme='http://www.blogger.com/atom/ns#' term='Hardware'/><title type='text'>PowerBook Down</title><content type='html'>I had an unfortunate incident with my PowerBook last week.  It's been potentially brought to its knees.  Was it a problem with the battery, a virus, chimpanzees slapping the keyboard like a bongo?&lt;br /&gt;&lt;br /&gt;No, it was teriyaki.&lt;br /&gt;&lt;br /&gt;My lunch, in my wonderful courier bag&lt;sup&gt;[1]&lt;/sup&gt;, was not sealed.  As a result, teriyaki spilled and pooled in the bottom of said bag.  Not having ordered the one with the special laptop pouch&lt;sup&gt;[2]&lt;/sup&gt;, it pooled into the back of my laptop.&lt;br /&gt;&lt;br /&gt;Now, the "geniuses" at the local Apple store opened it up (for 89 bucks!) and told me that it would be 1200 simoleons to replace the logic board. First off, I might as well buy a new laptop (probably their strategy), second off, who the hell still calls it a "logic board" anyway.&lt;br /&gt;&lt;br /&gt;I thought about this for all of thirty seconds and decided I would at least crack the thing open myself and try to clean it.  With a torx driver in hand, some electrical contact cleaner and instructions from &lt;a href="http://www.ifixit.com/"&gt;iFixit&lt;/a&gt;, I'm going to embark on my attempt to fix the laptop.&lt;br /&gt;&lt;br /&gt;Pictures and discussion to follow.&lt;br /&gt;&lt;br /&gt;...wish me luck.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;[1]And, yes, on the rare occasion that I ride my bike, it actually is used for its purpose.&lt;br /&gt;&lt;br /&gt;[2] &lt;a href="http://www.timbuk2.com/"&gt;Timbuk2&lt;/a&gt; bags are great, but not compartmentalized enough for the prevention of liquid mishaps.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-6963053530012677855?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/6963053530012677855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=6963053530012677855' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/6963053530012677855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/6963053530012677855'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2007/04/powerbook-down.html' title='PowerBook Down'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-3518124569964589065</id><published>2007-03-06T13:35:00.000-06:00</published><updated>2007-03-06T13:38:50.058-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Perceivably Slow</title><content type='html'>I installed the new version of the Java SDK, 1.6 (Mustang), at work recently and was surprised by the performance change.  Looking at David Dagastine's &lt;a href="http://blogs.sun.com/dagastine/entry/java_6_leads_out_of"&gt;discussion&lt;/a&gt; on of JDK performance, one would think that performance should and would be better.&lt;br /&gt;&lt;br /&gt;I was grossly underwhelmed.&lt;br /&gt;&lt;br /&gt;After installing the new SDK, I ran an install of Tomcat 5.5.  My server start-up times were running between 5 and 9 seconds.  Given that I  start and stop the server many times in an hour[1], I really thought it would be great to reduce this time.  The startup time with Mustang jumped to between 25 and 35 seconds.&lt;br /&gt;&lt;br /&gt;Once it had started up, the performance seemed comparable to the 1.5 VM (if not better - I'm sure that it's here where Dagastine's numbers are accurate).  That start up time is, however, miserable.  It effects the &lt;a href="http://en.wikipedia.org/wiki/Perceived_performance"&gt;perceived performance&lt;/a&gt; of the whole experience[2]. &lt;br /&gt;&lt;br /&gt;This startup performance force the designers of applications to add little things to their applications, like splash screens, startup info, etc.  This will increase the perceived performance of the application by giving the illusion of things happening.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[1] This is due to the fact the file I'm using is loaded through a servlet.  Due to the way that ClassLoader.getResourceAsStream() loads the stream into memory.  Only restarting the VM allows me to reload the changes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-3518124569964589065?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/3518124569964589065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=3518124569964589065' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/3518124569964589065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/3518124569964589065'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2007/02/perceivably-slow.html' title='Perceivably Slow'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-3774339747273157707</id><published>2007-02-27T21:56:00.000-06:00</published><updated>2007-03-06T13:10:11.998-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OS'/><category scheme='http://www.blogger.com/atom/ns#' term='&quot;Mac OS X&quot;'/><title type='text'>Mac on Your PC</title><content type='html'>It's one of those things that a few of us in the PC world have wanted for a while: Mac OS X on our own Intel hardware.  Build the machine and put whatever OS on it we wanted. What would be better than a very user-friendly UNIX variant?&lt;br /&gt;&lt;br /&gt;Beginning with a leaked &lt;a href="http://www.vmware.com/"&gt;VMWare&lt;/a&gt; build and followed by some brilliant hacking with the &lt;a href="http://www.opensource.apple.com/darwinsource/"&gt;Darwin kernel&lt;/a&gt; (the open-source core of OS X), this is now possible - albeit not entirely legally.&lt;br /&gt;&lt;br /&gt;From what I've, err, read (right, that's it), Osx86 (as it's commonly know as) has actually reached a rather stable state.  It even runs reasonably well on AMD hardware. Sure the project has a few instabilities (crashes when entering sleep mode), but it's come a long way considering it's a clever port of an closed system.   Current working versions are 10.4.8, and there are experiments in progress for the latest Leopard (10.5) builds.&lt;br /&gt;&lt;br /&gt;The Osx86 community has even put together a cobbled series of drivers for most commonly used hardware.  Patched together in an hacked Mac install disk, it's possible with access to BitTorrent to try it at home.&lt;br /&gt;&lt;br /&gt;For those who are interested in spending a little time tweaking, it's a surprisingly easy way to try before you buy.  A great site for information is &lt;a href="http://www.insanelymac.com/"&gt;Insanely Mac&lt;/a&gt; with numerous forums, or it's older &lt;a href="http://wiki.osx86project.org/wiki/index.php/Main_Page"&gt;Wiki&lt;/a&gt; site.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-3774339747273157707?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/3774339747273157707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=3774339747273157707' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/3774339747273157707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/3774339747273157707'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2007/02/mac-on-your-pc.html' title='Mac on Your PC'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-1309803412379274028</id><published>2007-02-09T09:54:00.000-06:00</published><updated>2007-02-09T15:19:52.230-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><title type='text'>For-In Issues</title><content type='html'>I came across a little idiosyncrasy yesterday in JavaScript.  Perhaps it still shows my ignorance to the nuances of the language, but I hadn't really thought about.&lt;br /&gt;&lt;br /&gt;Until I got bit by it.&lt;br /&gt;&lt;br /&gt;Look at the following snipit:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;var listOfValues = new Array(1, 2, 3, 4, 5);&lt;br /&gt;for(var x in listOfValues) {&lt;br /&gt;   doTheThingWithTheDeal(x);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/blockquote&gt;It seems simple and straight forward enough.  Handy to use to:  add some elements to an array and then use a language-level feature to evaluate them.  Heck, it so useful they put it into &lt;a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html"&gt;Java&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;That's great, but like Java, developers don't always want to be re-inventing the wheel with every application.  Still not a problem when one is writing their own libraries.  There are, however, a dearth of libraries available for use these days. With the rise of AJAX, we have people building fancy libraries to ease cross-browser development.&lt;br /&gt;&lt;br /&gt;One of the most commonly used libraries is the &lt;a href="http://www.prototypejs.org/"&gt;Prototype&lt;/a&gt; library.  This library provides a number of structures to improve and ease the coding of OO JavaScript.  It also extends some of the native JavaScript objects, in order to add some nice methods which the developers of Prototype thought where missing from the implementation.&lt;br /&gt;&lt;br /&gt;This is where we start to run into trouble.  Array is one of these objects that is&lt;br /&gt;modified with all sorts of convenient methods like &lt;code&gt;indexOf&lt;/code&gt;, &lt;code&gt;first&lt;/code&gt;, and &lt;code&gt;each&lt;/code&gt;.  This brings us back to that code snippet.  If we now iterate over that array in the example not only will we &lt;code&gt;doTheThingWithTheDeal&lt;/code&gt; on the integers in the array, but we'll also &lt;code&gt;doTheThingWithTheDeal&lt;/code&gt; on all of those handy-dandy new array methods.&lt;br /&gt;&lt;br /&gt;Prototype's (as well as any other library developer who modifies the native objects) response is to not use the for-in control.  I would argue that this is a poor extension, since it forces project developers to change their own code.  Some structures may rely on this control structure (hence why I'm writing about this). &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Why Does It Fail (and what to do about it)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The reason this failure happens is that the properties of all JavaScript objects have attributes.  These attributes consist of &lt;code&gt;ReadOnly&lt;/code&gt;, &lt;code&gt;DontEnum&lt;/code&gt;, &lt;code&gt;DontDelete&lt;/code&gt;[1].  The attributes are only available for modification inside the script engine (see the &lt;a href="http://www.mozilla.org/rhino/"&gt;Rhino&lt;/a&gt; JS engine, for example). &lt;br /&gt;&lt;br /&gt;&lt;code&gt;DontEnum&lt;/code&gt; is the attribute that controls whether or not the property shows up during the execution of a for-in structure.  For-in operates over all properties of an object. For arrays, this includes the indexed properties, as well as the named properties (In fact, this is true of all objects in JavaScript, due to the languages syntax).&lt;br /&gt;&lt;br /&gt;Current implementation of the language doesn't allow this to be modified by users. &lt;br /&gt;&lt;br /&gt;Looking at the &lt;a href="http://www.mozilla.org/js/language/js20/"&gt;future&lt;/a&gt; of JavaScript, keywords may be added in order to modify the enumerability of properties.  Until then, we'll have to either modify our code to work with Prototype, or use libraries that don't extend the native objects. &lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;[1] See the &lt;a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm"&gt;ECMAScript Spec&lt;/a&gt; for more information on these attributes.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-1309803412379274028?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/1309803412379274028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=1309803412379274028' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/1309803412379274028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/1309803412379274028'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2007/02/for-in-issues.html' title='For-In Issues'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1831008827141976577.post-2930613934572613756</id><published>2007-01-21T13:17:00.000-06:00</published><updated>2007-01-21T13:32:51.238-06:00</updated><title type='text'>Member of the Ranks</title><content type='html'>I've been writing blogs for a while now&lt;sup&gt;[1]&lt;/sup&gt;, but I have yet to enter the field of technology bloggers.&lt;br /&gt;&lt;br /&gt;Write what you know, they say.&lt;br /&gt;&lt;br /&gt;Well, actually, I plan to use this blog for writing about learning technology I don't know very well.  I'm a Java Developer by trade, dealing mostly with J2EE, and mobile Java.  I've dabbled a bit with web development (AJAX being the latest bit of technology).  Here, though, I'll stick  to writing about subjects I'm learning. &lt;br /&gt;&lt;br /&gt;I have quite a list of things that have begun to capture my fancy.  I'm interested in learning some Mac OS programming.  This may include things such as Cocoa, ObjectiveC, Dashboard widgets, and Java bindings for libraries. &lt;br /&gt;&lt;br /&gt;There are also system related things: trying out Linux distributions, like &lt;a href="http://www.xubuntu.org/"&gt;Xubuntu&lt;/a&gt; for example.  I'm in the process of setting up an iMac as an HTPC which, so far, has been worked out pretty well.  I might need to make some tweaks which I'm certain I'll post about.&lt;br /&gt;&lt;br /&gt;So here I am, in the ranks of technology bloggers.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;[1] &lt;a href="http://schpatz.blogspot.com/"&gt;Schpatz Lager&lt;/a&gt; for essays, &lt;a href="http://cityofvagabonds.blogspot.com/"&gt;Vagabond Tango&lt;/a&gt; for travel and tango, and &lt;a href="http://ninetyminuteshorts.blogspot.com/"&gt;Ninety-Minute Shorts&lt;/a&gt;&lt;/span&gt; for fiction.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1831008827141976577-2930613934572613756?l=blog.blastedmachine.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.blastedmachine.com/feeds/2930613934572613756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1831008827141976577&amp;postID=2930613934572613756' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/2930613934572613756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1831008827141976577/posts/default/2930613934572613756'/><link rel='alternate' type='text/html' href='http://blog.blastedmachine.com/2007/01/member-of-ranks.html' title='Member of the Ranks'/><author><name>Peter Schwarz</name><uri>http://www.blogger.com/profile/00388942456325359221</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/img/217/4348/320/IMG_0349.jpg'/></author><thr:total>1</thr:total></entry></feed>
