Archive for January, 2007

How did I live without migrations?

Posted on January 31st, 2007 in Programming | Comments

Like I mentioned in an earlier post, I really want to learn Ruby, so I can then dive into Ruby on Rails. Well, I decided to start moving along towards Rails, as I have a more clearer understanding of the Ruby language, its syntax and other goodies. I purchased the most awesome Rails book out there, Agile Web Development with Rails, a couple of months ago, but unfortunately I bought the first edition, which doesn’t even cover Rails 1.0. With the announcement a few weeks ago of Rails 1.2, I wanted to play with those features that aren’t covered in the book.

Looking around at the Rails Screencasts, I saw a nice little screencast about database migrations in Rails. Curious, I checked out that screencast, and was simply amazed at how easy it is to work with the database schema of your application in Rails. With the PHP applications I’ve developed over the years, this was one of the things that simply drove me crazy. Every time I did a change to the database in my development server, either adding a new column to a table, or deleting an existing table, I had to make a note to do it as well in the production server once the changes were complete. I can’t tell you how many times I uploaded some new changes to the production server, told the users about the changes, then reading their semi-angry E-Mails about how the changes don’t work at all, simply because I forgot to make the database changes.

With the migrations in Rails, once you have your schema set and the migrations in place, it’s as easy as editing a text file, specifying the changes you want to make, run a simple rake db:migrate command, and presto – All your changes are made automatically to the database without any data loss! And just in case you decide against one of those changes, you can go to the previous migration you made, which will revert your database as it was before. It’s really, really neat, and I don’t know how I ever lived without the migrations.

I still have a lot more to know, as I started playing around with migrations myself last night. But honestly, this is a feature that I know will save a lot of my time, as well as cover my behind in case of emergency. And to think that this is only one of the apparently many benefits of Ruby on Rails. Now I’m more pumped up than ever to keep on reading about this most awesome framework. Maybe I’ll finally be able to finish my first full Rails app ever soon, which is one of my short-term goals I started this year. It really is a beautiful thing.

Don’t take the easy way out

Posted on January 30th, 2007 in Linux, Programming, Ruby, Ruby On Rails | Comments

I remember when I first started using Linux back in the day – “back in the day” referring to about the year 2000 – it was a total pain to work with. From not-so-great hardware detection, to installation and partitioning pains, to the ever-lasting fight against making a Winmodem work, it surely wasn’t for the weak-minded. However, something I sort of enjoyed during that period was downloading and compiling the programs myself. Well, I didn’t enjoy it much when dependency problems arose. But just the fact that I was taking this free and accessible source code, compiling it myself, then having fully functional software made me have a sense of accomplishment.

Nowadays most people have it easy. With friendly and easy-to-use Linux distributions, such as Ubuntu and OpenSUSE, all you need is to just click on a checkmark in a GUI interface and your programs, along with all dependencies, are immediately installed. Nowadays no one even has to use the command-line at all if they wish to do so. So as Linux gets easier to use, less and less people learn how to really use the operating system to its fullest.

Unfortunately, I too have fallen into that trap as well. I remember I used to compile the kernel every single time a new one was announced. Now, I barely do it. If the operating system I’m using at the time doesn’t have a current update, I don’t install it. Every time I see a new program I was to try out, I check first if there are already pre-compiled binaries for my distribution, and only compile the source code if all else fails. It’s kinda sad how much I’ve lost during these past few years.

That will probably change from now on. Last night, I took a spare computer in my apartment (1.0 GHz Athlon with 768 MB of RAM and a 20 GB hard drive) and decided to put it to good use. Seeing that I’m trying to learn Ruby and Rails, I wanted to install an easy-to-use distribution to save me some time with installation and configuration duties. So I chose Ubuntu, and it all installed just fine, until it came time to install Ruby and Rails afterwards. With Ubuntu, installing Ruby is just as easy as doing this:

sudo apt-get install ruby

Ubuntu did its magic, even though I didn’t have a good feeling when I saw it was installing version 1.8.4 (Ruby is now at 1.8.5). Oh well, I thought. It was just a minor revision, no big deal. I then went on to install RubyGems, and it installed okay, until I started getting some warnings. Since it finished the installation, I just kept on going. When it came time to install Rails, This time one of the gems didn’t install (I believe is was Action Web Service). I had installed Rails in other distributions without warnings, even on Windows. Since I had a couple of spare minutes at night, I decided to go the long route, and install everything from scratch, and make sure it’s up-to-date.

I’ll skip the entire process, as I’ll probably cover it in another, more formal, post. But I grabbed the source code of Ruby and after uninstalling all the mess the Ubuntu binaries caused, I compiled everything and I had absolutely no errors at all! I was even able to install the Mongrel gem without any problems.

So, that taught me a lesson as far as relying on pre-compiled binaries goes. Besides the obvious reasons why you should try to compile your own software (if the code is available), such as optimizing the compiled binary for your system and making sure you have the latest versions, you can avoid problems from the beginning, even if package managers such as Ubuntu’s apt are supposed to help you there. Also, it brought back that sense of accomplishment I used to previously have. So from now on, as long as time and skill allows me, I’ll be compiling my own code.

Time to pay a visit to the Linux Kernel Archives. Long time I haven’t been there.

Ruby makes me want to rock out

Posted on January 28th, 2007 in Programming, Ruby, Ruby On Rails | Comments

During these past few weeks, I’ve been making a conscious effort to learn a couple of new programming languages, more specifically Ruby. As many people on the Internet, I was introduced to the beauty of the Ruby language when Ruby on Rails started to become popular around version 0.14. After reading a lot of Internet beginner tutorials, I decided to take the plunge and start learning Ruby now.

After grabbing the Programming Ruby book (lovingly known as ‘Pickaxe’ around Ruby circles), I have really fallen in love with this programming language. It’s not too difficult to learn, and you can produce really clean, readable and over-all beautiful code. I even feel Ruby has helped me become a better programmer, in the sense that I am striving to have all my code as clean and readable as possible. Being a full-time PHP programmer, you can imagine that clean and readable code isn’t my strong suit. After learning a bit more about Ruby, I’ll go ahead and dedicate myself to start learning Rails. I know I can start using Rails without vast Ruby knowledge, but I want to start with the basics, and I feel that’ll make me better at learning Rails.

However, the reason I’m writing this post today is because of an age-old question I’ve had ever since I started taking my programming courses in college. A lot of people question my choice of music while programming. This has popped up in some conversations because I love Rock music, especially anything that’s Punk Rock or Metal. The harder and faster it is, the better. So in a profession where I need to have absolute concentration to produce the best results possible, how can it be that I can concentrate more with some Bad Religion or Bullet For My Valentine on my MP3 player? It’s really weird.

At my current job, I tend to put some Rock music when no one’s around (just because I’m considerate of others). When I do, I notice I don’t move from my seat, and just start coding away. When I don’t have any music on, I tend to be distracted more easily, and go out for frequent bathroom breaks or just to chat with other co-workers. I wish my current employers could notice this and let me bring my own MP3 player to work and just leave me alone for long periods of time. I can guarantee that I can work much better and efficiently this way. But that seems like wishful thinking for now.

This past week, I think I’ve learned a whole lot with Ruby, partly because I’ve taken more time out of my schedule to sit down and practice hands-on. But it could also be because I just bought a couple of more CD’s for the collection, and I tend to listen to my CD’s completely when I code, instead of just having them in my car and listening to one or two songs before I move on to the next. I should do a formal study of this some day. Has anyone else in the world noticed this?

Welcome!

Posted on January 26th, 2007 in Programming | Comments

This will be the first of hopefully many entries to this blog. I’ve tried doing this blog thing many times before, but never followed through on it. Mostly it was because I wrote about inane stuff, like funny videos I had seen in YouTube, and because I was enshrouded in obscurity for reasons that seem pretty lame now.

In any case, I’ll try to give a glimpse into my professional life here, and how the ever-lasting quest for learning more and more software development things every day is going along. No more hiding behind the keyboard and monitor. This time it’ll be simply Dennis Martinez, and that’s how you’ll see me here.