tc39_study

 tc39_study

Temporal
BinaryAST

A32ef72a6a594abcf40c64154b968da6?s=128

Daiki Ihara

October 09, 2019
Tweet

Transcript

  1. tc39_study https://github.com/sasurau4/slides

  2. ABOUT
ME {
 

"id":
"sasurau4",
 

"name":
"Daiki
Ihara",
 

"description":
"Front-end
engineer
at
CureApp,
Inc.",
 

"techs":
{
 



"work":
["React
Native",
"TypeScript",
"JavaScript",
"MongoDB"],
 



"subwork":
["React
Native",
"React",
"TypeScript"],
 



"hobby":
["React",
"TypeScript",
"JavaScript",
"Deno"]
 

},


    

"homepage":
"https://sasurau4.github.io/profile/"
 }

  3. What
is
temporal? Provides
standard
objects
and
functions
for
working
with
dates
and
times.
This
proposal
is
currently
stage
2.

  4. Motivation Fixing
JavaScript
Date java.util.Date― その悲劇と歴史

  5. Principles All
temporal
APIs
are
non-mutating.
All
temporal
objects
are
effectively
immutable. All
date
values
are
based
on
the
Proleptic
Gregorian
Calendar. All
time-of-day
values
are
based
on
a
standard
24-hour
clock. Leap
seconds
are
not
represented.

  6. Specification The
documentation
is
out
of
date.


  7. Try
it
with
polyfill node
--experimental-modules
--no-warnings
--icu-data-dir
./node_modules/full-icu/
-r ./lib/initialise.js For
more
details,
https://github.com/tc39/proposal-temporal/tree/main/docs

  8. Results >
const
day
=
Temporal.Date(2019,
1,
1)
 undefined
 
 >
day.day
 1
 
 >
day.toString()
 '2019-01-01'
 


    >
let
d1
=
Temporal.DateTime(2019,
2,
1)
 undefined
 
 >
d1.toLocaleString()
 '2019/2/1
0:00:00'
 
 >
d1.daysInMonth
 28
 
 >
let
onem
=
Temporal.Duration(0,
1)
 undefined
 
 >
onem.toString()
 'P1M'
 

  9. What
is
binaryAST? Startup
performance
degrades
with
larger
JS
payloads,
even
if
only
a
fraction
of
the
code
is
actually
executed. Parsing
time
is
a
significant
component,
taking
more
CPU
time
than
bytecode
/
initial
JIT
code
generation.
For example,
on
a
powerful
laptop,
Chrome
spends
10%
to
15%
of
CPU
time
parsing
JS
while
loading
facebook.com. We
propose
a
new
over-the-wire
format
for
JS
that
is
a
binary
encoding
of
an
AST.
We
believe
this
new
format would
allow
for
drastically
faster
parsing.
Moreover,
web
developers
are
well
positioned
to
adopt
a
new
format
as they
have
embraced
build
tooling.

  10. Motivation from
https://blog.cloudflare.com/binary-ast/

  11. prototype
of
binAST from
https://github.com/binast/binjs-ref As
websites
become
more
sophisticated,
the
amount
of
JavaScript
source
code
keeps
increasing.
While depending
upon
a
large
JavaScript
codebase
won't
prevent
a
website
from
working,
it
will
cause
websites
to
start slowly
–
often
unacceptably
slow.
This
is
due
to
two
bottlenecks:
parsing
and
bytecode
compiling
JavaScript. Unfortunately,
browsers
have
pretty
much
reached
efficiency
peak
for
both
operations. We (Mozilla, Bloomberg, Facebook,

    CloudFlare) are currently working on a domain-specific encoding for JavaScript, called "BinAST" (short for "JavaScript Binary AST"). The JavaScript Binary AST is designed to break the bottleneck.
  12. Result

  13. Details https://blog.cloudflare.com/binary-ast/

  14. Demo Try
it
with
Firefox
nightly!
 https://serve-binjs.that-test.site

  15. The
End 
 