-
Notifications
You must be signed in to change notification settings - Fork 35
Difference between JavaScript and TurboScript
This page intended to understand what are the differences between JavaScript and TurboScript. Most of the JavaScript language features are available in TurboScript. For high performance programming TurboScript added more advanced features which are listed below.
TurboScript is a statically typed language. A language is statically typed if the type of a variable is known at compile time. This means that you as the programmer must specify what type each variable is, TurboScript also offer type inference, the capability of the type system to deduce the type of a variable. The main advantage here is that all kinds of checking can be done by the compiler, and therefore a lot of trivial bugs are caught at a very early stage. this is similar to TypeScript but in TurboScript static types are mandatory therefore TurboScript can be compiled to WebAssembly and asm.js efficiently. It is also possible to add more compiler targets in future like x86, ARM etc..
A pointer is a variable which holds the memory address of another variable. We can have a pointer to any variable type.
*AnyType
let ptr:*uint8;
//set memory region to zero
//let top = top_of_memory;
//let offset = start_address
let ptr = offset;
while (ptr < top) {
*(ptr as *uint32) = 0;
ptr = ptr + 4;
}
Customizes the JavaScript operators for operands of user-defined types. Overloaded operators are functions with special function names:
operator op
op
- any of the following 38 operators:+
-
*
/
%
ˆ
&
|
~
!
=
<
>
+=
-=
*=
/=
%=
ˆ=
&=
|=
<<
>>
>>=
<<=
==
!=
<=
>=
&&
||
++
--
,
->*
->
( )
[ ]