New Location

My website has moved to http://www.jasonwhaley.com. Please visit there for the latest and only remain here for legacy content.

Monday, November 23, 2009

compgen -c

Bash has a built-in called compgen that is responsible for tab completion when using the bash shell. compgen has some nifty arguments you can use. For instance, to get all of the executables on your path sent to stdout, it's just a matter of running
compgen -c [$beginningCharacters]
This is useful in cases where you need to programmatically see what executables are available in $PATH. For instance, if you remember part of the name of an executable, but not what characters the executable begins with, you can pipe compgen -c out and grep for a string you know exists.

Nifty stuff.

Wednesday, November 11, 2009

But... why ruby?

"One Language A Year" - or at least that's what the Programmatic Programmer reckons one should do. I've spent the majority of this year doing non development work. For any coding work I have done, I've gone back to my workhorses of bash, java, and python. This effectively means that in the three years I've worked as a software engineer (or similar) I've remained a three-trick pony. Although with that said, if I decided to actually go learn C++, I would know the gamut of the predominant languages used within Google, so I'm not fairing too badly.

Still, learning a language teaches one new idioms, new ways of solving problems, and increasing the toolset available with which to solve problems. For those reasons I'm going to allow myself to pick up another language. However since there is only two months left in this year and I'm super busy with non development work, I'm not going to learn a full language and become somewhat familiar with its accompanying sets of frameworks, libraries, and APIs in two months. Instead, I'm going to take a minimalist approach and take a one day at a time shot at learning ruby. I'll be spending a single solitary hour on hacking ruby code each working day. Doing that from now until the end of the year should possibly teach me enough of the language to claim I know it on the surface and will let me know whether or not I want to continue with it in 2010.

But... why ruby?

  1. Everyone who I know that has picked up ruby has only good things to say about the language and API. I'm not counting rails here... just ruby the language.
  2. It looks more flexible than my current dynamic language of choice, python. For example, one sees tons of material about writing DSLs in ruby. For all of python's goodness, it doesn't feel like a good language to facilitate writing DSL's. I welcome any objections to that assertion, of course.
  3. The ruby developer community where I live is strong. Hashrocket, a pretty well known ruby (on rails) shop is a 7 minute bike ride away. There's nothing better than sharing with and learning from a kick ass group of tightly knit developers.
  4. I want something that isn't tied to JVM. I could have cheated with my selection and chosen something like Groovy or Scala, but I want something completely different. Scala is interesting and there are some neat functional idioms and concurrency support features intrinsic to the language that would be useful, but I'll save it until next year. For now I want to see what world is like outside of java land.
Of course, one needs a non-trivial project in order to pickup a language and its platform. I learned java pretty much by attempting to hack on the Netflix Prize as part of my Master's thesis. It's a fun problem and will probably allow me to flex a majority of ruby features in attempting to solve it again.

Day one was yesterday. I spent the first 25 minutes going through the Ruby in 20 Minutes tutorial (yeah... I'm slow) and the next 35 minutes starting to write a module/class to read in comma delimited files from the Netflix Prize dataset that identify a user id, rating, and timestamp for all ratings on a given movie.

In doing so, I managed to explore the following basics in Ruby

  • File I/O (or at least reading files)
  • The CSV module
  • Iteration
  • Attributes
My initial first thoughts?

  • irb is a pretty neat interpreter. I'm a huge fan of the interactive python interpreter (and even bigger fan of bpython). The only thing missing here is the ability to see rdoc from irb - probably due to the fact that rdoc isn't stored as a member of any modules or classes the way that docstrings are in python (and accessible via .__doc__)
  • Attributes are awesome way to remove boilerplate property code. It just reduces the noise of having tons of getX() and setX(Object x) implementations and calls to access the internal members of objects in Java.
  • Reading in a file in ruby was just as easy and straightforward in ruby as in python. That's always a joy.
  • The shorthand iteration of an enumeration threw me at first, but perhaps it's just a rubyism that will grow on me as I find out how to use it effectively.
    file.each { |line| extract_rating_from_line } 
    just didn't seem quickly intuitive the way that an equivalent list comprehension in python would
    [extract_rating_from_line(line) for line in file.readlines()]
    or perhaps I'm just too used to python at this point.

Hopefully after this evening I'll have at least a working module and some classes for parsing ratings from those text files and get to explore some things like exception handling.

Sunday, November 8, 2009

iDon't Have Market Penetration

iDon't have a real keyboard.
iDon't run simultaneous apps.
iDon't take 5-megapixel pictures.
iDon't customize.
iDon't run widgets.
iDon't allow open development.
iDon't take pictures in the ark.
iDon't have interchangeable batteries.

Too bad Verizon forgot to mention this other truth about the iPhone:

iDo have massive market penetration.

Last week Verizon released the Motorola Droid as its latest smartphone offering. Quite honestly, it is the first smart phone Verizon has supported that is mildly appealing. As a former Verizon customer, the lack of decent phones was my biggest complaint and ultimately led to my departure as a Verizon customer.

I really like Android though, from what I've seen of it at least. Had Verizon announced plans to support an Android phone around the beginning of this year, I would have stuck around. I love Verizon's network and service. But I needed a smart phone worth a darn to support me in my budding freelance career.

What did I switch to? Why of course, I switched to an iPhone.

Already being a Mac OSX user, I figured I put away any reservations I had about the iPhone and AT&T and just get an iPhone. I have not regretted it. I love everything about the phone basically. And mind you I'm not even running a jailbroken phone - I like the base user experience and apps in the app store as they are. AT&T has had great coverage here in Northeast Florida so I can't even complain about them yet either.

But that's now. In my honest estimation, I expect Android to really be an awesome platform now and later. I admittedly also have a soft spot for Verizon's service - they have had great coverage every where I've ever lived or visited in the continental United States. But I'm not switching now... Verizon was too late.

What would it take for me to switch? I'm guessing it would probably take what every other iPhone owner on AT&T's network would require to take the risk of jumping to another phone platform and carrier - it would take Verizon offering some type of credit to iPhone customers canceling their AT&T contract early to cover the switching costs. For all of the things that Droid can apparently do better, the one thing it doesn't have right now is the user base and appeal that the iPhone has. It won't get those two things either unless it does something to woo those iPhone users away. It's going to be those users raving about how Droid is better than the iPhone (assuming it truly is), not Verizon's ads, that draw the masses to Droid.