Archive for the 'Coding' Category

Flash in the pan

It’s been a while. :) So, I ended up buying a Mac Mini, and last week I upgraded the RAM to 2 gigs so I’m sitting pretty well right now. (With the original 512 megs the Mini had at first, things were dog slow, especially when I tried to run Photoshop or InDesign. But now it’s quite fast. I am happy. :))

In other news, at work I’ve been coding a board game in Flash. It’s effectively my first Flash project ever (years and years ago I edited a company map in Flash, but it was so long ago that I can hardly remember it, and I was only maintaining it, so it doesn’t really count). Flash is smooth. I’m not completely satisfied with ActionScript, but it certainly works well enough, and I’m sure more experience with it will make it better. Overall, my time with Flash has been good and fun.

Finally, I’m hoping to get back into more Ruby/Python/Perl coding before too long. My new job’ll require some XML magic, for which I’ll probably use Python and XSLT. And in my typographical work on the side I’ll be doing a lot with TeX and either Ruby or Python.

All of which is to say, hopefully I’ll start blogging here more often. :)

A short update

I’m not doing so hot at updating this blog regularly, am I. :) School’s keeping me busy (seems like I say that a lot) but I’ll try to figure out a focus, something that’ll get me writing. (And be interesting to read.)

In the meantime, I think I want to master regular expressions next. I’m familiar with them and have used them often, but there’s a lot of power in them there regexes. In other news, I’ll be coding a family website in Rails over the next few months. It’ll be a good testing ground for my Beyond work. And at work, it looks like this web app I’m working on will be almost all Javascript. Not what I expected, but I’d much rather work in Javascript than ASP.NET. :)

Goodbye, OpenLaszlo

After a month of OpenLaszlo, I’ve had enough. Coding in XML just isn’t my style, I’m afraid. (And yes, I know you do half the coding in JavaScript, but that doesn’t change anything.) I don’t think that means XML-based programming languages are inferior or anything like that — if I spent more time wrapping my head around OpenLaszlo, I could probably feel better about it (or I’d have one heck of a sore head). But I don’t have that kind of time. Nor was I getting enough of a “coolness” factor, the way I do when I work with Lisp. This experiment leads me to suspect that I probably wouldn’t like Flex much, either.

So, I’m going back to the basics. Simplicity is good, and so I’ve taken the app I’m working on and pared it down as far as possible. So far, in fact, that I’m pretty sure I’ll be able to do the whole thing with Javascript, HTML, and CSS, with a web service providing a connection to the server (written in ASP.NET most likely, though I’d prefer Python and may end up going that route), and anything else in Python. I might use MochiKit or Dojo to make the Javascript end easier to code, but I’m not sure yet if I really need it. (Why not Rails? Well, the server is unfortunately a Windows box running IIS, and I’ve heard that Rails doesn’t perform all that well on IIS. I wish I could get the server moved to Linux, but that’s probably not going to happen anytime soon. In the meantime, Python is still very nice to work with, and I haven’t caught wind of any performance issues with it on IIS.)

At any rate, this stack feels a lot better. When I was working with OpenLaszlo, I felt like I was in a straitjacket. Not much fun. Or “open.” (Again, keep in mind that these are subjective impressions; who knows, maybe OpenLaszlo is your style.)

In the meantime, I’m reading Paul Graham’s ANSI Common Lisp and liking it.

OpenLaszlo

I’ve been tinkering around a bit with OpenLaszlo, since here at work I’m about to start writing an RIA for doing online extraction of genealogical records, and it would be really nice not to have to re-invent the wheel. :) The advantages of OpenLaszlo are that it’s free, it compiles to Flash (which is on pretty much every computer out there) and soon DHTML, and it looks like it’s conducive to fast development. And there are a lot of high-profile apps using it (like Pandora).

So I spent half an hour throwing together a quick prototype of our app — no functionality, just the layout — and I think I’m liking it. It’s basically XML with a healthy dose of Javascript. Using XML this way feels almost like Lisp somehow, incidentally. :) So far I haven’t run into any huge roadblocks, so we’ll see if OpenLaszlo works for what I need.

A handful of thoughts

Some thoughts that have been going through my mind lately…

In writing software, it seems like there are two distinct creative philosophies: planned vs. organic. With the first, you blueprint the whole project out in advance, thinking through everything as much as possible, sketching out the program with broad strokes first. You then go through the blueprint and implement it. The second philosophy takes a more laid-back approach, starting with the bare minimum and then letting the needs of the users define the design. It’s an iterative process, something more grown than engineered.

As is often the case in life, both of these methods have their place. For me, the general flow of a project should be organic (if possible), but the details should be planned. Let me explain.

When writing software, you often don’t know what’s best for the user. You have ideas, sure, but you don’t know for certain. Rather than bloat the software up with unnecessary features, it’s better to let the project’s requirements evolve as you proceed. Experience will dictate the course.

Down in the trenches, however, it helps a lot to have a plan. Not a long-term plan, mind you, but a right-here-and-now list of what needs to happen in the next hour or day. Yes, I can code without a plan, but my thinking gets murky and there’s only so much state you can hold in your mind before you start to lose things. Writing out a list of to-do items, along with pseudocode for whatever it is I’m working on, has proven invaluable.

My other lifesaver is freewriting. If I get stuck, I open up my work log in Google Docs and start writing about what I’m working on, raising questions that need to be answered, describing obstacles in my path, trying to map out the next few steps so I don’t stay bogged down. It’s worked almost every time. And when it doesn’t work, I know it’s time to take a break and do something else for a bit — read a book, draw, take a walk — anything to recharge the batteries.

Oh, and I’m going to try to be better about posting here more than once a month. :)

A stitch in time

At work last week my boss was about to purchase a piece of software for a substantial sum. When he told me about it, I almost laughed at the ludicrous price. “They said it took about $6,000 worth of labor,” he said. Completely outrageous. So I coded up a program in Ruby that does pretty much the same thing (all the parts that matter to us) in just a handful of hours. I hate overpriced software.

Square peg, round hole

Jeff Croft writes about personal content management:

[A CMS] ought to make your content more useful simply by virtue of the content being in the system. But more often than not, it doesn’t. Most of time, you actually make your data (read: content) as dumb as possible by way of entering it into a CMS. Seriously.

He’s got a good point — with most content management systems, we flatten out the structure (or square-peg a round hole, as he puts it) and lose important information. Rolling your own is sounding better and better every day. I’ve been meaning to do that for Riverglen Press, and it wouldn’t be a bad idea to extend it to Blank Slate either (once I figure out what on earth I want Blank Slate to be — at the moment it’s just a neglected child, most of the time forgotten while its siblings bask in the spotlight, but ironically it gets more traffic than the others).

At any rate, I’m itching to make these sites more my own, and writing a custom CMS is a great way to do that. (I also really need to revamp the graphic design…) The main thing is to decide what I need this CMS to do. Most features I don’t really need, really, and my tastes have sharply turned to lightweight lately.

More to come later, once I have more time. :)

Yet another update

It’s been a while since I wrote about programming. Almost a month, in fact. ~sigh~

So, the BYUFHLC is on hold for now due to time constraints at work. (I have to get all the new extraction software done by a month from now when we present it at the ICAPgen conference.) After ICAPgen I should have enough time to finish it, though.

Haven’t coded much Ruby (or Rails) lately. I may start using it for prototypes for this extraction software, though… Considering that we’ll be switching to a Linux server sometime within the next few months, it almost feels like a waste to code the stuff in .NET (not to mention that I much much much prefer Rails), but it’ll have to do. At least I can rest assured that I’ll be able to recode it in Rails five times as quickly. :)

In other news, Matz is coming to BYU to give a colloquium two weeks from tomorrow. (11 a.m. on the 19th in 1170 TMCB, if you’re interested and on campus.)

Ruby to PHP

I’ve been porting the BYUFHLC to PHP, and it’s coming along pretty well in spite of a number of mini-setbacks. The only tricky part was figuring out how to parse the HTML from the screenscrape. At first I was going to use Troy Wolf’s class_http, but it didn’t seem to have any functions for actually doing anything with the HTML once it was fetched. Then I discovered the new DOM stuff in PHP 5.

Excitedly coding up a few lines to test it, I ran into function-not-found errors. Ten minutes later, I realized that Bluehost’s servers were running PHP 4. (Side note: I’d tried to get PHP running locally on my Mac, but it wasn’t serving the PHP; instead it would just display them as plain text.) I called them up and they said it’d take a 24-hour downtime to migrate my domains over to the PHP 5 server. That was unacceptable.

So, I went hunting around in /etc/httpd/httpd.conf again, and I found a line reading “<IfModule mod_php4.c>”. Changed the ‘4′ to a ‘5′ and it all started working perfectly.

After that, it only took twenty or thirty minutes to convert my Ruby code to PHP, and I’ve got the first set of results working perfectly. But now my stomach is grumbling because I haven’t eaten in a long time, so finishing this up is going to have to wait till tomorrow. I’m glad it’s going to be a fairly easy port. (From here on out it’s smooth sailing, since I’ve worked out all the DOM issues.) Expect another status report tomorrow.

And no, I’m not converting to PHP. :) I love Ruby and will continue to use it whenever possible.

BYUFHLC

Last week on Top of the Mountains I mentioned my FHLC/UVRFHC mashup (which I’m now calling BYUFHLC). It’s written in Ruby on Rails and is 75% done (I just have to add support for the non-place searches, like surname and such). Here at the Center for Family History and Genealogy, my employer has gotten interested in it, especially with the possibility of packaging it up to deploy at other family history centers.

Which leads to the question: is Ruby on Rails good for that? I mean, I know it’s superior to something like PHP or Perl, and I much prefer it, but what are the chances that those family history centers are going to be able to support a Rails app? It seems like PHP would be a better choice, since it’s guaranteed to be installed and supported. I don’t really want to recode it in PHP, though. :)