Re:"Move" — a simpler programming language as a subset of Ja...
by andolanra on Monday February 14, 2011 @07:05AM
(#2216443)
Variables need not be explicitly declared. Move will
declare a newfound variable in the scope which it first
was used.
How does this interact with lexical scope? For example, how would the go-to counter example (in JavaScript below) be expressed in Move?
function makeCounter() {
var x = 0;
return function() {
return x++;
};
}
Does Move not require declarations because it has implicit declarations whenever there's a usage of any variable? (In which case the above example couldn't be expressed without some kind of circumlocution—again, like in Python.) Or are variables always looked up in the outermost scope, so you can't have a variable whose name is shared by another variable in an enclosing scope?
No commas required to terminate expressions. Move will
determine when a comma is needed so you don't have to
(and the code gets more readable).
Given that all the code has commas in the same places as in JavaScript, I'm going to assume s/comma/semicolon, and s/expression/statement, to be pedantic.
Re:"Move" — a simpler programming language as a subset of Ja...
by igorw on Monday February 14, 2011 @04:59AM
(#2216156)
> In JavaScript, there are two different ways to define a function: using the function expression and the function declaration statement, the latter having subtle restrictions. Move only has function expressions.
Except using named functions will also make your stack traces useful. Because function names tell you more than line numbers.
Re:"Move" — a simpler programming language as a subset of Ja...
by dpritchett on Monday February 14, 2011 @09:20AM
(#2216818)
CoffeeScript benefits from the work done on other JS dialects. Last year jashkenas rolled in "features and optimizations" from Coco which is itself a dialect of CoffeeScript [1].
The difference in the semantics of «==» is an example. Also, it does not have things that JS has, and has other things JS doesn't.
C# style: var item_names = $( "li.menu_item span" ).map( x => x.innerHTML )
JS style: var item_names = $( "li.menu_item span" ).map( function( x ) { return x.innerHTML } )
item_names = $("li.menu_item span").map (x) -> x.innerHTML
$("li.menu_item span").map(function(x) x.innerHTML)
for that particular exaple, you could also steal pluck() from Prototype.js:
$("li.menu_item span").pluck("innerHTML")
Except using named functions will also make your stack traces useful. Because function names tell you more than line numbers.
Step 2) Make it marginally more expressive
Step 3) ???
Step 4) Profit
http://en.wikipedia.org/wiki/Blocks_(C_language_extension)
http://news.ycombinator.com/item?id=2037996