Category: Code


So you made your website in 5 hours - nobody cares

January 2nd, 2009 — 6:00pm

Nobody should care.

I was doing my usual reading this morning and I started to recognize a pattern. Not just this morning, but a pattern that has been occurring over the last year or more.

It goes like this:

  • Developer finds a new web framework
  • Framework espouses really quick development time
  • Developer creates a really stupid application based on a stupid idea
  • Developer submits a link to their new stupid app to [Reddit,Digg,Hacker News]
  • Developer says “Look at me, I did this in 5 hours”

I understand why this happens. I have done it myself. Developers do this because there are websites out there that have been made in just hours or days that turned out to be hugely profitable. The allure is tremendous.

Here is the part that gets me: There are so many bigger problems out there. Money can be made solving these bigger problems too and society would benefit. Why waste the energy on a 5 hour site that scrapes twitter for people who type “oops”? I’ll admit to a little bit of weird people-watching interest, but seriously aren’t there better things to work on?

Take for example healthcare and education.

In healthcare there are still hospitals and clinics using paper medical records. Some still schedule your visit using Excel spreadsheets. I know first hand that there are 5 to 10 problems that are just unanswered from the software industry. There are standards galore. There are vendors, all of which sell the one-solution-to-fix-them-all products. Here’s the catch, they are all expensive and don’t do what they are advertising. And if you do buy the product you have to change the way you do business to fit the way the software works. If you ever want to know why healthcare gets expensive - start looking at the way the hospitals and clinics have to do business (not just health care). It’s interesting to say the least.

Education has it’s own set of problems. Take for example that in the United States some schools and state agencies have yet to fully analyze data for grades and attendance because they don’t have software to do so. Even though there is legislation that requires them to collect this data in order to evaluate performance which will in turn determine funding for schools. Some agencies can’t even properly coordinate data sharing because the schools are all doing different things with their information. There are tons of school information systems out there and standards as well - yet the problem still exists. Ever wonder why the U.S. doesn’t do better with education at lower levels? Start looking at how schools analyze their performance based on grades and attendance.

And these examples are tips to titanic icebergs (yep - ship sinkers). Meanwhile really smart developers are spending hours or days watching people on twitter type “oops” or building fart noise makers for the iPhone. And at the same time some feel they have the justification to wax poetic about the ails of the world. So why is it really that you aren’t working on these bigger problems? Scared? This indeed is me challenging you.

I just wonder what it would be like to see links submitted at the same rate these stupid apps are submitted that solve these bigger problems. Or at least see people saying they are trying. I can think of one argument that may stop some is that it doesn’t sound fun. Those industries aren’t exotic or even interesting. Well I would contend that if you love software, writing code and solving problems you have no argument. Your interest is in the code not the industry. Your pride is in the solving. Right?

Say what you will about me and my grandpa moment here - just don’t overlook the real problems out there.

Comment » | Code, Life

Rails + Merb: When differences matter and when they don’t

December 24th, 2008 — 3:29pm

Yesterday saw the announcement that Rails and Merb would merge.

I’ll let the blogosphere debate the benefit of the merging of the frameworks feature by feature. At first I was disappointed because I liked where Merb was going (and still is apparently). I use Rails everyday and am beginning to be slightly perturbed about the “opinionated” design. However, I wanted to comment on the bigger picture. The merging of different opinions and principles.

The most refreshing part of this merge announcement is the notion that “warring tribes” were able to join forces. I think this should not go unnoticed. How often do software projects with dramatic differences basically move in together? Not often.

In my opinion that’s because software developers are isolationists. We want to write frameworks that can live independent of other peoples junk. That way when problems arise it’s the other guys bad idea and not ours. On top of that we want to be the creator of the Better Way™. And when we are opinionated about it, that makes us colorful. At least that has been the climate lately.

Look at other debates on technology. Here are a few:

  • REST vs. SOAP
  • ODF vs. OOXML
  • functional vs. imperative languages
  • Vi vs. Emacs
  • Mac vs. PC

How many of these are tired? What prevents some of these from just dropping their differences and combining their strengths? I have my opinion and it involves ego and pride, but I’ll keep it to myself.

Sure you might think it utopian and idealistic for some of these larger technologies to merge, but I find it refreshing to at least consider it. Think of this: how many new ideas are being lost because the differing ideas aren’t being brought together side by side? [UPDATE] I really enjoy this:

That the rift in many ways was a false one. Founded on lack of communication and a mistaken notion that because we care about working on different things, we must somehow be in opposition.

Differences matter when the problem calls for it. That’s inherit in every design. In some cases you have to use X because Y doesn’t solve the problem. But differences don’t matter when you are looking for new ideas. I think Rails + Merb is a new idea.

Progress does not come from solving the same problem with the same solution over and over again. There is a word for that. Doing the same thing over and over again expecting different results is what again …

Comment » | Code

When floats don’t float

December 19th, 2008 — 3:44am

I had the pleasure/pain of discovering first hand the issue of interpretation when it comes to data type intent. The Rails migration feature is one of the better features. To be able to quickly outline the schema of a table and produce it in a database from a rake task is the definition of love for a developer. It goes like this - I want to use my language (Ruby) and I want to create this table in the fewest amount of keystrokes possible:

create_table "student" do |table|
  table.string :name
  table.integer :zip
  table.float :gpa
end

Now from the command line I run rake db:migrate and blamo - table made. No SQL statements. And I can create this table on any database I choose. SQLite, MySQL, Oracle, Postgres and unfortunately SQL Server.

Except when the world crashes down around you and your float values are being returned as integers. Yep. The student that only got 0.59 GPA (rough year with no electives) is now getting a 0 GPA because your database driver says so.

What?

That’s right. The database driver says so. In this case Oracle JDBC. Well it’s not all Oracle’s fault. They had a lot of help from IBM and WebSphere. Here’s how this all panned out.

  1. I performed the migration to an Oracle database using the regular Ruby OCI8 driver.
  2. Fire up the Rails app inside a WebSphere server using JRuby and connecting to the database with JNDI Oracle JDBC driver.
  3. Created a few records with the correct float values (0.24, 1.2, etc)
  4. Look at records in DB and see 0.24, 1.2 etc.
  5. Look at records from Rails app and see 0, 0 etc.
  6. Profit?

Hmm… That is rough. The app works. I know it. It worked all day long on my machine. Ha. Famous last words.

So after days of debugging (yes I said days) I finally found the problem. It was all in the interpretation. Ruby OCI8 read my table.float :gpa statement and said:

“oh - he wants a NUMBER column named ‘gpa’”

Well OK that works. Oracle defaults that way anyways. Oracle will recognize that as a field that can store 1000 or 1000.10. No problem. And the ActiveRecord JDBC adapter will receive that schema and say:

“oh - this column is a NUMBER with no precision or scale so we’ll default to decimal like Oracle does”

The problem occurs when you ask WebSphere to provide you the Oracle JDBC driver through JNDI and let WebSphere wrap it with it’s helpers. The irony. See the DataStoreHelpers will tell the ActiveRecord JDBC adapter that the column is actually a NUMBER(22) with a scale of 0. What’s wrong with that you say? This is what’s wrong (from activerecord-jdbc-adapter/lib/jdbc_adapter/jdbc_oracle.rb):

def simplified_type(field_type)
  case field_type
  when /^number\(1\)$/i                  : :boolean
  when /char/i                           : :string
  when /float|double/i                   : :float
  when /int/i                            : :integer
  when /num|dec|real/i                   : @scale == 0 ? :integer : :decimal
  when /date|time/i                      : :datetime
  when /clob/i                           : :text
  when /blob/i                           : :binary
  end
end

Yikes. If the scale is 0 the ActiveRecord JDBC adapter says it’s an integer. Rightly so. So now a value of 0.24 is 0. Shit. Why would WebSphere Oracle DataStoreHelpers do this? If the data type is NUMBER with no precision and no scale, why would it create a precision of 22 and a scale of 0? Is that interpretation?

And the final kick in the pants is - if you run the migrations using JRuby and the ActiveRecord JDBC adapter - it puts the data type as FLOAT(63). Ouch.

I don’t know how to end this post. There is no morale. I just wanted to share my pain.

Comment » | Code

Back to top