Showing posts with label check javascript code. Show all posts
Showing posts with label check javascript code. Show all posts

Monday, December 7, 2009

Java Vs Python

There are three main language characteristics that make programmers more productive with Python than with Java.



Java
  1. statically typed
In Java, all variable names (along with their types) must be explicitly declared. Attempting to assign an object of the wrong type to a variable name triggers a type exception. That's what it means to say that Java is a statically typed language.
Java container objects (e.g. Vector and ArrayList) hold objects of the generic type Object, but cannot hold primitives such as int. To store an int in a Vector, you must first convert the int to an Integer. When you retrieve an object from a container, it doesn't remember its type, and must be explicitly cast to the desired type.

  1. verbose
"abounding in words; using or containing more words than are necessary"

  1. not compact

Python
  1. dynamically typed
In Python, you never declare anything. An assignment statement binds a name to an object, and the object can be of any type. If a name is assigned to an object of one type, it may later be assigned to an object of a different type. That's what it means to say that Python is a dynamically typed language.
Python container objects (e.g. lists and dictionaries) can hold objects of any type, including numbers and lists. When you retrieve an object from a container, it remembers its type, so no casting is required.

  1. concise (aka terse)
"expressing much in a few words. Implies clean-cut brevity, attained by excision of the superfluous"

  1. compact
In The New Hacker's Dictionary, Eric S. Raymond gives the following definition for "compact":
Compact adj. Of a design, describes the valuable property that it can all be apprehended at once in one's head. This generally means the thing created from the design can be used with greater facility and fewer errors than an equivalent tool that is not compact.


Thursday, August 20, 2009

Evaluate Your JavaScript

Usually people have hard time in evaluating their JavaScript code, I found a interesting tool which helps to evaluate the Javascript JSLint - The JavaScript Code Quality Tool. Its quiet easy to use; navigate to
http://www.jslint.com/
Example:
This will help ensure our code is compatible with IE 6 and IE 7.

Strict white space

Assume a browser

Disallow undefined variables

Disallow == and !=

Alternatively, you can add this line to your javascript. This will ensure these values are "checked".