js2coffee.org helps your learn coffeescript faster


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/bateeqjg/public_html/news/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/bateeqjg/public_html/news/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/bateeqjg/public_html/news/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

coffeescript icon
coffeescript icon

Coffee-script is a smoking hot simple language that converts 100% into Javascript code. Coffee-script allows you to spend more time focusing on the algorithm rather than the syntax.
js2coffee.org is an awesome website that converts your Coffee-script to Javascript and vice versa on the fly. So you can learn Coffee-script faster.
Example:
Let’s convert my Random Number Generator code from a previous post to Coffee-script.

// Javascript version
var getRandomNum = function( i, decLen ){
	return (Math.random() * (i||1) ).toFixed(decLen);
};

# My Coffee-script version
getRandomNum = ( i=1, decLen ) -> (Math.random()*i).toFixed(decLen)

# js2coffee.org Coffee-script verison
getRandomNum = (i, decLen) ->
	(Math.random() * (i or 1)).toFixed decLen

Awesome huh?

Check out a demo of Coffeescript here.

I’ll like to leave you with a HTML5 Coffee-script presentation.

Cheers.

Larry Battle

Larry Battle

I love to program, and discover new tech. Check out my <a href="http://stackoverflow.com/users/527776/larry-battle">stackoverflow</a> and <a href="https://github.com/LarryBattle">github</a> accounts.

More Posts - Website

Follow Me:Add me on XAdd me on LinkedInAdd me on YouTube

Siebel eScript headaches.


Here are a few problems that I’ve encountered while spending a week programming in Siebel eScript 7.8.

  1. Siebel eScript is ECMAScript compliant.
    ECMAScript is the standard implementation of JavaScript as defined by the ECMA-262 standard.
    Beginning with Siebel Business Applications version 7.8, the script engine supports ECMAScript Edition 4.
    You can opt to use the updated functionality of this engine, including the Siebel ScriptAssist tool, or you can opt to leave this updated functionality inactive.
    http://docs.oracle.com/cd/B31104_02/books/eScript/eScript_JSLOverview.html

    Here’s a link to ECMAScript Version 4.0. proposed draft.
    Example code for ES4.

    interface I { function f() } 
    interface J { function g(n) } 
    class C implements I, J { 
    	function f() { return "foo" } 
    	function g(n) { return n+2 } 
    }


    It should be noted that most major web browsers abandoned ES4 due it the complexity of feature implementations.
    So even if your scripts pass jshint.com and jslint.com 100%, and works on all major browsers you still have the possibility of your code throwing an during execution.
    Siebel eScript says it’s ECMA-262 compliant but I’ve found a few bugs in the engine that require some work around.

  2. Developing a simple way to unit test your code is essential.
    Here’s a easy way to add test function to your library.

    function logThis( name, result ){
    	// Log this values to a Property Set Object that get's converted to XML.
    	AddParameterPS( logObjs.Outputs, name, result, "logThis");
    }
    function testThis( name, func ){
    	try{
    		logThis( "Passed: "+ name, func() );
    	}
    	catch(e){
    		logThis( "Failed: "+ name, e );
    	}
    }


    Test example

    function runTest(Input, Output){
     
    	testThis( "Test strict equivalence support", function(){
    		return "1" !== 1;
    	});
    	// This will fail since Siebel doesn't support the apply and call Object function calls.
    	testThis( "Test isArray using call", function(){
    		// Siebel eScript: FAIL, Browser: Pass
    		function isArray( arr ){
    			return Object.prototype.toString.call( obj ) == "[Object Array]";
    		}
    	});
    	testThis( "Test isArray using instanceof", function(){
    		// Siebel eScript: Pass, Browser: Pass
    		function isArray( arr ){
    			return arr instanceof Array;
    		}
    	});
    }

  3. Siebel Business Applications in high-interactivity mode requires an ActiveX plugin, which forces you to use Internet Explorer on Windows.
  4. Siebel eScript has errors with it’s engine and it’s hard to debug eScripts for run-time business services.
    Here’s a strange bug in Siebel eScript.
    You can’t create return objects when they are generated from a function attached to an object.
    Example Code:

    	var x = {};
    	x.getObj = function( a, b ){
    		var obj = function(){
    			this.x = a;
    			this.y = b;
    		};
    		return new obj();
    	};
    	var getObj = function( a, b ){
    		var obj = function(){
    			this.x = a;
    			this.y = b;
    		};
    		return new obj();
    	};
    	var arr = [];
    	arr.push( getObj() );	// successful
    	arr.push( x.getObj() );	// Run-time Error.

  5. Siebel eScript engine is pretty damn slow. So avoid writing these two performance killers.
    1: Wrapping all your code within a closure.
    2: Defining an object inside closure with the same name as an object in the outer scope.
    Example:

    	var x = (function(){
    		var x = {
    			a:1
    		};
    		return x;
    	}());

Siebel eScript Reference from Oracle.com:
eScript Lanague Reference (2004 edition)

Larry Battle

Larry Battle

I love to program, and discover new tech. Check out my <a href="http://stackoverflow.com/users/527776/larry-battle">stackoverflow</a> and <a href="https://github.com/LarryBattle">github</a> accounts.

More Posts - Website

Follow Me:Add me on XAdd me on LinkedInAdd me on YouTube

Check out this awesome Coffeescript Tutorial



http://bodil.github.com/coffeescript/

Larry Battle

Larry Battle

I love to program, and discover new tech. Check out my <a href="http://stackoverflow.com/users/527776/larry-battle">stackoverflow</a> and <a href="https://github.com/LarryBattle">github</a> accounts.

More Posts - Website

Follow Me:Add me on XAdd me on LinkedInAdd me on YouTube

How to install Docco.coffee on Windows 7

Docco.coffee requires the following to run.

  1. Node.js
  2. Python
  3. CoffeeScript
  4. Pygments
  5. Docco

Step 1:
Download and install Node.js and Python 2.7. Python 3.2 might work but I haven’t yet tried it out.

Step 2:
Add the root and ‘node_modules’ directories for node.js and the root and “Script” directory for python 2.7 to your path environment variable.
C:\nodejs;%userprofile%\node_modules\.bin;C:\python27;C:\Python27\Scripts;

Step 3:
Open up a command prompt, start -> run -> type “cmd”.

Type npm install coffee-script
*You should see installation output on the screen*

Type npm install docco
*You should see installation output on the screen*

Step 4:
Download ez_setup
In command prompt, navigate to where you downloaded ez_setup.py.
Type in python ez_setup.py.

Step 5:
In command prompt type easy_install pygments to install Pygments.

Done.

Test
Download ‘underscore.js’ to your desktop.

Open up a command prompt and type in docco %userprofile%\desktop\underscore.js.
You should see two output files, “p” and “docs”.
The annotated source code is the html file in the docs folder.

Enjoy!

Larry Battle

Larry Battle

I love to program, and discover new tech. Check out my <a href="http://stackoverflow.com/users/527776/larry-battle">stackoverflow</a> and <a href="https://github.com/LarryBattle">github</a> accounts.

More Posts - Website

Follow Me:Add me on XAdd me on LinkedInAdd me on YouTube