Archive for the ‘Other’ Category

Google Chrome Doesn’t Always Seperate Each Tab to Different Threads

Posted on September 3rd, 2008 in Other, Technology | No Comments »

I’m using Google Chrome right now, and I have to say that it’s blazing fast. Based on Javascript benchmarks I’ve ran from around the web, I found it to be way faster than IE7, way faster than Firefox 2, much faster than Firefox 3, and even faster than Opera. Chrome’s new Javascript engine is awesome, but I just wanted to clarify that tabs do not always run as a seperate process.

Google mentions on their in one of their Chrome FAQs that it’s up to the web developer to decide if a new link opens as a seperate process or not.

I found this out first hand by going to W3 School’s html samples page and clicking on one of the links. Instead of opening on the same tab, the link opens on a new tab. So now I had http://www.w3schools.com/HTML/tryit.asp?filename=tryhtml_basic open in a tab. I edited the html source code on the left frame and put in a simple infinite loop with Javascript then hit run. As expected, the tab, instead of the entire browser, hung.

However, when I clicked on the W3 School’s html sample tab (which launched the now frozen tab), I noticed it was also frozen. My other tabs, such as Gmail, Google Calendar, etc were fine.

Google answered why: 

New tabs spawned from a web page, however, are usually opened in the same process, so that the original page can access the new tab using JavaScript.

Makes sense. In fact, that is one of the reasons why current web browsers run in a single thread. No big deal. Most of the time I have multiple “sessions” of browsing and I don’t mind if a few tabs share the same process thread.

Anyway, if you don’t have Google Chrome, get it. Finally multi-core machines will see benefits in browsing the web. I can have 10 tabs open without seeing a slowdown.

Web Standards

Posted on August 15th, 2008 in Other | 1 Comment »

As many Flash Developers have heard, ECMAScript 4 has died. I’m not going to go into the details of the decision, although you can most likely blame Microsoft and their 80% browser stronghold on the web.

Nevertheless, the decision has raised significant issues around the web regarding web standards, and whether or not they have worked in the past or not.

Take for example IE and Firefox. Every web developer has experienced the browser compatibility problem. 90% of forum posts start with “Strange CSS bug, works in IE but not in FF” or “Script works in FF but not in IE” etc. Ironically, Adobe Flash’s success has largely come from this problem as Flash runs ubiquitously on every browser. While the W3C has made progress on creating web standards, in general it’s been a failure. Even newer browsers, aware of the recommended standards while in development still don’t pass Acid2. But why has this failed?

I think it’s by choice. Microsoft, Firefox, Safari, and Opera fight for the larger share in browser usage. If coders create a site that fits their browser, the idea is that more users will download that browser. For a long time, IE was the standard. Whenever a site didn’t work in IE, as a developer, you MADE it work on there knowing that 90% of the visitors to your site would have IE.

But a phenomenon happened: the open source movement. Firefox arrived as an open source competitor. It’s not that Firefox was better than competitors (it wasn’t). But because of the nature of Firefox just being open source, the browser had more power than other competitors to browser dominating Internet Explorer. Firefox complies with the web rather than the web complies with Firefox. This development strategy could have only existed on an open source project, as the developers of the project did not have the authority or mindset to take over the web.

But as mentioned earlier, Firefox has led to major problems to web designers and coders. It’s a pain to create stuff! Everyone wants a page to look the same on every browser and on every computer. Only a dream… and will stay a dream.

Having standards would fix this problem; however, how would the actual products react? How will innovation be affected? There are many parallels to government oversight in the economy and web standards… but we don’t have to go into that.

A fleet only goes as fast as its slowest ship. When Mozilla, Firefox, and Apple vote on a particular feature to be a standard, some will have to pick up the pace while others will have to slow down. And that is what has been happening at the W3C and ECMA. Adobe has included a bunch of features that it would have probably had to remove in order to comply with ECMA 4. Now that ECMA 4 is dead, Adobe can keep those features… and even develop new ones without having to wait for ECMA to accept or reject revisions.

Of course, the downside is that we developers will have to work extra hard to make our products work on multiple software. Meaning more browser specific pages and more time researching what works on a particular browser and what doesn’t.

But here is where I disagree. At this level, the benefit isn’t that someone with IE may see an awesome Javascript menu while someone on FF may see a image mapped navigation. The biggest misconception I have found is that coding standards are susceptible to the same criticism as software standards (Browsers, GUIs, colors). But it ain’t.

Here’s why: the standards proposed in ECMA 4 were in coding syntax rather than in any product output. At today’s high level coding languages, we can basically do anything we want with Javascript, Flex, and Actionscript; however, the syntax is different. And THIS is something that NEEDS standardization. Just because the experience of writing the literature of source code may be better and more intuitive on one platform than another doesn’t change the actual output of the product. This is why I think the dump of the ECMA standard is a BAD thing. The ECMA was a scripting standard. So Actionscript may get private constructors now, whooped-dee-do.

What would have happened if RSS standards weren’t introduced? Sure, maybe one RSS format would have “extra features”, but we wouldn’t have the RSS readers that we do today. The Google Reader team can focus on making their product better and not on how to read hundreds of different XML formats.

I’m not saying that ECMAScript is comparable to XML; however, I am trying to address the criticsm I have been reading trying to say that web standards hinder innovation and are always a bad thing.

The reason ECMA failed was because companies want to control the market. The excuse Microsoft and others use is that, in practical terms, the web doesn’t need certain coding features. But that’s just an excuse. Web applications are getting more and more advanced. A standard like ECMA 4, which would last for many years, needs to support the most advanced coding syntax as possible. Sure maybe most products are not big enough to really benefit from abstract classes, but in 2 or 3 years, when ECMA 4 was scheduled to be adopted and shipped with products, who knows? And what about in 5-6 years?

In other words, in the short term and for companies that have the capacity to advance their languages more than others (like Adobe) , and since AS4 may come out sooner, this decision is ultimately good in the short term and bad in the long term.

Firefox 3 Fixes Bug

Posted on May 30th, 2008 in Other, Technology | 1 Comment »

The keyboard bug with RC1 has been fixed for latest build (RC2)!

Phew!

Firefox 3 Release: World Record? What world record?

Posted on May 30th, 2008 in Other, Technology | No Comments »

The Mozilla team has announced that they are attempting to set a (Guinness Book) of World Record of number of downloads for a piece of software in 24 hours… A record never set before.

The first thought that came to me was… huh? How can this number not be set already - by Adobe (or back in the day Macromedia) Flash! Isn’t the Flash plugin downloaded millions of times per day? Flash is on more computers than any other software (including any operating system). Macromedia never and Adobe doesn’t really release any download statistics other than averages. I’m sure Flash 8 or 9 when they first went public shattered records. Adobe should release the results so Mozilla has a number to beat.

Just think back to the day YouTube decided to switch to Flash 9 and how many users downloaded then.

Mozilla may set the record, but by no means will they have broken one.

*Edit:

I love FF3 (although I am shocked that they won’t fix a critical Flash bug that happens with RC1 for the final release). The search bar is great, and I don’t experience the slowdowns I did with FF2. But still, there seems to be a disconnect with FF and the web… Just look at this huge bugzilla thread about the Flash bug.

Jacobi Algorithm in AS3

Posted on April 10th, 2008 in Actionscript 3.0, Algorithms, Other | 1 Comment »

Recently, my “Calculus for Computer Science” teacher assigned the following problem.

So to complete this assignment, I decided to use Actionscript 3 and Flash. A friend of mine and I at Georgia Tech are developing a complex open source matrix library called as3matrix, and we were planning on implementing Jacobi to find eigenvectors of a MxM matrix anyway, so we decided to just apply it to our library.

The Jacobi algorithm is pretty straight forward. It’s impossible to use a formula to find the eigenvalues of a matrix larger than 5×5 because there is no equation solver for equations to that degree. So let’s say you have an 6×6 matrix. To find the eigenvectors, the Jacobi algorithm creates a smaller 2×2 matrix inside that matrix, diagonlizes that, then reapplies it to the matrix.

So what the program I turned in does, is generates a random 5×5 matrix. The program then begins to diagnolize the Matrix using the Jacobi algorithm. Then the program attempts to try diagnolizing the Matrix using the Jacobi method but this time ignoring sorting to solve the 2×2. Obviously, sorting is much faster since it ensures the 2×2 can be diagnolized (since the corner entries will be the largest absolute value of the matrix).

So anyway, here’s how the process works in our as3Matrix library. The jacobi() method computes one interation, while diagonalize() continues the jacobi method until the Off (the sum of the square of off-diagonal elements) is less than 1e-10.

First, take the matrix A. Find the i,j element in the matrix that have the largest absolute value. Create a 2×2 matrix from the i,j elements where a = i,i ; b = i,j ; c = j,i ; d = j,j . This step was probably the hardest part because I kept mixing up the i’s and j’s! Quite annoying when you accidently flip them…

Next, take that 2×2 matrix and diagonalize it. The formula for the eigenvalues that the library uses for 2×2 matrices is:

var L1:Number = ( (a+d)/2 ) + Math.sqrt( 4*b*c + ((a-d)*(a-d)))/2;
var L2:Number = ( (a+d)/2 ) - Math.sqrt( 4*b*c + ((a-d)*(a-d)))/2;

For the eigenvectors, I use a nice trick found by Harvard professor Oliver Knill. I then normalize (which is something Oliver’s page fails to mention) the eigenvectors. Combining the eigenvectors to {u1,u2}, I now have my matrix U.I take that matrix and embed it into the identity (of size of the original, original matrix).  I call that matrix G. Then D is Transpose(G)*A*G.

Then outside of the method I check if the Off(D) is < 1e-10. If so, then I consider the Matrix diagonalized!

Here are the results of Jacobi (with sorting) vs Theoretical Bound and Jacobi (without sorting) vs Theoretical Bound. Since AS3 doesn’t have an LN function, I just used the change of base formula (log(X)/log(2)). I hard coded log(2) to optimize the code.

A couple of random 5×5 matrix sample:

After running 100 random 5×5 symmetric matrics through the Jacobi algorithms, these were the average number of iterations for each:

Average Sorting = 25.11
Average no Sorting = 102.94

Sorting is clearly the best method.

Anyway, you can browse/download the as3matrix library here. Check out the TestJacobi.as in the trunk.

Object Oriented Programming without a Computer

Posted on December 29th, 2007 in OOP, Other | 1 Comment »

Artists see the world as a canvas. They represent environments, objects, and abstractions with shapes, shades, and colors. Pride and honor can be shown in a sculpture, or love may be represented with red colors and heart shapes. Architects envision the world as a blueprint; objects have structure and forces acting upon them from other objects. Just as a bridge is supported with suspension chords and metal, a family is strengthened with care and unity. Profession influences perception, and while outlooks on space and matter may differ, none are right or wrong – only different. But these professions and perspectives are kept in mind when programming languages are developed. Today, one of the most common programming ideologies is object oriented programming (OO). Object oriented programmers don’t picture the world as a canvas or blueprint; alternatively, OO programmers envision a hierarchical world composed of hierarchical objects with polymorphic, encapsulated actions and properties. There are four fundamental principles of object oriented programming: composition, inheritance, polymorphism, and encapsulation. Each attribute can be explained without a computer in a non technical (Java based) perspective, and some visibility represented in an Adobe Flash environment.

Scooby Doo is a famous detective dog from children TV and books. The charismatic, friendly, cute dog detective helps his friends solve mysterious.

In Java (and other OO programming languages), Scooby could be represented as a class.

public class Scooby
{
}

In Flash, Scooby can be represented as a Movie Clip with a picture of Scooby inside of it.

In this picture, Scooby has a bright, blue collar around his neck. He also has a long tail and a big nose. The idea that Scooby has these three objects and more is the composition concept of object oriented programming. Modifying the class to fulfill this design ideology is very easy in Java.

public class Scooby
{
	public Collar myCollar;
	public Tail myTail;
	public Nose myNose;
}

ScoobyCollar, ScoobyTail, and ScoobyNose are all objects that belong to Scooby; therefore, they are stated inside the Scooby object. In Flash, a Movie Clip that is placed on the stage can have multiple Movie Clips inside of it. Consequently, a representation of Scooby in Flash could be a movie clip called Scooby with three movie clips called myCollar, myTail, myNose. Every object has its own properties and actions, and consequently Flash allows code and properties to be added to actual objects. Flash and Java are two environments that use the same idea of building blocks. The building blocks of Java are floating point numbers while the building blocks of the visual Flash environment (excluding Actionscript) are vectors, bitmaps, and video. This means that objects can be broken down to their compositions, and their compositions can likewise be broken down and eventually they will all break down into the building blocks of the language. For instance, a soccer ball has color (a hexadecimal number) with bounciness (a number), weight (number), or a logo which can be itself broken down to objects that have numerical representations. In Flash, a movie clip is composed of vectors, videos, bitmaps, or other movie clips.

Inheritance, another fundamental aspect of OO design, is the concept that every object inherits identity from another object. For example, Scooby is a dog, a dog is an animal, an animal is a living being, and a living being is… an object. Scooby is a dog because Scooby has all the properties and actions that every dog possesses. One could claim every dog barks, has four legs, and has a tail. One could also say that not all dogs have a collar, have a big nose, or a long tail like Scooby’s. Clearly, there can be an infinite amount of classes between animal and living being, but the idea is that everything (eventually) is a subset of an object. Objects have attributes from more general objects, but have specific attributes that only it and its children objects keep. In Java, this concept is represented with the extend keyword. “Scooby extends Dog” means that Scooby is a dog and inherits the methods and properties from Dog.

public class Scooby extends Dog
{
	public Collar myCollar;
	// Notice how tail and nose was removed from here and added to Dog
	public Scooby()
	{
		super();
		super.myNose = new ScoobyNose(); // ScoobyNose extends Nose
		super.myTail = new ScoobyTail(); // ScoobyTail extends Tail
	}
}

public class Dog
{
	public Legs myLegs; // These properties are accessible in Scooby
	public Tail myTail;
	public Nose myNose;
	public void Speak()
	{
		System.out.println(“Ruff!”);
	}
}

Unfortunately, the concept of inheritance does not apply as easily with Movie Clips. Flash takes the approach that a Movie Clip is an object, and subclasses of Object are created as new movie clips and shapes are added to the original movie clip. For example, a vector drawing of a basic car is in a movie clip called Car. The developer in Flash can rename Car to BMW. According to the idea of inheritance, the car should be easily modified to create a BMW since a BMW inherits all the elements of a car (four tires, has an engine, etc..).

Polymorphism is the idea that two objects can have the same input but have a different output. A dog and a cat can both speak (which can be said to be an action of SpeakableAnimal which both a dog and a cat extend), but one says “Meow” while another says “Ruff”. In fact, Scooby says neither, he says “Scooby Dooby Doo!”

Therefore, the design needs to change in Java. The method Speak needs to be “overloaded”, which means the name of the action is duplicated but the implementation changes.

public class Scooby extends Dog
{
	public Collar myCollar;

	// Notice how tail and nose was removed from here and added to Dog
	public Scooby()
	{
 		super();
	 	myNose = new ScoobyNose(); // ScoobyNose extends Nose
	 	myTail = new ScoobyTail(); // ScoobyTail extends Tail, therefore a ScoobyTail can be constructed even though myTail is of a Tail Type
	}
	// Overloaded action
	public void Speak()
 	{
 		System.out.println(“Scooby Dooby Doo!”);
 	}
}

public class Dog extends SpeakableAnimal
{
	public Legs myLegs;
 	public Tail myTail;
 	public Nose myNose;
 	// Overloaded action
 	public void Speak()
 	{
 		System.out.println(“Ruff!”);
 	}
}
public class SpeakableAnimal extends Animal
{
 	public void Speak()
	{
 		// To be overloaded
 	}
}
public class Cat extends SpeakableAnimal
{
	public void Speak()
 	{
 		System.out.println(“Meow!”);
 	}
}

Movie Clips in Flash do not follow the exact same idea of polymorphism. Flash has an alternative viewpoint in objected oriented perspectives at this point. Movie Clips follow composition rather than inheritance and polymorphism. While MovieClips inherit actions from its parent Movie Clips, the parent is not ideologically the same as a super class in Java. A movie clip does not extend its parent; its parent composes of the movie clip. A Car movie clip will compose of an Engine which will have access to actionscript functions TurnOn()or Drive() defined in Car, but design-wise, Engine does not extend Car. Instead, Car has an Engine. This is where Flash’s attempt of visualizing object oriented programming starts to break down.

Flash also does not visually represent the concept of encapsulation. Encapsulation is the idea that the implementation of an action is not accessible. When a person is asked “What would be one word you would use to describe yourself” during a job interview, a thought process happens in the interviewee’s mind. What the process is the interviewer does not know; however, a one result is outputted to the interviewer by the interviewee. Since the interviewer cannot read minds, the thought process of the interviewee is considered encapsulated. In Java, classes, methods, and properties can be declared public or private. If the attribute is private, then it is used primarily for internal processes. An example could be finding the distance between two points on a two dimensional plane.

public void FindDistance(double x1, double y1, double x2, double y2)
{
	return Math.sqrt(Square(y1-y2)+Square(x1-x2));
}
private void Square(double n)
{
	return n*n;
}

FindDistance is a method that a user may use in their program, but the user does not know (or need to know) how that method works. The Square method is actually used by the FindDistance method, but since the user is not allowed and does not need to use the Square method, Square is declared as a private method.

Where OO programming loses its power is when describing abstract objects. For example, feelings and emotions cannot be developed easily. Love or Frustration can extend Feeling; however feelings are not necessarily objects because the concept of an object is arguably something tangible. Because Flash assumes all Movie Clips to be tangible, it is a much easier platform to develop on since positioning objects on the screen is much easier than in Java. In Java and in most programming languages, coordinates on a plane must be defined. In Flash, objects can simply be pasted on certain spots on the screen and the coordinates are automatically set into the objects.

Nevertheless, OO programming is overall a powerful language that allows programmers to design a system before actually coding a design. Especially in Flash, programmers can worry about designing a system rather than mulling over syntax. In Flash that system can be graphically represented, in Java that system can be programmatically represented, and in a designers mind that system can be ideologically represented.

My bad

Posted on August 16th, 2007 in Other | 1 Comment »

Someone reported to me that none of the links on the blog were working (including comments). Turned out to be a .htaccess problem. Fixed it.

My bad.

Ground Control to Major Tom

Posted on June 30th, 2007 in Other | 1 Comment »

I know I’m supposed to say something like “Welcome to my blog, here I’ll try to write about …” or something of the sorts.

Truth is, is that this is probably the 4th time I’ve started a blog. It’s not like I don’t have the time (and often I don’t) or have nothing to say (and often I don’t), it’s that I get lazy or preoccupied with other work.

But hey,  5th time’s a charm!