Coming from JavaScript?
Below, you'll find how JavaScript language compare to Nox. A lot of things are similar.
Literals
JavaScript
Nox
3
3
3.1415
3.1415
"Hello world!"
"Hello world!"
`Multiline
string`
`Multiline
string`
'Hello world!'
'Hello world!'
`Hello, ${ name }!`
'Hello, { name }!'
No distinction between characters and strings
No distinction between characters and strings either
true
True
false
False
[1, 2, 3]
[1, 2, 3]
[1, 'hello', true]
(1, 'hello', True)
Records
JavaScript
Nox
{ x: 3, y: 4 }
{ x = 3, y = 4 }
point.x
point.x
point.x = 42
(TODO: Still figuring this out)
Functions
JavaScript
Nox
function f(x, y) { return x + y; }
func f(x, y) { return x + y }
(x, y) => x + y
(x, y) => x + y
Math.max(3, 4)
math.max(3, 4)
Math.min(1, Math.pow(2, 4))
math.min(1, math.pow(2,4))
(TODO: Support 2^4 syntax instead of pow)
numbers.map(Math.sqrt)
numbers.map(math.sqrt)
points.map(function(p) { return p.x })
points.map(p => p.x)
(TODO: Support .map(.x) syntax)
Control Flow
JavaScript
Nox
3 > 2 ? 'cat' : 'dog'
3 > 2 ? 'cat' : 'dog'
var x = 42; ...
x = 42
return 42
return 42
(TODO: Do we want to keep the explicit return keyword?)
Strings
JavaScript
Nox
'abc' + '123'
'abc' + '123'
(TODO: or do we need 'abc' ++ '123' to distinguish from arithmetic ops)
'abc'.length
'abc'.size()
'abc'.toUpperCase()
'abc'.to_upper()
'abc' + 123
'abc' + 123.to_str()
(TODO: or ++, see above)
Last updated
Was this helpful?