►
From YouTube: Numerical Computing in JavaScript by Mikola Lysenko
Description
Numerical Computing in JavaScript - Mikola Lysenko
A
Hi
thanks
for
coming
out
here
for
this
talk,
so
my
name
is
mccullough
on
github
I'm
at
McCullough,
Y
Cinco,
so
here's
my
profile
I
currently
work
at
its
cooperative,
which
is
a
worker
on
coop
based
out
of
Hawaii,
and
today
I'm
gonna
talk
about
numerical
computing,
so
I'm
gonna
start
with
these
clipart
images
here.
So
so
just
bear
with
me
for
a
moment.
So
each
of
these
images
is
illustrating
something
that
might
be
you
know,
maybe
considered
a
hot
or
extremely
exciting,
emerging
area
in
computing
of
some
sort.
A
So
we
have
things
like
augmented
or
virtual
reality.
Data
visualization,
distributed
manufacturing,
3d,
printing,
deep
learning
and
the
one
thing
I
want
to
draw
everyone's
attention
to
with
all
of
them
is
that
a
critical
component
for
each
of
these
new
or
emerging
areas
is
numerical
computing
all
right.
So
what
is
numerical
computing
right?
And
so
when?
Why
should
you
care
about
it?
A
So
there's
maybe
a
couple
of
different
ways
to
look
at
it,
but
broadly
I
would
say:
there's
two
main
ingredients
to
it,
which
is
computing
with
large
arrays
of
numbers
so
like
computing
with
a
bunch
of
numbers
like
tensors
or
arrays,
or
matrices
and
high-performance
numerical
algorithms
that
would
operate
on
these
giant.
Tensors
are
n,
dimensional,
arrays.
A
So
another
way
to
think
about
this
is
it's
calculus
and
linear
algebra
with
computers,
and
this
is
important
because
it
turns
out
you
know.
Recent
advances
and
everything
ranging
from
natural
language
processing
to
computer
vision
are
all
built
on
fast
computations,
using
these
giant
arrays
of
numbers,
and
so
why
I
do
this
all
in
JavaScript?
Well,
so
that's
like
the
second
part
of
this
talk,
so
the
the
main
reason
is
you
want
to
do
this
on
the
web
right.
A
So
at
the
moment
the
web
is
pretty
much
the
last
major
application
platform
which
isn't
controlled
completely
by
some
private
company.
So
if
you
want
to
actually
go
out
there
and
build
things
and
get
them
directly
to
your
customers
without
having
to
go
through
some
intermediate
app
store,
the
web
is
the
only
show
in
town.
A
Also,
the
web
is
great
for
creating
accessible
explanations,
so
I'm
going
to
pull
a
slide
out
here
from
bread,
Viktor,
and
so
these
are
a
collection
of
different
visualizations
which
all
run
on
a
client
illustrating
different
concepts.
So,
for
example,
this
one
shows
how
you
know
you
can
understand
segregation
in
terms
of
you
know,
processes
like
objects,
moving
from
one
place
to
the
other,
and
if
we
would
like
to
create
these
sort
of
you
know,
data
visualizations
and
allow
them
to
run
on
a
client
and
allow
people
to
interact
with
them.
A
So
then
people
can,
you
know,
change
different
parameters
and
see
how
it
works
and
then
learned
something
from
that
model
and
then
finally,
like
Java
Script,
has
the
largest
and
most
active
development
community
in
the
entire
world
right
now,
so
we
have
all
of
these
capabilities
with
numerical
computing
that
are,
you
know,
available
to
us
and
we
would
like
to
make
it
more
democratic
and
accessible
so
that
more
people
can
pick
these
things
up
and
start
doing
something
with
it.
So
we
would
like
to
have
people
you
know.
Grab
these.
A
You
know
advanced
computer
vision
or
numerical
algorithms
and
take
them
and
put
them
into
their
browser.
So
that's
sort
of
a
high-level
view
for
what
this
talk
is
about.
So
I'm,
going
to
now
give
a
couple
of
examples
of
numerical
computing
on
the
web
in
a
browser.
Alright,
so
so
here
is,
for
example,
an
elastic
wave
that
can
be
simulated,
so
you
can
do
things
like
physics,
stimulation
running
in
a
browser,
and
this
is
all
just
WebGL
like
running
on
a
client.
A
We
can
do
things
like
3d
modeling,
so
I
can
you
know,
use
like
my
browser
here
to
generate
some
little
shape
using
GLSL
and
I
can
render
it
here
and
then
generate
like
a
mesh
from
it
and
then
zoom
in
and
out.
I
can
also
create
creative
audio
reactive
visualizations.
So
this
is
actually
reading
input
from
the
microphone
right
here
and
then
rendering
it.
So
this
is
also
using,
like
some
numerical
components.
A
This
is
another
demo
that
I've
made.
So
this
is
actually
some
neuron
data
which
has
been
taken
from
mouse,
brain
and
so
I
can
adjust
these
like
little
sliders
here
and
then
this
volume
in
real
time
and
do
different
processing
on
it
completely
in
a
web
browser
again
right.
So
this
is
all
just
running
in
JavaScript
on
here
and
then
last
I
can
do
things
like
deep
learning
in
a
web
browser.
A
So
this
is
a
standard
immunised
benchmark
and
I
can
you
know,
draw
a
digit
and
then
a
neural
network
which
is
running
in
my
browser.
Right
now
is
actually
reading
these
symbols
and
then
using
it
to
you,
know,
convert
these
pixels
that
I
draw
over
here
into
digits
right,
and
this
is
all
happening
in
JavaScript
on
the
client
in
my
web
browser
alright,
and
we
can
also
see
more
advanced
examples
of
this
using
things
like
Kara
SJS,
which
allows
for
you
know,
fancier
models
to
work
in
a
client.
A
A
Also
javascript
doesn't
have
a
concept
of
threads,
so
we
can't
use
multi-threading
and
we
don't
have
things
like
typed
objects
or
values,
so
memory
management
becomes
very
difficult
in
JavaScript,
but
that
said,
though,
these
are
not
unique
to
JavaScript,
so
Java
is
also
used
in
many
cases
for
doing
this
and
has
the
same
exact
problems.
Similar
problems
exist
in
Python
and
other
languages,
which
have
also
been
successfully
used
for
doing
numerical
computing.
So
in
Python
you
still
have
things
like
a
global
interpreter,
lock
right.
A
So
you
know
that
we
have
these
language
problems
is
not
insurmountable.
We
can
still
get
stuff
done,
but
there
are
other
issues
in
the
broader
ecosystem.
So
we
don't
have
something
like
a
standard,
multi-dimensional
array.
Data
type
in
JavaScript,
and
so
we
have
to
you
know,
do
a
bunch
of
data
conversion
from
one
format
to
another,
which
is
an
efficient
and
slow.
A
We
also
have
problems
with
native
bindings
in
JavaScript
that
are
not
press
in
other
languages
and
there's
also
this
larger
cultural
inertia
in
the
numerical
computing
community
and
in
the
JavaScript
community
in
order
to
get
people
involved
and
actually
doing
stuff
with
this
stuff.
So
these
are
the
sort
of
problems
that
we
have
to
overcome
in
order
to
do
numerical
computing
in
JavaScript
and
there
are
there's
some
progress
on
them.
A
So
on
these
first
points
here,
if
for
the
operator
overloading
and
Cindy
stuff,
there
is
progress
right
now
in
es7,
you
know
the
next
iteration
of
JavaScript
and
in
the
tc39
community
are
the
tc39
to
ultimately
try
to
fix
some
of
this,
so
I
have
some
faith
that
that
will
ultimately
get
done,
and
these
other
issues
are
things
that
we
can
actually
solve
ourselves
in
user
space
without
having
to
go
all
the
way
to
the
level
of
some
standards
board.
So
let's
go
now
into
some
details
for
how
we
might
be
able
to
solve.
A
This
are
a
possible
set
of
prescriptions
for
these
problems,
so
the
first
is
multi-dimensional
arrays,
so
the
current
state
of
JavaScript
is
we
have
a
bunch
of
different
approaches.
The
one
which
I've
seen
most
commonly
adopted
is
perhaps
this
raise
of
a
raised
technique.
So
the
idea
is
that
you
want
to
create
a
multi-dimensional
array,
so
you
just
make
an
array
of
arrays
and
just
do
that
recursively.
However
many
times
in
order
to
go,
you
know
create
your
n
dimensional
array.
A
Also,
you
have
to
store
all
these
extra
pointers
to
all
these
other
array
objects,
and
so
that
requires
n
to
the
D
minus
one
extra
space,
and
if
you
do
a
traversal
of
this
right,
because
you
have
all
these
indirect
cache,
lookups
you're,
basically
paying
this
extra.
You
know
D
times
n
to
the
D
traversal
right,
and
if
you
want
to
make
a
copy
of
this
thing,
then
you
just
have
to
go
through
and
slice
all.
The
pointers
which
is
really
slow,
so
arrays
of
arrays
are
actually
like.
This
is
like
just
laughably
inefficient.
A
So
if
you're
writing
and
something
like
C
or
Fortran,
you
would
probably
do
it
like
this
right.
You
would
just
take
a
regular
flat
array
or
a
typed
array
if
you
were
doing
it
in
JavaScript
and
you
just
lexicographically
flatten
the
entire
array
out.
So
the
advantage
this
is
that
you're
not
wasting
any
extra
space
right
like
there's.
None
of
these
extra
pointers
spinning
around.
If
you
want
to
access
anything,
it's
just
immediate
and
even
better
when
you
do
a
traversal
you're
actually
going
to.
A
If
you
scan
the
traversal
of
this
array
in
lexicographic
order,
you
don't
have
to
do
all
these
extra
indirect
memory
accesses,
so
things
will
actually
scale
with
the
size
of
your
cache
lines
on
your
processor,
which
is
a
very
big
deal
because
often
times
the
size
of
those
cache
lines
can
be
very
big
and
probably
much
more
than
number
of
cores
on
your
computer
right.
So
you
know,
writing
algorithms
that
take
advantage
of
cache
performance
is
generally
a
higher
priority
than
even
parallelizing.
A
Them
are
running
them
on
a
distributed
system
right,
because
this
is
how
you
get
like
the
really
big
scaling
of
performance,
so
that's
great,
and
also
to
some
limited
extent.
You
can
still
sort
of
slice
an
implicit
array
by
basically
changing
the
size
along
the
largest
axis.
So
this
is
commonly
used
in
many
numerical
codes
right,
but
there's
also
an
even
better
way
where
we
could
generalize
this
a
little
bit.
A
So
one
problem
is:
if
our
matrix
here,
you
know,
if
we
basically
flatten
it
all
out
and
lexicographic
order,
then
we'll
get
one
ordering,
but
we
could
also
flatten
it
in
row
major
or
column
major
order,
or
do
it
in
some
different
way.
So
we
can
generalize
this
using
this
concept
of
strided
arrays
and
so
in
a
strided
array.
A
A
So,
for
example,
if
we
wanted
to
transpose
this
array,
all
we
have
to
do
is
just
switch
the
two
stride:
components
and
then
we've
transposed
it
in
place
and
we
don't
have
to
do
any
work
or
if
we
want
to
take
say
just
the
first
row
or
the
first
column,
we
can
just
cut
them
using
one
of
the
stride
vectors
by
itself.
So
there's
a
much
more
flexible
representation
for
creating
arrays
or
matrices,
and
this.
A
Done
in
systems
like
julia,
MATLAB
or
Sipe
I
raised,
they
used
these
sort
of
strided
arrays,
so
I
proposed.
You
know
for
basically
the
purposes
of
creating
some
standard
format
for
a
JavaScript.
We
could
adopt
an
ende
array
format
very
similar
to
the
way
that
python
does
things
by
basically
creating
a
standard
object,
and
all
we
have
to
do
is
give
it
three
pieces
of
information.
So
we
have
the
underlying
data
array.
A
So
this
is
a
set
of
tools
and
also
some
convenient
methods
for
working
with
slices.
So,
to
give
a
quick
overview
of
that,
we
have
things
like
slice
operation,
so
you
can
cut
out
a
sub
array
using
this
high
and
dot
low
syntax
transposing
different
stepping.
So
you
can
do
things
like
down
sample
array
by
a
factor
of
two
by
just
multiplying
the
stride
by
two
or
selecting
sub
arrays
like
picking
out
a
row
or
a
column
or
some
component
of
a
tensor,
and
each
of
these
operations
is
essentially
I
mean
it's
basically
constant.
A
A
Okay,
so
that's
the
first
part
of
numerical
computing,
so
we
just
have
to
pick
some
multi-dimensional
array
format
and
then
we
need
to
start
creating
algorithms
that
can
produce
or
consume
these
arrays.
So
in
terms
of
creating
numerical
algorithms,
there's
a
couple
of
big
approaches,
but
I
would
say
they
sort
of
broadly
break
down
into
two
categories.
The
first
is,
we
can
try
to
just
implement
everything
in
j/s,
and
this
is
probably
the
only
viable
option
today
and
I
have
some
partial
work
along
this.
A
Fines
are
along
these
lines
through
CJ
s,
which
is
a
collection
of
modules
that
can
either
produce
or
consume
nd
arrays.
There
is
something
like
a
hundred
thirty
hundred
and
fifty
of
these,
and
they
can
do
everything
from
some
basic
linear
algebra
to
you,
know,
image,
processing
and
Fourier
analysis,
for
you
know
audio
and
video
processing.
A
A
So
if
we
think
about
systems
that
have
been
successful
in
the
past
in
this
space,
the
large
the
biggest
names
are
probably
things
like
sy,
PI
or
MATLAB,
or
R
or
Julia.
Or
you
know
things
of
along
this
along
those
lines
and
I
would
say
that
most
of
those
systems
can
be
described
as
basically
Fortran
wrappers
so
to
bootstrap,
something
like
sy,
PI
or
MATLAB.
The
standard
practice
is
to
just
grab
an
existing
Fortran
set
of
libraries
and
then
just
wrap
them
all
up
in
some
idiomatic
API.
A
For
whatever
language
you're
working
in
so
sci-fi
is
really
just
a
bunch
of
Fortran
and
C
routines
that
have
all
been
packaged
up
and
exposed
to
Python.
So
then
you
can
use
Python
to
script
and
drive
these
computations.
So
if
we
want
to
be
able
to
get
caught
up
to
these
other
systems
in
JavaScript
quickly,
we
need
some
way
to
bring
that
existing
native
code
into
JavaScript
efficiently.
A
So
one
way
we
could
get
something
working
right
now
is
we
can
use
node
native
modules,
and
there
are
some
partial
efforts
along
this.
But
up
until
recently,
and
even
to
this
day,
maintaining
native
modules
on
JavaScript
with
node
is
extremely
difficult.
It's
a
very
fragile
thing,
just
break
all
the
time.
It's
a
ton
of
work
to
keep
it
up
and
you
have
to
just
you
know,
babysit
these
and
because
every
version
of
node
or
electron
or
whatever
on
every
different
platform
breaks
compatibility.
So
it's
difficult
to
publish
and
maintain
native
modules.
A
There
are
systems
like
as
MJS,
but
these
have
issues
with
load
time,
because
parsing
all
of
the
JavaScript
from
this
native
code
is
difficult
and
then
also
as
a
foreign
function
interface.
You
end
up
wasting
a
bunch
of
memory
because
you
have
to
spawn
multiple
instances
of
the
library
and
each
have
their
own
separate
heap.
So
it's
technically
difficult
and
the
future
web
assembly
might
be
a
better
solution,
but
it's
still
not
viable
as
a
spec,
but
this
might
give
us.
You
know
some
other
options
and
perhaps
even
more
ambitiously.
A
If
this
does
become
something
that
is
a
high
enough
priority
for
the
web,
we
could
eventually
get
a
web.
Api
is
standardized
through
you
know
either
you
know
like
the
w3c
or
some
other
standards
process
and
actually
give
browsers
to
adopt
and
implement
this,
which
would
be
amazing,
because
then
we
wouldn't
have
to
be
shipping
and
re
implementing
all
this
stuff
in
JavaScript
all
the
time,
and
we
could
actually
have
the
vendors
compete
to
get
the
best
possible
implementation
for
whatever
a
native
platform.
A
A
So
I
guess
in
summary,
numerical
computing
is
important,
is
something
that
we
should
all
try
to
work
toward
bringing
to
the
web
and
to
JavaScript
and
I
think
in
terms
of
three
concrete
things
that
we
can
do
for
trying
to
make
this
happen.
The
first
is
that
we
should
start
advocating
for
better
standards
and
improvement
to
the
systems
that
we
are
using
right
now.
A
We
should
also
try
to
grow
the
module
ecosystem,
so
this
becomes
viable
and
then
people
can
actually
use
these
things
and
start
doing
stuff
with
and
finally,
we
just
need
to
start
building
more
stuff
with
it,
because
we
already
have
some
pieces
out
there
that
work,
and
so
we
just
need
to
start
creating
more
things
and
getting
more
people
interested
in
it
and
start
getting
numerical
computing
working
on
the
web.
So
I
think
with
that
I'll
wrap
this
up
and
leave
this
open
to
some
questions.
B
A
So
I
actually
don't
know
much
about
es.
Plugins
I
think
was
this
related
to
there's
been
a
couple
of
attempts
to
create
a
standard
system
for
native
modules
and
I.
I
would
say
that
I
am
at
some
level
personally,
not
too
attached
to
any
particular
one.
I
just
want
something
to
exist
right,
but
we
need
that
right
and
I
think
if
we
have
that
that's
going
to
make
it
a
lot
easier
to
do.
Numerical
computing.
A
B
A
If
you
look
at
other
languages
that
have
been
very
successful
in
numerical
computing
like
Python
or
MATLAB,
or
are
none
of
those
languages
are
actually
that
good
at
computing.
In
fact,
in
many
ways,
javascript
is
actually
a
far
better
option
for
writing.
Compute
intensive
applications
than
Python
the
only
reason
and
it's
purely
a
historical
accident,
is
that
Python
just
happened
to
be
there
at
the
right
place
in
time
that,
basically,
when
people
needed
to
start
looking
for
something
other
than
MATLAB,
the
community
was
able
to
mobilize
and
fill
that
niche.
A
So
I,
don't
think
that
any
of
the
things
that
people
often
would
say
like
javascript
is
not
good
for
computer,
whatever
are
remotely
applicable
here.
It's
totally
an
issue
of
cultural
inertia.
There's
just
all
of
this
work
that
is
still
getting
done
and
built
in
Python,
and
it
just
continues
to
get
you
know.
A
So
it's
stuff,
like
a
you,
know,
giant
matrix,
matrix,
multiply
or
matrix
vector
multiply
as
where
most
of
the
cycles
get
spent,
and
if
we
basically
push
that
down
to
some
low
level
highly
optimized
code,
we
can
do
all
the
same
stuff
in
JavaScript
that
they
can
do
in
Python.
So
I
don't
see
it
as
a
problem.