Following on from the recent discussions on ecmascript as a compiler target
and Brendan's point re targeting the AST, I have coded a user-friendly
pseudocode-ish syntax which targets the V8 ecmascript AST: 'zedscript'
aka 'zed is ecmascript for dummies'. (And given the focus of the list
i won't be posting followup's - but i hope it may be of interest to some
readers).
The code can be found at:
code.google.com/p/zedscript
Zedscript runs in the V8 ecmascript engine. That is, there is no
parsing zedscript source -> javascript source phase. It targets the
AST directly.
The V8 scanning/parsing source code has been altered to allow the V8
engine to compile and run both ecmascript and zedscript. It reuses the V8
tokens/scanning/parsing/runtime/errorhandling machinery. This reduces
abstraction leakages and aids debugging. zedscript can call ecmascript
and vice-versa. (Calling jsfunction.toString() can be surprising however!).
A zedscript script can be run via the V8 shell:
./shell <zedscriptfile>
So, zedscript provides a thin layer of syntax sugar over the core
ecmascript semantics which will (hopefully):
* show the emerging rich 3.1 and 4(Harmony) semantics in the best
possible best light.
* minimizes quirks and gotchas.
* emphasize simplify, security, safety and speed. For instance
ecmascript 3.1 'strict mode' could be enabled by default.
* is not a port of existing languages e.g python, ruby. (Imho
emcascript does not need 1001IronXXX ports.
It needs one good alternate syntax - which can take inspiration
from the sugar/syntax of other pragmatic languages - but can be
considered a dialect of the core ecmascript semantics rather than
a new language or port).
* hits the sweet spot between succinctness and pseudocode readability.
The goal is to track ecmascript 3.1 and 4/Harmony and deliver
zedscript 3.1 and 4 on the V8 engine. (And maybe on tracemonkey and
sfx/nitro). It could be considered a synthesis of Brendan's goal of sugar
for es4 and Douglas Crockford's idea re a 'new' language. I feel that some
users - especially those without a comp. sci background - will never get on
with the curlies syntax. An alternate syntax in addition to the
javascript syntax
especially for esHarmony - could really help promote ecmascript as a general
purpose scripting language. Even if something like this never gets into the
browser it would be useful for server and desktop development.
Here an example 'ztest/sample.js'. Note how the script begins with
//zed to signal to V8 it's a zedscript file.
(This is a temporary solution).
//zed
// - currently has a dylan/moo -ish syntax
// - the parens around the expression could change to
// a more ruby/lua -ish syntax, with optional do/then.
print("*** start\n")
var x = 10
var y = 20
// if has elif clauses
// and/or are aliases for &&/||
if (x == -99)
print("FAIL")
elif (x == 10 and y > 15)
print("OK")
elif (x == -99 or y > -99)
print("FAIL")
else
print("FAIL")
end
// not as alias for !
var b = false;
print(!b)
print(not b)
// fn as alias for function
fn times2(i)
return i * 2
end
var z = 1
while (z <= 5)
print(z + " : " + times2(z++))
end
print("\n*** end ");
Following on from the recent discussions on ecmascript as a compiler target
and Brendan's point re targeting the AST, I have coded a user-friendly
pseudocode-ish syntax which targets the V8 ecmascript AST: 'zedscript'
aka 'zed is ecmascript for dummies'. (And given the focus of the list
i won't be posting followup's - but i hope it may be of interest to some
readers).
The code can be found at:
http://code.google.com/p/zedscript/
Zedscript runs _in_ the V8 ecmascript engine. That is, there is no
parsing zedscript source -> javascript source phase. It targets the
AST directly.
The V8 scanning/parsing source code has been altered to allow the V8
engine to compile and run both ecmascript and zedscript. It reuses the V8
tokens/scanning/parsing/runtime/errorhandling machinery. This reduces
abstraction leakages and aids debugging. zedscript can call ecmascript
and vice-versa. (Calling jsfunction.toString() can be surprising however!).
A zedscript script can be run via the V8 shell:
./shell <zedscriptfile>
So, zedscript provides a thin layer of syntax sugar over the core
ecmascript semantics which will (hopefully):
* show the emerging rich 3.1 and 4(Harmony) semantics in the best
possible best light.
* minimizes quirks and gotchas.
* emphasize simplify, security, safety and speed. For instance
ecmascript 3.1 'strict mode' could be enabled by default.
* is not a port of existing languages e.g python, ruby. (Imho
emcascript does not need 1001IronXXX ports.
It needs one good alternate syntax - which can take inspiration
from the sugar/syntax of other pragmatic languages - but can be
considered a dialect of the core ecmascript semantics rather than
a new language or port).
* hits the sweet spot between succinctness and pseudocode readability.
The goal is to track ecmascript 3.1 and 4/Harmony and deliver
zedscript 3.1 and 4 on the V8 engine. (And maybe on tracemonkey and
sfx/nitro). It could be considered a synthesis of Brendan's goal of sugar
for es4 and Douglas Crockford's idea re a 'new' language. I feel that some
users - especially those without a comp. sci background - will never get on
with the curlies syntax. An alternate syntax in addition to the
javascript syntax
- especially for esHarmony - could really help promote ecmascript as a general
purpose scripting language. Even if something like this never gets into the
browser it would be useful for server and desktop development.
Here an example 'ztest/sample.js'. Note how the script begins with
//zed to signal to V8 it's a zedscript file.
(This is a temporary solution).
//zed
// - currently has a dylan/moo -ish syntax
// - the parens around the expression could change to
// a more ruby/lua -ish syntax, with optional do/then.
print("*** start\n")
var x = 10
var y = 20
// if has elif clauses
// and/or are aliases for &&/||
if (x == -99)
print("FAIL")
elif (x == 10 and y > 15)
print("OK")
elif (x == -99 or y > -99)
print("FAIL")
else
print("FAIL")
end
// not as alias for !
var b = false;
print(!b)
print(not b)
// fn as alias for function
fn times2(i)
return i * 2
end
var z = 1
while (z <= 5)
print(z + " : " + times2(z++))
end
print("\n*** end ");
----------------------
Following on from the recent discussions on ecmascript as a compiler target and Brendan's point re targeting the AST, I have coded a user-friendly pseudocode-ish syntax which targets the V8 ecmascript AST: 'zedscript' aka 'zed is ecmascript for dummies'. (And given the focus of the list i won't be posting followup's - but i hope it may be of interest to some readers). The code can be found at: code.google.com/p/zedscript
Zedscript runs in the V8 ecmascript engine. That is, there is no parsing zedscript source -> javascript source phase. It targets the
AST directly.
The V8 scanning/parsing source code has been altered to allow the V8 engine to compile and run both ecmascript and zedscript. It reuses the V8 tokens/scanning/parsing/runtime/errorhandling machinery. This reduces abstraction leakages and aids debugging. zedscript can call ecmascript and vice-versa. (Calling jsfunction.toString() can be surprising however!).
A zedscript script can be run via the V8 shell: ./shell <zedscriptfile>
So, zedscript provides a thin layer of syntax sugar over the core ecmascript semantics which will (hopefully):
The goal is to track ecmascript 3.1 and 4/Harmony and deliver zedscript 3.1 and 4 on the V8 engine. (And maybe on tracemonkey and sfx/nitro). It could be considered a synthesis of Brendan's goal of sugar for es4 and Douglas Crockford's idea re a 'new' language. I feel that some users - especially those without a comp. sci background - will never get on with the curlies syntax. An alternate syntax in addition to the javascript syntax
Here an example 'ztest/sample.js'. Note how the script begins with //zed to signal to V8 it's a zedscript file. (This is a temporary solution).
//zed // - currently has a dylan/moo -ish syntax // - the parens around the expression could change to // a more ruby/lua -ish syntax, with optional do/then.
print("*** start\n")
var x = 10 var y = 20
// if has elif clauses // and/or are aliases for &&/|| if (x == -99) print("FAIL") elif (x == 10 and y > 15) print("OK") elif (x == -99 or y > -99) print("FAIL") else print("FAIL") end
// not as alias for ! var b = false; print(!b) print(not b)
// fn as alias for function fn times2(i) return i * 2 end
var z = 1 while (z <= 5) print(z + " : " + times2(z++)) end
print("\n*** end ");