My Resume | Contact Me | RSS Feed | Follow Me on Twitter

Code Capers

The Ninja Coding Dojo
RSS Feed Twitter Email

AMD Phenom II Overclocked to 6.5 GHZ!

clock January 30, 2009 by author Michael Ceranski
Recently during the CES tradeshow a group of overclockers pushed the limits of modern technology. They overclocked an AMD Phenom II X4 chip to 6.5 GHZ. In order to keep the chip cool they used liquid nitrogen and liquid helium. The temperature of the chip got to an astounding -232 degrees celsius. This is a world record for a quad core CPU! Watch the video below to see how it was done:



How Does Your Programming Language Rate?

clock January 29, 2009 by author Michael Ceranski

During tough economic times it is important to be always thinking about your next career move. If you got laid off today would you be able to find another job using your current skill set? As an IT professional I am constantly working on keeping my skills relevant and current. In particular, developers need to learn programming languages that can keep them gainfully employed for years to come. So if you are considering learning a new programming language how do you know which one to pick? One possible way would be to take a look at the 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."

Although TIOBE's method used to collect statistics is not perfect, it still serves as a good indicator of which programming languages are still actively developed with. The top 5 for January 2009 are Java, C, C++, VB and PHP. The chart below shows the long term trends.

While gazing into my crystal ball I came up with my own predictions based on this data:

 

Java, C++ and C are excellent skills to acquire. They are heavily rooted in the industry and will remain that way for decades to come. Especially due to the fact that most colleges still teach the majority of their programming courses with these languages.

I believe that Java will continue to slowly lose market share. I would like to think that this is partially due to the emergence of .NET as an enterprise scale development platform. However Java will always be a big player in the market due to its ability to run on multiple operating systems. This is something that Microsoft .NET will probably never accomplish.

As a former Delphi programmer I would like to see the language stay on the chart. Unfortunately, I do not think that Borland has positioned the product well over that last five years. They had a couple of really bad software releases starting with Delphi 8 which I believe hurt their reputation. Anyway these are just my personal opinions. If you disagree (which I am sure most people will) then please leave a comment.



Using Ruby with SQL Server

clock January 28, 2009 by author Michael Ceranski

Update: I have created an up-to-date tutorial that shows how to use Ruby on Rails with SQL 2008. It is written from the perspective of a .NET Developer and tries to draw comparisons between ASP.NET MVC with LINQ and Ruby on Rails with ActiveRecord.


In the computer world most people seem to be die-hard Windows or die-hard Linux. From a programmers perspective, each platform seems to have a core set of technologies that are associated with it. If you are a web developer working on the Windows platform you are probably going to build solutions using SQL Server and .NET. If you are working in a Linux shop you may be more inclined to use MySQL and Ruby.

In my case, I like Windows but I am intrigued by Ruby. I want to write Ruby apps that run on Windows and talk to SQL Server. So I started the challenge the same way most people do. I Googled for some sample code. Unfortunately, most of the snippets I found on the Internet were based on Linux and MySQL. Now I could have copped out and used IronRuby (Microsoft's interpretation of Ruby) but the thought of it made me feel cheap. I really wanted to use the language in its truest form. Eventually I figured out the process. Here it is:

  1. Install Ruby on Windows. There is a one-click installer which you can download here.
  2. Install the Ruby-DBI package. There is a great outline of the process here. The hardest part is making sure that you put the ADO.rb file in the proper folder.

Once the installation is done you can open up your favorite editor and start writing some code. The first step is to include the DBI module. The Ruby DBI module is the library that you use to access the database server. Now it is just a matter of creating your database connection and executing some SQL. The end result is this chunk of code:

require 'dbi'

oConn = DBI.connect('DBI:ADO:Provider=SQLNCLI;Data Source="sqlserver01";Integrated Security=SSPI;Initial Catalog=master')
sth = oConn.execute("SELECT name * FROM sys.databases")
rows = sth.fetch_all
col_names = sth.column_names
sth.finish
DBI::Utils::TableFormatter.ascii(col_names, rows)

Here are the results:

+-----------------------------+ name +-----------------------------+
master
tempdb
model
msdb
AdventureWorks

 

Not bad for a few minutes of tinkering! Now that the database connectivity issue is solved I can start experimenting with ActiveRecord. I also discovered the rubydotnet project recently which gives you the ability to utilize the .NET framework from Ruby. I do not know if this has any real world applications yet but it just looks like it would be fun to try.



Offline Gmail!

clock January 27, 2009 by author Michael Ceranski

I have been using Gmail for about 2 years now. I previously used Hotmail, but I switched when Gmail started offering POP3 for free (Hotmail used to charge for POP3). In case you don't know, POP3 gives you the ability to read your email with a rich email client such as Outlook or Thunderbird. This capability was crucial to me because I needed to download all of my email so I could read it even when I was offline. Having an offline email capability for some people is a necessity. Unfortunately, some people do not want to go through all the trouble of downloading an email client and setting up Gmail for POP3 access. If you are one of those people then today is your lucky day! Gmail announced today that they are going to build offline functionality directly into their web-based email client. Basically, when you are connected to the internet Gmail will make a local copy of your messages and cache them to disk. They refer to their caching technology as Gears. This is similar to the Isolated Storage Technology that was developed by Microsoft. I would be willing to bet that the other major players in the market such as Yahoo and Hotmail will be working hard to add this capability to their web clients as soon as possible. Still don't believe me? Watch the Video!



The Significance of Code Reviews

clock January 27, 2009 by author Michael Ceranski

I can not stress to people enough about how important it is to do a code review. This is especially true if you have a staff of young developers on your team. Unfortunately, in my company we tend not to do code reviews. It mainly stems from the fact that there are no "Lead Developers" to mentor the less experienced developers. Now even though code is written with the best intentions there is always a right and a wrong way to do things. However, presenting your arguments to others needs to be done in a positive manner. The goal is not to criticize! We are simply just trying to show them a better way of doing things. Code Reviews are a great platform for learning.

 

As a DBA I typically end up getting phone calls from end users who are complaining about performance. The phone call then precedes by a SQL trace. Once I review the results of a trace, I can typically get an idea of how the application was written. In order to fix the problems, I occasionally will ask the developers for source code. When I do this, I typically get a strange, confused look because most of the developers I work with do not think that DBAs can read code. After some hesitation they will give me the code but only because they think that I won't know enough to find any problems with it. Anyway, here is a stored procedure that I recently discovered. This procedure was used to populate a combo box on a form. This procedure would have been executed every time the form was displayed.

 

   1:  ALTER PROCEDURE uspGetMonths
   2:  AS
   3:   
   4:  CREATE TABLE #tmpMonth(
   5:      Ident INT ,
   6:      Months VARCHAR(15)
   7:  )
   8:   
   9:  INSERT INTO #tmpMonth(Ident, Months) VALUES(0, '(Select One)')
  10:  INSERT INTO #tmpMonth(Ident, Months) VALUES(1, 'January')
  11:  INSERT INTO #tmpMonth(Ident, Months) VALUES(2, 'February')
  12:  INSERT INTO #tmpMonth(Ident, Months) VALUES(3, 'March')
  13:  INSERT INTO #tmpMonth(Ident, Months) VALUES(4, 'April')
  14:  INSERT INTO #tmpMonth(Ident, Months) VALUES(5, 'May')
  15:  INSERT INTO #tmpMonth(Ident, Months) VALUES(6, 'June')
  16:  INSERT INTO #tmpMonth(Ident, Months) VALUES(7, 'July')
  17:  INSERT INTO #tmpMonth(Ident, Months) VALUES(8, 'August')
  18:  INSERT INTO #tmpMonth(Ident, Months) VALUES(9, 'September')
  19:  INSERT INTO #tmpMonth(Ident, Months) VALUES(10, 'October')
  20:  INSERT INTO #tmpMonth(Ident, Months) VALUES(11, 'November')
  21:  INSERT INTO #tmpMonth(Ident, Months) VALUES(12, 'December')
  22:   
  23:  SELECT    
  24:      Ident ,
  25:      Months
  26:  FROM
  27:      #tmpMonth (NOLOCK)
  28:  ORDER BY
  29:      Ident ASC
  30:   
  31:  DROP TABLE #tmpMonth 

Immediately after seeing this procedure I asked the developer the following questions:

  1. Why would you use a stored procedure for this?
  2. Why didn't you just hard code the month values in a combo box. It is not like the month names are going to change!
  3. Is there a reason to make a round trip to the server just to populate a combo box with a list of month names in it?

Here is how I would rewrite this in C# code:

   1:  public Form1() {
   2:     InitializeComponent();
   3:     comboBox1.DataSource = new BindingSource(GetMonths(), null);
   4:     comboBox1.DisplayMember = "Value";
   5:     comboBox1.ValueMember = "Key";
   6:  } 
   7:   
   8:  private Dictionary<int,string> GetMonths() {
   9:     Dictionary<int, string> results = new Dictionary<int, string>();
  10:     results.Add(0, "(Select One)");    
  11:     for (int i = 1; i <= 12; i++) {      
  12:         DateTime myDate = new DateTime(2000,i,1);
  13:        results.Add(myDate.Month, myDate.ToString("MMMM"));
  14:     }    
  15:     return results;
  16:  }

Now even though this particular procedure would probably not be considered a major performance killer it definitely does not help the cause. If this procedure was deployed to production it would have been executed repeatedly and caused a lot of unnecessary network I/O. In my opinion, this is a perfect example of how a code review can save everyone a lot of time and aggravation. If you are not doing code reviews with your team then start doing them now. No excuses!



About the author

MikeMy name is Michael Ceranski. I am a software developer from Buffalo NY. I have been writing code for over 10 years starting with Borland Delphi and later migrating to the .NET stack. I enjoy blogging about .NET, MVC and jQuery and I hope to spread my enthusiasm for technology by sharing my thoughts and ideas with you.

View my resume

Cumulus

This will be shown to users with no Flash or Javascript.

Sign in