Posts

Identifying IE browser usage correctly

How was IE browser usage being captured? The user agent string that IE identifies itself with includes the name and version number. For eg, IE 7 user agent will include MSIE 7.0, IE 8 will include MSIE 8.0 and so forth. The Splunk query that we used extracted this “name followed by version” token and derived usage statistics. Why did my team re-analyze at the browser usage statistics? For a particular client, we noticed heavy and consistent traffic from IE 7.Our Splunk query suggested around 550 users using IE 7, while the client claimed to have migrated to higher versions of IE. What was the observation after analysis of raw HTTP headers sent by IE? IE 8 onwards Microsoft started shipping every newer version of IE along with “compatibility mode”. If a page was working in IE 7 and breaks after IE 8 upgrade, user can switch to “compatibility mode”. However, in this mode, IE 8 (and all higher versions) user agent contains name and version as “MSIE 7.0”.  Hence, th...

Comparison operators in JavaScript

Another pretty weird but some may argue powerful feature of JavaScript is the way it handles comparisons. In JavaScript, (false==0) , (null==undefined), (""==0) all result in TRUE! Weird? You bet it is! What JavaScript does behind the scene? It uses pretty confusing and complicated set of rules while comparing values. In most cases it just tries to convert one of the values to the type of the other value. However, when null or undefined occur, it only produces true if both sides are null or undefined. For cases where you do not want any automatic type conversions to happen, there are two extra operators: === and !==. The first tests whether a value is precisely equal to the other, and the second tests whether it is not precisely equal. So now, (false===0) , (null===undefined), (""===0) will all return false as expected! Amusing, isn't it? Reference: http://eloquentjavascript.net

Logical operators in JavaScript

Most of us who are more familiar with static typed languages like java, c#, c++, c etc, know that logical "and" and "or" can be applied on boolean values. Well Javascript (or may be even other dynamic languages) let you apply these operators on any type. The way it works : 1. The || ("OR") operator - The expression on the left hand side of the operator is evaluated. If that expression is true, the value on the right is returned as it is which in turn is converted to boolean. So basically something like ("" || "hello") would return "hello" which when converted to boolean returns true. 2. The && operator works similarly, but the other way around. When the value to its left is something that would give false when converted to a boolean, it returns that value, and otherwise it returns the value on its right. (picked straight from this book) The way javascript handles boolean is also pretty odd. Only 0, "", null ...

Intuitive UI on the Web

Image
I read this blog some time back and just loved the small things which the author considers. He makes few good points: Auto saving to prevent data loss. Providing "undo" on the web which allows users to correct their mistakes. The simplest thing to do in a modal overlay would be to have a cancel button on the top right. Well, I have been working on the web for almost over a couple of years now. And to be honest, with all the development efforts which go into the application, I think UI takes a back seat. Unless of course, you have full time dedicated designers. UI to me should be measured with 2 parameters, how intuitive is it functionally? how attractive is it visually? We can keep the 2nd point for professional designers. As for developers, making the UI intuitive seems to be the key.

Principles of functional programming

A lot of concepts which are specific to the functional paradigm are pretty new and unheard of in the object oriented paradigm. Lets take a look at the main concepts and principles of functional programming. 1. Referential transparency: On a broader level, an expression is said to referentially transparent if it can be replaced by its value without changing your program. Essentially, the value of that function only depends on the arguments that are supplied to the function. So a referentially transparent function will never use a global variable or a I/O fetched value for computation. One of the most important advantage of writing referentially transparent programs is to optimize code using parallelization. As two such functions are dependent on only the arguments, performing them in parallel/concurrently is possible. With the new multi core processors coming into picture, concurrent computing has become important. This is also one of the reasons why Erlang and Scala have gained po...

Introduction to functional programming

I vaguely remember reading something about functional programming back in my engineering days. We did study Lisp and Prolog a bit, but it was done at a very abstract level. Ever since i joined the industry i have been writing object oriented code, or so i like to believe :) The point being that am completely new to this paradigm. Functional programming languages have largely been emphasized in academics rather than in commercial software development. However lately, few functional languages have gained popularity. Erlang - used by Facebook for their Instant Messaging. OCaml - used for financial analysis Scheme - used for training simulation software and telescope control Scheme (which is a dialect of Lisp) was in fact used in early macintosh computers. What exactly is functional programming? Its difficult to give a precise definition, but generally speaking: In functional programming the basic method of computation is the application of functions to arguments. It also avoids sta...