Most of you have probably noticed the new look of CodeRun.
In addition to the new website, this version is much faster and supports a broader range of browsers. Coderun now offers a new service called cloud hosting. This basically means that you can write your application and host it online, with a few simple clicks and no installed software at all. Check out the free trial.
Gilad created today a few videos that are well worth checking out:
Create: http://www.youtube.com/watch?v=M7fspIbpRGA
Debug: http://www.youtube.com/watch?v=Ccd5Ap-liFw
Deploy: http://www.youtube.com/watch?v=Hqv42zH7kz4
Cheers,
Alon.
Monday, October 5, 2009
Tuesday, July 14, 2009
CodeRun adds support for Visual Studio solutions
We are in the process of rolling out support for Visual Studio .SLN files, stay tuned!
Thursday, June 25, 2009
CodeRun gets a new debugger
I'm pleased to announce that CodeRun has a new debugger. Still a bit rough around the edges, but works very well. We'll continue improving it in the next few days.
Thursday, April 30, 2009
Javascript: The missing parts
Looking at the way YUI is modelled, I tried to figure out how their type system works.
As it turns out, there isn't one. There is no standard way of doing these things:
Problem: Method overloading.
Description: Some methods may accept different argument type and number of parameters, and behave differently for different combinations. Pro: API seems smaller. Con: API is a lot larger, you can't remember which combination does what.
Solution: Suffix _every_ method name with the argument types. It seems a bit too much at first, but if your not hand-writing the JS code (hint hint), it shouldn't be a problem. Also Intellisense would be more helpful, and less reference documentation would be required. When you think about it - that's cheating. There is no one overloaded methods, but different methods with different names.
Examples:
Problem: Multiple constructors
Description: Similar to method overloading, but the same solution will not work. You will end up by having N different prototypes, but you need only one. Also, instanceof will not work.
Solution 1: Instead of using many parameters, use an object literal as a single parameter. Pro: Solves the problem. Con: You will need to memorize or document the object literal. This is also valid for method overloading, but since you usually call more methods than constructors, and this does change the code structure, it is a better fit for this scenario.
Example:
Solution 2: A constructor has 4 parts to it: (1) Instance creation (2) Base ctor where applicable (3*) instance fields initialization and (4) ctor body. The new() operator does (1). You do the rest in your code. This code demonstrates what is being done:
Edit: Correction - I double checked with C# and apparently (3) occurs before (2). Instance members are initialized before the first statement of the ctor of their declaring type. So if class A is derived from class B, and both contain some field initializers, A's fields will be initialized before B's fields.
*Some languages (like C#) allow you to initialize instance fields in their declaration. They are initialized at construction time, between the base constructor call and the actual constructor code.
However, this does not fit in an expression, but rather in two statements. The solution is simple: have init() return the "this" instance. That way, you can write something like:
Since the new() operator takes precedence over the dot (.) operator, this expression does exactly what we need. the expression
More stuff next time. Cheers!
As it turns out, there isn't one. There is no standard way of doing these things:
Problem: Method overloading.
Description: Some methods may accept different argument type and number of parameters, and behave differently for different combinations. Pro: API seems smaller. Con: API is a lot larger, you can't remember which combination does what.
Solution: Suffix _every_ method name with the argument types. It seems a bit too much at first, but if your not hand-writing the JS code (hint hint), it shouldn't be a problem. Also Intellisense would be more helpful, and less reference documentation would be required. When you think about it - that's cheating. There is no one overloaded methods, but different methods with different names.
Examples:
Element.hide$Element(myElement);
Element.hide$Id("myElementId");
Element.hide$ElementArray(document.getElementsByTagName("p"));
Element.hide$IdArray(["id1","id2"]);
Problem: Multiple constructors
Description: Similar to method overloading, but the same solution will not work. You will end up by having N different prototypes, but you need only one. Also, instanceof will not work.
Solution 1: Instead of using many parameters, use an object literal as a single parameter. Pro: Solves the problem. Con: You will need to memorize or document the object literal. This is also valid for method overloading, but since you usually call more methods than constructors, and this does change the code structure, it is a better fit for this scenario.
Example:
var anim = new Animation({element:myElement});
var anim = new Animation({elementId:"myElementId", finished:function(){alert('done!');}});
Solution 2: A constructor has 4 parts to it: (1) Instance creation (2) Base ctor where applicable (3*) instance fields initialization and (4) ctor body. The new() operator does (1). You do the rest in your code. This code demonstrates what is being done:
var a = new Example.MyContact();
a.init("john","doe",31,"Mexico");
Edit: Correction - I double checked with C# and apparently (3) occurs before (2). Instance members are initialized before the first statement of the ctor of their declaring type. So if class A is derived from class B, and both contain some field initializers, A's fields will be initialized before B's fields.
*Some languages (like C#) allow you to initialize instance fields in their declaration. They are initialized at construction time, between the base constructor call and the actual constructor code.
However, this does not fit in an expression, but rather in two statements. The solution is simple: have init() return the "this" instance. That way, you can write something like:
myFunc(new Example.MyContact().init("john","doe",31,"Mexico"));
Since the new() operator takes precedence over the dot (.) operator, this expression does exactly what we need. the expression
a instanceof Example.MyContactevaluates to true. The code resembles the overloaded style we have in OO languages, with a tiny addition.
More stuff next time. Cheers!
Subscribe to:
Comments (Atom)
