6. How many of you use JavaScript?
Put your hands UP if YES
Is the majority of your JavaScript jQuery?
Put your hands DOWN if YES
Are you using any server-side JavaScript?
Put yours hands DOWN if NO
6
15. The Implementation
Java Mozilla Rhino
Site
Browser
CF
Site
/^[A-D][0-9]{4}$/i.test(v) .NET
Site
MS Jscript
15
16. What Next?
Like the idea of common language on all platforms
(But Clients still expect .NET sites to be .NET like & Java sites to be Java like)
16
17. Entire Forms engine?
Complex
Benefits from implementing once
Needs to be extensible
There is always a new requirements
Clients could create their own extensions
17
18. So we did it!
Forms generated using a simple template* containing JavaScript
<%
if ( Props["FIELDPROPERTIES"]["MAXLENGTH"] !== "") {
maxLength="maxlength='" + Props["FIELDPROPERTIES"]["MAXLENGTH"] + "'";
}
%>
<label for='<%=Props["FIELDID"]%>'><%=Processor.htmlEsc(Props["FIELDPROPERTIES"]["LABEL"])%></label>
<input type="text" name="<%=Props["FIELDID"]%>" id="<%=Props["FIELDID"]%>" <%=maxLength%>/>
18
19. Snag
We really needed a good, fast JavaScript engine on all platforms.
JScript was problem
19
20. V8 Arrives!
Created by Google for Chrome
Also designed to be used in other apps
20
21. V8 is FAST!!
Clever optimisations and compiling to native code.
Not quite as dramatic now as when it first appeared
21
22. V8 is Single Threaded!!
Only one thread can execute JavaScript at a time
V8 Locking can help synchronize multiple threads
One of reasons it’s fast
Multi-threading can get complex…and slow
22
23. V8.net wrapper
Replaced JScript with JavaScript .NET from Noesis
Proved reliable in production deployment
Real JavaScript
Much faster than Jscript!!
23
24. V8 is Single Threaded!!
A problem for traditional server-side scalability
How do you handle multiple concurrent requests?
24
25. V8.net wrapper
Limited by single threading
Resorted to a global lock around execution
But an evolutionary dead-end while V8 is single threaded
25
33. Simple web server
Continuations break processing into steps
Function called on each request
Function called when file contents available
33
34. Node.JS
Lots of additional modules
Really learn JavaScript the language not just jQuery
Google ‘Douglas Crockford’
Look at source code of real projects
Combine it with MongoDB for end-to-end JSON
34
35. Node.JS
Think carefully if your application needs it
Highly interactive?
Loads of AJAX?
Very high number of requests?
Not just because you can!
35
39. Real world code is hard
How many developers
really understand it?
Many can tweak, but
starting from scratch…
Debugging can be difficult
Node-inspector worth a
look
39
45. Sooner or later something has to
do something
For many things this is not a problem
eg
Database modules written to be asynchronous
45
46. Non blocking?
This example is computationally
intensive. It results in high CPU
use on any system.
On Node.JS it would only
process one request at a time.
n=40 takes about 5s
3 concurrent requests:
1 client will wait 15s
46
47. V8 is single threaded!
A badly written extension and Bye Bye server…
47
50. Best of all worlds
Requests delegated to a suitable worker or queued if worker busy
A CGI style wrapper round the V8 engine allowing use of traditional linear
JavaScript. It’s a good match for our approach to forms rendering
50
51. Where Next?
Does the industry need Node.JS?
Other web servers can/will achieve similar performance
So its really all about the language?
51
52. Is 1 Language an ideal?
Same developers for UI and Backend?
Common in start-ups
Less so in the ‘enterprise’
Jack of all trades master of none?
52
70. Final Thoughts….
The web is changing at pace.
There will be lots of shiny toys
They might not lead to nirvana
but they will often give you a glimpse of a very exciting future!!
Stay Excited…
70