Ruby, technology

Loading data from multiple files in Ruby using Hash

Loading data into Database reading from multiple files was never easy. I have been working on different projects lately, which required such exercise often. A general technique I followed to do that is explained here. In a gist, this is what it looks like:

require 'rubygems'
require 'fastercsv'

files.each do |key, value|
	file = "#{RAILS_ROOT}/db/drugsatfda/" + key
	recs = 0

	puts "Working with #{value.pluralize}.."
	FasterCSV.foreach(file, :headers => true) do |row|
		begin
			obj = value.constantize.new(Array.to_hash(row.headers, row.fields))
			obj.save

			recs += 1
		rescue => e
			puts "Rows processed: " + recs.to_s
			puts e
		end
	end
	puts "Loaded #{recs} #{value.pluralize}"
end

What do you think?

Standard
apis, java, technology

TIOBE Programming Community Index

The TIOBE Programming Community index gives an indication of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. The popular search engines Google, MSN, Yahoo!, and YouTube are used to calculate the ratings. Observe that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.

The index can be used to check whether your programming skills are still up to date or to make a strategic decision about what programming language should be adopted when starting to build a new software system.

Since there are many questions about the way the TIOBE index is assembled, a special page is devoted to its definition.

The ratings are calculated by counting hits of the most popular search engines. The search query is executed for the regular Google, Google Blogs, MSN, Yahoo!, and YouTube web search for the last 12 months. The web site Alexa.com has been used to determine the most popular search engines.

The number of hits determine the ratings of a language. The counted hits are normalized for each search engine for the first 50 languages.

Besides the rating of programming languages, there is also a status indicated in the TIOBE chart. Programming languages that have status “A” are considered to be mainstream languages. Status “A-” and “A–” indicate that a programming language is between status “A” and “B”. If a programming language has a rating that is higher than 0.7% (yes, this number is arguable but we had to fix it somewhere) for at least 3 months it is rewarded status “A”. The first two months the programming language will receive status “A–” and “A-” respectively. The opposite holds for languages that go from status “A” to status “B”. So if a language had status “A” 2 months ago, a rating of “0.607%” last month and a rating of “0.687%” now, it will have status “A–“.

Programming languages that are very similar are grouped together. Currently the maximum of the hits of the individual languages is taken into account when calculating the ratings of groupings. In the future we will do a better job and take the union (from mathematical set theory) of all the hits.

The long term trends for the top 10 programming languages can be found in the line diagram below.

No wonder Java tops the ranking. And it will continue to hold that position for some time to come. What I am surprised to see there was Pascal is gaining popularity and people are using it nowadays. You can see the list of top 50 languages here.

Standard
java, technology

Which is the Hottest Java Web Framework?

The “Break it Down” Blog has a lengthy post on Which is the Hottest Java Web Framework? Or Maybe Not Java? Comparing Java Web Frameworks is hard because so many people are passionate about the framework they know best. Add a couple more like Flex and Ruby on Rails and its downright difficult. Nevertheless, this post is good in that it contains a lot of pretty trend graphs and it looks like the author has done some good research. It’s likely the folks that will scream foul are the ones that did poor in the comparison (Tapestry and Stripes, I’m talking about you).

Surprising among the top Java Web Frameworks is the rise of Struts 2. Which is much more interesting I think is how Wicket adoption has stayed almost flat while Struts2 adoption has spiked. Spring MVC/WebFlow seems to be going no where fast and racing JBoss Seam there.The popularity of Struts 2 really caught me off guard with it being quite a bit different from Struts 1, I figured it got thrown into the “just another web framework” category, but I guess there is something in a name and it’s doing quite well.

Regardless of what one might think of the post and trends, one has appreciate the amount of time the author invests in the work.

Standard