Nov 14 2006

Jewels and Stones

So my web design opportunities have slimmed down. That’s to be expected, really. I had two people courting me for help, only one has come through with plans, meetings, and a set of requirements. So, naturally, that is the one I will work on.

I’ve already made a temporary site; it’s mostly in Perl and straight HTML. Got a webmail form, a hard-coded gallery, and a front page set up. The site is mostly served from cgi scripts using templates; each script is specialized to its own page. Boy, do I love Template Toolkit.

After some careful thought, investigation, and simple tests, I decided that Maypole, the Perl Model-View-Controller application framework, though it’s powerful in its own right, had some shortcomings. In one review of Maypole I read, the writer stated that he had a difficult time setting up Maypole to do anything beyond the sample demo applications that are provided in the documentation. I tend to agree with that writer. It’s got promise, but there’s some gnarly details that need to be hammered out before I can do something large-scale with it.

All this talk I’ve made about Maypole being the Perl equivalent of Ruby On Rails, I decided, in one evening of frustration, to actually look into Rails. After reading some docs, installing Ruby, Gem, and Rails, and building some demo applications, I’m kind of sold on the idea. A simple application can be built in one night, a medium one in a few, and a complex one in a few weeks…given I can focus on the task.

Ruby is a strange and foreign language to me, given my history with Perl and Javascript. Everything is an object, like in Javascript, and everything returns something, like in Perl. In Ruby’s case, everything, from constants, to strings, integers, floats, and on up are a subclass of Object, and as such feature a few built-in methods. What most people call methods, Ruby calls messages. You have an object of a certain class, and it has methods that are called with messages like so: someObject.sayHello("Hi There") This is similar in structure to Javascript’s heavy usage of dot notation, but I think the depth stops at one dot. Ruby also has little need of the semicolon to punctuate statements; this I find alien and a little offsetting. They’re really only needed for multiple statements on one line, otherwise the newlines delineate statements.

Perhaps one of Ruby’s greatest strengths, one I’m barely understanding, is its ability to encapsulate blocks of code and store them, and their variables, into persistent chunks to be thrown around as closures, iterators, etcetera. This is where curly braces are most likely to be found. Ruby doesn’t require curly braces around methods, loops, conditions, or anywhere else; those are enclosed by the statement itself and its corresponding end statement.

Rails is programmed in Ruby, and it takes advantage of Ruby’s strengths. Most important to Rails is the class ActiveRecord, which is Ruby’s version of Perl’s venerable Class::DBI module; each object of that class corresponds in some way to a specific record in a specific database table. Coupled with that is a menagerie of other Rails classes such as ActionController and ActionView which round out the triumvirate of the Model-View-Controller paradigm.

Rails is much like Maypole in that it takes only a few real lines of programmer code to make it work. When one creates a Rails application on the command line, Rails builds a generic framework of directories, templates, scripts, tests, and configuration files you can then edit. Once you configure the application to use the database, and have created your tables, you can then ask Rails to create for you a scaffold of classes, templates, and controller methods so you can start manipulating records in the database right off the bat. Once you are done with the generic “CRUD” methods (Create, Retrieve, Update, Delete), you can then replace them with your own custom methods.

As good as all this sounds, what makes me balk about the framework is that, to the uninitiated, Ruby On Rails has some damnable voodoo in it. By this I mean that there are requirements to the way you name your database tables, the fields in those tables, and your application classes; you must conform to certain naming conventions for Rails to automatically see and interact with them, elsewise you’re scratching your head trying to find a way to force Rails to see things your way (which there are ways).

One such naming convention is that your tables must be a plural of what they hold; for instance, you have a table where each record is a “toy”, therefore the table must be named “toys”. Rails has singular-to-plural inflection code built in. Your model must be named “toys”, your application controller class, “toys”, your templates will be in the “toys” directory. Some damnable voodoo indeed! I’ve yet to discover where I can expect Rails to do this, but there are ways to circumvent it, fear not. Most of Rails’ personality is configurable, but doing so makes so much of the automatic things that Rails does fewer and farther between.

So this website I’m building; it’s turning into this smallfry e-commerce storefront with multiple vendors, multiple products, pictures, a blog, a webmail system, back-office report generation, and so on. It gives me trepidation to think what all I have before me. I know I’m not going to get any barebones functionality ready before deadline, but it’s my hope that my client will understand and will be lenient on me. Learning a new language, discovering the powers and caveats of a new framework, trying to handle the things in my personal life…it’s a lot of work.


Oct 9 2006

Emo-Bitten

So yeah, I’ve had a dumb weekend. Friday was ok, but saturday found me in a hell of a bad mood. Sat inside most of the day going between snoozing in my chair, cleaning the house, reading documentation on the Ruby programming language, and feeling bad about my life. Moody McGivesafuck. Brooded over myself as I changed venue; left the house at sunset and ambled over to Epoch where I absorbed myself in journal writing and reading more on Ruby. In one weekend I’ve read nearly the entire manual. Finally, my friend Jonathon came around and we discussed things; felt better about my current state.

By this morning, I felt fine. Took my time getting out of bed. An hour of reading the Internet did its job on distancing me from my snoozy feelings of a pure morning. Did laundry while making lunch, then read some more Ruby docs. Got dressed and went to Epoch. More reading. It’s my goal to learn enough Ruby to proficiently use it with Ruby On Rails to build a site for a friend of mine. After several hours there, I started walking; took the long way home in the crisp air. Autumn is approaching, and this full moon is making things nice. I haven’t driven my car since I got home from work on Friday; it’s a weird feeling. As long as my car’s not up to snuff, it’s in my best interest to let it sit in the parking lot whenever I can. It’ll still drive decently, but the smoke, the smoke.

So I’ve still got this outstanding dental issue. There’s the molar that needs a root canal. That’s still gotta get done. I’m fine with that; I’m fairly certain I know where I’m going for that. But just an hour ago I discovered something else that may’ve happened this week since my recent dentist visit: I noticed in the mirror that my crooked incisor tooth is broken. There’s a crack right across it on the front; may’ve happened while eating, since the tooth has a filling on the backside. This scares the shit out of me. I don’t know what procedure is done for cases like that. Bonding? Patching up? Removal?

I’m becoming a poor man, and my bad teeth are to blame.

Scary shit.

Addendum:
Ok, so what I thought was a crack in a tooth was just the edge of the tooth-colored remnants of dinner. After brushing, it’s no longer there. I feel like a fool. I still need the root canal though.