28. What we need —
1. Familiar, standard syntax
2. Nothing extra to learn or think about
29. What we need —
1. Familiar, standard syntax
2. Nothing extra to learn or think about
3. Completely non-blocking, able to
continue rendering while waiting for
callbacks
30. What we need —
1. Familiar, standard syntax
2. Nothing extra to learn or think about
3. Completely non-blocking, able to
continue rendering while waiting for
callbacks
4. Fast
36. How AJS works —
1. Parse source to an abstract syntax
tree (AST)
37. How AJS works —
1. Parse source to an abstract syntax
tree (AST)
2. Add “futures” hooks around callbacks
38. How AJS works —
1. Parse source to an abstract syntax
tree (AST)
2. Add “futures” hooks around callbacks
3. Recompile and cache optimized JS
39. How AJS works —
1. Parse source to an abstract syntax
tree (AST)
2. Add “futures” hooks around callbacks
3. Recompile and cache optimized JS
4. Execute code inside a VM that
manages and handles async callbacks
41. How callbacks are handled —
1. At the exact spot a callback is passed to
its async function, we create a “future”
buffer.
42. How callbacks are handled —
1. At the exact spot a callback is passed to
its async function, we create a “future”
buffer.
2. We continue executing the template,
flushing everything up until a callback that
we’re still waiting on.
43. How callbacks are handled —
1. At the exact spot a callback is passed to
its async function, we create a “future”
buffer.
2. We continue executing the template,
flushing everything up until a callback that
we’re still waiting on.
3. When each callback returns, we fill in its
buffer and continue flushing down the page
as we can.
44. JS Compatibility —
Should be mostly complete, can
correctly compile embedded jQuery
and underscore.js source already.
(no they aren’t templates, but they are complex JS)
47. What about
performance? —
Parses ~40-50,000 lines/sec uncached.
Good, not great (should improve).
But AJS can render while Node
waits on your DB calls, and page
loads will feel faster because
<head> resources aren’t blocked.
49. Current limitations —
1. Since callbacks are detected and at runtime,
callbacks can’t be nested. There may be
some ways around this, but we may not want
to encourage it...
50. Current limitations —
1. Since callbacks are detected and at runtime,
callbacks can’t be nested. There may be
some ways around this, but we may not want
to encourage it...
2. There’s no layout nesting built into the
middleware.
51. Current limitations —
1. Since callbacks are detected and at runtime,
callbacks can’t be nested. There may be
some ways around this, but we may not want
to encourage it...
2. There’s no layout nesting built into the
middleware.
3. Others...
53. How to get it —
1 - npm install ajs
2 - github.com/kainosnoema/ajs
Submit issues, fork and improve!
Editor's Notes
\n
\n
We haven&#x2019;t progressed since the days of inline PHP, in fact we&#x2019;ve regressed\n Node&#x2019;s non-blocking architecture is being handicapped by archaic templating conventions\n We need something completely new (at least under the hood)\n
We haven&#x2019;t progressed since the days of inline PHP, in fact we&#x2019;ve regressed\n Node&#x2019;s non-blocking architecture is being handicapped by archaic templating conventions\n We need something completely new (at least under the hood)\n
\n
\n
\n
\n
From the end user&#x2019;s perspective, we&#x2019;re finally back the experience we had with inline PHP.\nRegardless, we&#x2019;re stuck with Ruby&#x2019;s blocking IO calls. \n
From the end user&#x2019;s perspective, we&#x2019;re finally back the experience we had with inline PHP.\nRegardless, we&#x2019;re stuck with Ruby&#x2019;s blocking IO calls. \n
From the end user&#x2019;s perspective, we&#x2019;re finally back the experience we had with inline PHP.\nRegardless, we&#x2019;re stuck with Ruby&#x2019;s blocking IO calls. \n
Somehow we have this assumption that whatever we write in Node will be non-blocking.\nUnfortunately this isn&#x2019;t true on a per-request level... if you have a blocking function, Node blocks.\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
The uncached performance is only relevant on the first page load.\nAfter that performance is MUCH better, and will only improve.\n
The uncached performance is only relevant on the first page load.\nAfter that performance is MUCH better, and will only improve.\n
2. Thought of this last night actually...\n
2. Thought of this last night actually...\n
2. Thought of this last night actually...\n
Obviously Ryan was joking around, but in threory AJS could be used as\nan asynchronous &#x201C;PHP&#x201D; by simply serving up AJS files, mapping URIs\nto a directory structure. Not that you&#x2019;d want to.\n