<s>
AssemblyScript	B-Application
is	O
a	O
TypeScript-based	O
programming	O
language	O
that	O
is	O
optimized	O
for	O
,	O
and	O
statically	B-Application
compiled	I-Application
to	O
,	O
WebAssembly	B-Language
(	O
currently	O
using	O
,	O
the	O
reference	O
AssemblyScript	B-Application
compiler	O
)	O
.	O
</s>
<s>
Resembling	O
ECMAScript	B-Language
and	O
JavaScript	B-Language
,	O
but	O
with	O
static	O
types	O
,	O
the	O
language	O
is	O
developed	O
by	O
the	O
AssemblyScript	B-Application
Project	O
with	O
contributions	O
from	O
the	O
AssemblyScript	B-Application
community	O
.	O
</s>
<s>
In	O
2017	O
,	O
the	O
availability	O
of	O
support	O
for	O
WebAssembly	B-Language
,	O
a	O
standard	O
definition	O
for	O
a	O
low-level	O
bytecode	O
and	O
an	O
associated	O
virtual	B-Architecture
machine	I-Architecture
,	O
became	O
widespread	O
among	O
major	O
Web	B-Application
browsers	I-Application
,	O
providing	O
Web	O
developers	O
a	O
lower-level	O
and	O
potentially	O
higher-performance	O
compilation	O
target	O
for	O
client-side	B-Operating_System
programs	O
and	O
applications	O
to	O
execute	O
within	O
Web	B-Application
browsers	I-Application
,	O
in	O
addition	O
to	O
the	O
interpreted	B-Application
(	O
and	O
in	O
practice	O
dynamically	O
compiled	O
)	O
JavaScript	B-Language
Web	O
scripting	O
language	O
.	O
</s>
<s>
WebAssembly	B-Language
allows	O
programs	O
and	O
code	O
to	O
be	O
statically	B-Application
compiled	I-Application
ahead	O
of	O
time	O
in	O
order	O
to	O
run	O
at	O
potentially	O
native-level	O
or	O
“	O
bare-metal	O
”	O
performance	O
within	O
Web	B-Application
browsers	I-Application
,	O
without	O
the	O
overhead	O
of	O
interpretation	O
or	O
the	O
initial	O
latency	O
of	O
dynamic	O
compilation	O
.	O
</s>
<s>
With	O
the	O
adoption	O
of	O
WebAssembly	B-Language
in	O
major	O
Web	B-Application
browsers	I-Application
,	O
Alon	O
Zakai	O
,	O
creator	O
of	O
Emscripten	B-Language
,	O
an	O
LLVM/Clang	O
-based	O
C	B-Language
and	O
C++	B-Language
compiler	O
that	O
targeted	O
a	O
subset	O
of	O
JavaScript	B-Language
called	O
asm.js	B-Language
,	O
added	O
support	O
for	O
WebAssembly	B-Language
as	O
a	O
compilation	O
target	O
in	O
Emscripten	B-Language
,	O
allowing	O
C	B-Language
and/or	O
C++	B-Language
programs	I-Language
and	O
code	O
to	O
be	O
compiled	O
directly	O
to	O
WebAssembly	B-Language
.	O
</s>
<s>
While	O
Emscripten	B-Language
and	O
similar	O
compilers	O
allow	O
Web	O
developers	O
to	O
write	O
new	O
code	O
,	O
or	O
port	O
existing	O
code	O
,	O
written	O
in	O
a	O
high-level	O
language	O
such	O
as	O
C	B-Language
,	O
C++	B-Language
,	O
Go	B-Application
,	O
and	O
Rust	B-Application
to	O
WebAssembly	B-Language
to	O
achieve	O
potentially	O
higher	O
,	O
native-level	O
execution	O
performance	O
in	O
Web	B-Application
browsers	I-Application
,	O
this	O
forces	O
Web	O
developers	O
accustomed	O
to	O
developing	O
client-side	B-Operating_System
Web	O
scripts	O
and	O
applications	O
in	O
ECMAScript/JavaScript	O
(	O
the	O
de	O
facto	O
client-side	B-Operating_System
programming	O
language	O
in	O
Web	B-Application
browsers	I-Application
)	O
to	O
use	O
a	O
different	O
language	O
for	O
targeting	O
WebAssembly	B-Language
than	O
JavaScript	B-Language
.	O
</s>
<s>
AssemblyScript	B-Application
,	O
as	O
a	O
variant	O
of	O
TypeScript	B-Language
that	O
is	O
syntactically	O
similar	O
to	O
JavaScript	B-Language
,	O
allows	O
developers	O
accustomed	O
to	O
JavaScript	B-Language
to	O
use	O
a	O
familiar	O
language	O
for	O
targeting	O
WebAssembly	B-Language
,	O
potentially	O
reducing	O
the	O
learning	O
curve	O
of	O
a	O
separate	O
language	O
that	O
can	O
be	O
compiled	O
to	O
WebAssembly	B-Language
.	O
</s>
<s>
Furthermore	O
,	O
because	O
AssemblyScript	B-Application
was	O
designed	O
to	O
be	O
an	O
optimal	O
source	O
language	O
for	O
WebAssembly	B-Language
,	O
the	O
language	O
’s	O
type	O
system	O
closely	O
reflects	O
that	O
of	O
WebAssembly	B-Language
,	O
and	O
the	O
language	O
provides	O
standard	O
low-level	O
functions	O
(	O
typically	O
implemented	O
as	O
macros	O
)	O
that	O
map	O
directly	O
to	O
WebAssembly	B-Language
instructions	O
that	O
mirror	O
instructions	O
available	O
on	O
modern	O
processors	O
such	O
as	O
SIMD	B-Device
and	O
vector	B-Operating_System
instructions	O
and	O
more	O
specialized	O
instructions	O
such	O
as	O
clz	O
(	O
count	O
leading	O
zero	O
bits	O
)	O
,	O
ctz	O
(	O
count	O
trailing	O
zero	O
bits	O
)	O
,	O
and	O
popcnt	O
(	O
population	O
count	O
)	O
,	O
used	O
in	O
applications	O
such	O
as	O
encryption	O
and	O
cryptographic	O
libraries	O
.	O
</s>
<s>
,	O
the	O
reference	O
AssemblyScript	B-Application
compiler	O
,	O
is	O
based	O
on	O
Binaryen	O
,	O
a	O
back-end	O
compiler	O
toolchain	O
developed	O
by	O
Alon	O
Zakai	O
that	O
compiles	O
to	O
WebAssembly	B-Language
and	O
is	O
a	O
component	O
of	O
Emscripten	B-Language
(	O
which	O
Zakai	O
also	O
developed	O
)	O
.	O
</s>
<s>
The	O
compiler	O
and	O
other	O
tooling	O
are	O
available	O
via	O
the	O
npm	B-Language
package	O
manager	O
.	O
</s>
<s>
While	O
WebAssembly	B-Language
was	O
originally	O
designed	O
for	O
execution	O
within	O
Web	B-Application
browsers	I-Application
,	O
the	O
development	O
of	O
WASI	O
(	O
WebAssembly	B-Language
System	O
Interface	O
)	O
,	O
a	O
community	O
specification	O
for	O
a	O
standard	O
API	B-General_Concept
that	O
allows	O
WebAssembly	B-Language
programs	O
access	O
to	O
system	B-Operating_System
calls	I-Operating_System
and	O
other	O
operating	B-General_Concept
system	I-General_Concept
functions	O
,	O
has	O
led	O
to	O
the	O
development	O
of	O
WebAssembly	B-Language
runtime	B-Device
environments	I-Device
from	O
projects	O
such	O
as	O
Wasmtime	O
and	O
Wasmer	O
that	O
allow	O
WebAssembly	B-Language
,	O
and	O
code	O
written	O
in	O
languages	O
such	O
as	O
AssemblyScript	B-Application
that	O
can	O
compile	O
to	O
it	O
,	O
to	O
run	O
in	O
non-Web	O
environments	O
as	O
well	O
.	O
</s>
<s>
AssemblyScript	B-Application
is	O
compiled	O
to	O
WebAssembly	B-Language
modules	O
,	O
which	O
can	O
then	O
be	O
instantiated	O
into	O
client-side	B-Operating_System
Web	O
pages	O
using	O
standard	O
JavaScript	B-Language
methods	O
such	O
as	O
WebAssembly.compileStreaming	O
and	O
WebAssembly.instantiateStreaming	O
just	O
like	O
standard	O
WebAssembly	B-Language
binaries	O
.	O
</s>
<s>
Data	O
passing	O
between	O
JavaScript	B-Language
and	O
the	O
compiled	O
WebAssembly	B-Language
modules	O
,	O
as	O
well	O
as	O
function	O
calls	O
between	O
JavaScript	B-Language
and	O
WebAssembly	B-Language
,	O
are	O
then	O
the	O
same	O
as	O
for	O
any	O
WebAssembly	B-Language
module	O
.	O
</s>
<s>
Because	O
the	O
AssemblyScript	B-Application
language	O
is	O
largely	O
a	O
subset	O
of	O
TypeScript	B-Language
,	O
it	O
is	O
theoretically	O
possible	O
to	O
write	O
an	O
AssemblyScript	B-Application
program	O
using	O
this	O
subset	O
and	O
compile	O
it	O
to	O
both	O
plain	O
JavaScript	B-Language
and	O
WebAssembly	B-Language
,	O
using	O
the	O
TypeScript	B-Language
compiler	O
and	O
AssemblyScript	B-Application
compiler	O
,	O
respectively	O
.	O
</s>
<s>
This	O
potentially	O
allows	O
for	O
portable	O
code	O
that	O
can	O
be	O
deployed	O
in	O
either	O
JavaScript	B-Language
or	O
WebAssembly	B-Language
run-time	B-Device
environments	I-Device
.	O
</s>
<s>
more	O
than	O
12,000	O
projects	O
hosted	O
on	O
GitHub	B-Application
are	O
written	O
,	O
either	O
wholly	O
or	O
partially	O
,	O
in	O
AssemblyScript	B-Application
,	O
with	O
roughly	O
18,000	O
downloads	O
of	O
the	O
AssemblyScript	B-Application
compiler	O
per	O
week	O
via	O
npm	B-Language
.	O
</s>
<s>
In	O
2021	O
,	O
Webpack	B-Language
started	O
using	O
AssemblyScript	B-Application
to	O
speed	O
up	O
the	O
calculation	O
of	O
hash	O
functions	O
such	O
as	O
xxhash	O
and	O
md4	O
.	O
</s>
<s>
Lead	O
Emscripten	B-Language
developer	O
Alon	O
Zakai	O
has	O
characterized	O
AssemblyScript	B-Application
as	O
being	O
“	O
designed	O
with	O
WebAssembly	B-Language
and	O
code	O
size	O
in	O
mind	O
.	O
</s>
<s>
It	O
’s	O
not	O
an	O
existing	O
language	O
that	O
we	O
are	O
using	O
for	O
a	O
new	O
purpose	O
,	O
but	O
it	O
’s	O
a	O
language	O
designed	O
for	O
WebAssembly	B-Language
.	O
</s>
<s>
Aaron	O
Turner	O
,	O
a	O
senior	O
engineer	O
at	O
Fastly	B-General_Concept
,	O
a	O
cloud	O
computing	O
services	O
provider	O
that	O
uses	O
WebAssembly	B-Language
for	O
the	O
company	O
’s	O
Compute	O
@Edge	O
serverless	O
compute	O
environment	O
,	O
in	O
a	O
review	O
of	O
AssemblyScript	B-Application
wrote	O
:	O
</s>
<s>
While	O
AssemblyScript	B-Application
requires	O
stricter	O
typing	O
than	O
TypeScript	B-Language
does	O
,	O
it	O
sticks	O
as	O
close	O
as	O
possible	O
to	O
TypeScript	B-Language
syntax	O
and	O
semantics	O
—	O
which	O
means	O
that	O
most	O
JavaScript	B-Language
developers	O
will	O
find	O
AssemblyScript	B-Application
comfortable	O
to	O
use	O
—	O
and	O
it	O
enables	O
great	O
support	O
for	O
the	O
modern	O
JavaScript	B-Language
ecosystem	O
.	O
</s>
<s>
For	O
instance	O
,	O
the	O
AssemblyScript	B-Application
compiler	O
is	O
available	O
on	O
,	O
as	O
well	O
as	O
common	O
AssemblyScript	B-Application
tools	O
and	O
libraries	O
like	O
.	O
</s>
<s>
AssemblyScript	B-Application
files	O
also	O
use	O
TypeScript	B-Language
’s	O
‘’	O
file	O
extension	O
,	O
and	O
it	O
includes	O
proper	O
typings	O
for	O
allowing	O
AssemblyScript	B-Application
to	O
piggy-back	O
on	O
TypeScript	B-Language
tooling	O
,	O
such	O
as	O
the	O
TypeScript	B-Language
linter	O
.	O
</s>
<s>
With	O
the	O
right	O
small	O
tweaks	O
,	O
AssemblyScript	B-Application
can	O
even	O
be	O
used	O
with	O
the	O
TypeScript	B-Language
compiler	O
.	O
</s>
<s>
This	O
is	O
very	O
exciting	O
,	O
as	O
AssemblyScript	B-Application
offers	O
a	O
low-overhead	O
entry-point	O
for	O
JavaScript	B-Language
developers	O
to	O
pick	O
up	O
a	O
language	O
to	O
output	O
WebAssembly	B-Language
—	O
both	O
in	O
terms	O
of	O
learning	O
to	O
read	O
and	O
write	O
AssemblyScript	B-Application
,	O
as	O
well	O
as	O
using	O
a	O
lot	O
of	O
the	O
pre-existing	O
tooling	O
that	O
may	O
already	O
be	O
in	O
a	O
JavaScript	B-Language
developer	O
’s	O
workflow	O
.	O
</s>
<s>
AssemblyScript	B-Application
is	O
often	O
referred	O
to	O
in	O
the	O
WebAssembly	B-Language
community	O
as	O
a	O
great	O
gateway	O
to	O
picking	O
up	O
WebAssembly	B-Language
.	O
</s>
<s>
It	O
offers	O
a	O
large	O
group	O
of	O
developers	O
who	O
already	O
write	O
applications	O
for	O
the	O
web	O
a	O
path	O
to	O
pick	O
up	O
and	O
learn	O
WebAssembly	B-Language
.	O
</s>
<s>
Even	O
if	O
you	O
are	O
starting	O
from	O
scratch	O
and	O
are	O
not	O
particularly	O
familiar	O
with	O
JavaScript	B-Language
or	O
TypeScript	B-Language
,	O
AssemblyScript	B-Application
is	O
a	O
solid	O
choice	O
when	O
picking	O
a	O
language	O
to	O
start	O
outputting	O
WebAssembly	B-Language
.	O
</s>
