LAMP, or LAMR, how about LASR?

Fred Hwang pointed to this post by Steve Jones about the problem of the LAMP acronym with Ruby for the language instead of PHP. The problem being that it would be called LAMR.

For those so inclined to drop buzzwords, I think they should call the platform LASR. Just consider the database to be SQL (a compromise between MySQL, Postgresql, and SQLite), and it fits nicely.

Posted in General, Ruby and Rails | Comments Off on LAMP, or LAMR, how about LASR?

Rails – real data – database loading

Quick tip…

When working on a rails project you need to have REAL DATA to work with in your development environment. The easiest way is to grab data from a production database. Ah, but won\’t that require SQL and effort?

The answer is no. Luckily, 99% of the work involving this is done for you. You will not have to code a single bit of SQL to accomplish this.

Here is what we do here:

  1. Find the extract_fixtures rake task somehwere out on the internet. Check it into your project. Essentially, this gives you a rake task that dumps the environments database into .yml files in your test/fixtures directory. I modified the file so that it creates files with a \’.bak\’ extension in order to avoid destroying an existing fixture.

So, on my production machine, I do the following.


rake extract_fixtures RAILS_ENV=production

Then I copy the resulting files to my development environment. I then change the data to protect the innocent and avoid leaking any sensitive information. Once that is done, I rename the files over their blank/empty/unused fixtures of the same name (for example mv fruit.yml.bak fruit.yml) and check them in.

Once all the fixtures are sufficiently populated, I then do the following on my development workspace:


rake db:fixtures:load

I have just given myself (and every developer on the team) great test data that is also useful for developing new features. It is just too hard to code new features without real data. For example, that bar chart you are working on will not impress anyone when all the bars are at 0. 🙂

So, again, a few simple,easy steps and significant improvement on the development cycle for all parties.

Posted in General, Ruby and Rails | Comments Off on Rails – real data – database loading

Rails – How I get a new model up

Quick tip…

When working on a rails project and I need to get a new model up and running, I do the following.

./script/generate model Fruit

That will generate the model files, and most-importantly an empty migration… all in one step. The migration also has the nice side effect of having the appropriate skeleton of the model already inside (less typing, better consistency == good)

I then edit the migration and run it to generate the necessary modifications to the database. For example, not only will I create the columns for the Fruit object, I may add some columns to another table (Cakes ?) to refer to instances of this new model.

rake migrate

Now, once this is done, I have the model, and the tables ready in the database. The next part is to add the scaffolding.

./script/generate scaffold Fruit \'admin/fruit\'

This will create the controller and view skeleton code that will facilitate the basic CRUD operations.

DONE

For all of this to work, you didn\’t have to do anything but pick a name for the model and choose the fields.

So here is the summary… simple, no?

./script/generate model Fruit

rake migrate

./script/generate scaffold Fruit \'admin/fruit\'

Posted in General | Comments Off on Rails – How I get a new model up

Rails, Ruby, etc.

Ruby on Rails logo

So I finally have some time to handle a series of posts on Ruby and Ruby on Rails.

I’ve been playing with Rails for a while, at least over 1 year. I like it and I wouldn’t consider using anything else. The framework is well designed. For example, the form editing pattern is just so smart. The code looks simple, but only because the infrastructure was the result of some thoughtful debates. No other framework seems to get this right, out of the box. (In the same way programming languages love to demo the fibonacci code, yet falls apart in a real-world application)

Here are two other observations. The most popular observation is that people are just more productive in this system over any other system. This is a result of the language, the framework, and the best practices for the development environment. One personal observation is that I’m productive when changing older code in the system. The system is easy to navigate and consistent. It doesn’t take long to figure out what the intention was.

Overall, I would highly recommend this environment and will not expound any more on this. Try it out.

Also, although I’ve been productive in Rails and Ruby… I haven’t really known the language. Just recently I broke down and got the book. I know that may sound a bit odd, but the reality is that I could be productive in Rails and with Ruby in a project without really understanding Ruby. This says something about the language.

So, after doing some more generic projects in Ruby, I’ve come around to liking the language. I can be just as productive in that language as I can in Python now. It will be the first choice for any project.

Two other interesting points.

  1. I’ve been getting a bit of flack from some people about the whole being CTO and still doing the coding thing. 🙂 IMHO, if you have a CTO that can’t code something real and useful, they are too disconnected from reality to be effective.

  2. I’m going to get some of the code I’ve worked on available as open source. It is time to give back to the Ruby and Rails communities.

Posted in General, Ruby and Rails | Comments Off on Rails, Ruby, etc.

Interesting development in the Computer Game Industry

I think the following article/blog post at GigaOm is great news for the game industry.

Greg Costikyan’s Gaming Manifesto

Update: Greg’s blog is a great read to, just check this post

Posted in General | Comments Off on Interesting development in the Computer Game Industry

Nice Quote

“Of all races in an advanced stage of civilization, the American is the least accessible to long views… Always and everywhere in a hurry to get rich, he does not give a thought to remote consequences; he sees only present advantages… He does not remember, he does not feel, he lives in a materialist dream.” —Moiseide Ostrogorski (1902, 302-303)

Posted in General | Comments Off on Nice Quote

Ruby vs. Python on Domain Specific Languages

As I get more and more into the Rails Ruby thing, I’ve thought of a bunch of comments.

One that recently pushed me to the ‘blog about this’ limit is the discussion of Domain Specific Languages or DSLs.

There appears to be a lot of interest in building DSLs in Ruby. When you read some of the papers, it becomes quite obvious why Python is going to miss this boat. It also explains some of the difficulty as to why some DSLs that I did in Python didn’t take too well…. The whitespace indentation. If you are open-minded and you can get over that hump, you will eventually appreciate Python’s take on the problem.

But how many open minded people… or programmers are out there? By my count… not a lot. Everybody, including me, has blinders on. It’s provable as well. You hear some new programmers gush about Ruby as such a great language. Yet the language is 10 years old. Why is the phenomenon so recent? It is because programmers tend to be into fashion (surprise) just like everybody else.

So, how does this get back to the DSL problem? Simple. Python is the only reasonably successful language to attempt the whitespace is ‘really’ significant tack. Yet, this is a major piece of friction for newcomers, religious non-python programmers, and even python people who are working with other programmers (read TABS). It is also a huge piece of friction when it comes to implementing a DSL. Every attempt at doing a templating language for HTML, for example, has ended up looking a lot like something that isn’t Python. When I used the clever ‘eval’ trick to have Python become my configuration file language… the users hated it. This is a real problem for Python.

Ruby, on the other hand, is easy to use as a DSL platform. You don’t get burned by whitespace. This is one of the key reasons that Rails succeeds with Ruby. All files use Ruby. Even the templating language RHTML, Ruby. It works well…. really well.

So where does this leave Python? It leaves it with less energy and momentum for the future. Ruby is so similar to Python in many respects, yet with better features (ie. lower friction). Ruby will be used in more and more projects. Ideas from the Python world will drift over to the Ruby camp. Look what it is doing to the Java community as well. Perl? PHP?

Someone once exclaimed to me ‘syntax doesn’t Matter!’. Oh how wrong they were!

Sidenote: Humor

Ok, so if the era of the ‘P’ languages has passed, and we are in the new era of ‘R’… will we end up with ‘S’malltalk?

Posted in General | 3 Comments

Microsoft Releases Zune – Domain Owner Hits Jackpot

Microsoft announces the Zune… finally.

As I travel to http://www.zune.com/ I am greeted with an all-black ‘UNDER CONSTRUCTION’ page. Apparently, Microsoft didn’t acquire the domain name before the announcement. I have a feeling that the owner, GATE MARKET RESEARCH LIMITED has a smile a mile wide. I’ll bet Microsoft is prepared to pay 7 figures right now for the domain!

Posted in General | Comments Off on Microsoft Releases Zune – Domain Owner Hits Jackpot