Node.js:JavaScript from Client to Server and Beyond!              Robert McCarthy –CEO       Gary Ratclliffe – Development...
Agenda1.   The best new technology in the world2.   The exciting future3.   The real world4.   If still alive           Go...
Introduction to GOSSRobert McCarthy – GOSS CEO  Gary Ratclliffe – Technical
Who we work with                   4
Server-side Javascript                         5
How many of you use JavaScript?        Put your hands UP if YES Is the majority of your JavaScript jQuery?       Put your ...
Why?       7
The Problem?               9
Form validation for websites     User needs simple validation                                    10
On the browser/^[A-D][0-9]{4}$/i.test(v)                             11
On the server          CF: ReFindNoCase("^[A-D][0-9]{4}$", v) GT 0        Java: Pattern.matches("(?i)^[A-D][0-9]{4}$", v)....
4 different implementations!!  More work, more maintenance, more risk                                           13
The Solution?Server Side javascript = One languageLess work, less maintenance, less risk                                  ...
The Implementation                                       Java    Mozilla Rhino                                       SiteB...
What Next?Like the idea of common language on all platforms(But Clients still expect .NET sites to be .NET like & Java sit...
Entire Forms engine?                Complex      Benefits from implementing once    Needs to be extensible      There is a...
So we did it!Forms generated using a simple template* containing JavaScript<%if ( Props["FIELDPROPERTIES"]["MAXLENGTH"] !=...
SnagWe really needed a good, fast JavaScript engine on all platforms.                      JScript was problem            ...
V8 Arrives!    Created by Google for ChromeAlso designed to be used in other apps                                         20
V8 is FAST!!Clever optimisations and compiling to native code.Not quite as dramatic now as when it first appeared         ...
V8 is Single Threaded!!Only one thread can execute JavaScript at a timeV8 Locking can help synchronize multiple threads   ...
V8.net wrapperReplaced JScript with JavaScript .NET from Noesis    Proved reliable in production deployment               ...
V8 is Single Threaded!! A problem for traditional server-side scalabilityHow do you handle multiple concurrent requests?  ...
V8.net wrapper              Limited by single threading       Resorted to a global lock around executionBut an evolutionar...
Along came Node.JS                     26
Along came Node.JS                     27
Non blocking vs Threads   Threads use a lot of memory and are limitedUse asynchronous IO and an event loop like NGINX     ...
Weakness now a strengthRyan Dahl, creator of Node.JS used these concepts in Node.JS  The single threaded nature of V8 was ...
You’ve gotta love it                       30
Node.JS
What can Node.js do?    Simple http hello world                              32
Simple web server                        Continuations break processing into steps        Function called on each requestF...
Node.JS          Lots of additional modulesReally learn JavaScript the language not just jQuery             Google ‘Dougla...
Node.JSThink carefully if your application needs it              Highly interactive?             Loads of AJAX?     Very h...
1000’s of concurrent requests  All server-side JavaScript
Writing continuations for      everything is hardSooner or later something has       to do something
Writing continuations for    everything is hard                            38
Real world code is hard  How many developers  really understand it?  Many can tweak, but starting from scratch…Debugging c...
Our SolutionLets call it pragmatic                         40
IcedCoffeeScript?         Not a drink but derived from coffeesriptCoffeeScript = Cool, elegant syntax, JavaScript without ...
IcedCoffeeScript?What happen to the 1 language     It makes you think different.                                     42
await and defer used to  express callbacksCleaner code layout but you do have to learn     CoffeeScript  Extra build step ...
And that other issue?                        44
Sooner or later something has to          do something       For many things this is not a problem                        ...
Non blocking?           This example is computationally           intensive. It results in high CPU                 use on...
V8 is single threaded!A badly written extension and Bye Bye server…                                                47
Use Node.JS for it’s strengths                                 48
Multiple workers processes                               JavaScript Worker                                JavaScript Worke...
Best of all worlds   Requests delegated to a suitable worker or queued if worker busyA CGI style wrapper round the V8 engi...
Where Next?           Does the industry need Node.JS?Other web servers can/will achieve similar performance         So its...
Is 1 Language an ideal?   Same developers for UI and Backend?          Common in start-ups        Less so in the ‘enterpri...
So will it survive?                      53
Today most sites..                     54
Multiple Dev Languages                         55
Client is a dumb browser                           56
Clients are isolated from one            another                                57
Anything more interactive tends         to be bespoke                              58
Imagine          60
ImagineOne server-side infrastructure                                 61
ImagineOne Language               62
ImagineOne Data Format: JSON?                         63
ImagineTransfer Data not UI                       64
ImagineCollaborate & Distribute                           65
66
So is it just a dream?                         67
68
But that’s for the next talk?                                69
Final Thoughts….                 The web is changing at pace.                There will be lots of shiny toys             ...
Any questions?   Thank you!!PS. We are hiring!
Node.js #digpen presentation
Node.js #digpen presentation
Upcoming SlideShare
Loading in...5
×

Node.js #digpen presentation

659
-1

Published on

JavaScript from Client to Server and Beyond!

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
659
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Node.js #digpen presentation

  1. 1. Node.js:JavaScript from Client to Server and Beyond! Robert McCarthy –CEO Gary Ratclliffe – Development Manager
  2. 2. Agenda1. The best new technology in the world2. The exciting future3. The real world4. If still alive Goto 1 2
  3. 3. Introduction to GOSSRobert McCarthy – GOSS CEO Gary Ratclliffe – Technical
  4. 4. Who we work with 4
  5. 5. Server-side Javascript 5
  6. 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 YESAre you using any server-side JavaScript? Put yours hands DOWN if NO 6
  7. 7. Why? 7
  8. 8. The Problem? 9
  9. 9. Form validation for websites User needs simple validation 10
  10. 10. On the browser/^[A-D][0-9]{4}$/i.test(v) 11
  11. 11. On the server CF: ReFindNoCase("^[A-D][0-9]{4}$", v) GT 0 Java: Pattern.matches("(?i)^[A-D][0-9]{4}$", v).NET Regex.Match(v, "^[A-D][0-9]{4}$", RegexOptions.IgnoreCase) 12
  12. 12. 4 different implementations!! More work, more maintenance, more risk 13
  13. 13. The Solution?Server Side javascript = One languageLess work, less maintenance, less risk 14
  14. 14. The Implementation Java Mozilla Rhino SiteBrowser CF Site /^[A-D][0-9]{4}$/i.test(v) .NET Site MS Jscript 15
  15. 15. 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
  16. 16. 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
  17. 17. 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
  18. 18. SnagWe really needed a good, fast JavaScript engine on all platforms. JScript was problem 19
  19. 19. V8 Arrives! Created by Google for ChromeAlso designed to be used in other apps 20
  20. 20. V8 is FAST!!Clever optimisations and compiling to native code.Not quite as dramatic now as when it first appeared 21
  21. 21. V8 is Single Threaded!!Only one thread can execute JavaScript at a timeV8 Locking can help synchronize multiple threads One of reasons it’s fast Multi-threading can get complex…and slow 22
  22. 22. V8.net wrapperReplaced JScript with JavaScript .NET from Noesis Proved reliable in production deployment Real JavaScript Much faster than Jscript!! 23
  23. 23. V8 is Single Threaded!! A problem for traditional server-side scalabilityHow do you handle multiple concurrent requests? 24
  24. 24. V8.net wrapper Limited by single threading Resorted to a global lock around executionBut an evolutionary dead-end while V8 is single threaded 25
  25. 25. Along came Node.JS 26
  26. 26. Along came Node.JS 27
  27. 27. Non blocking vs Threads Threads use a lot of memory and are limitedUse asynchronous IO and an event loop like NGINX 28
  28. 28. Weakness now a strengthRyan Dahl, creator of Node.JS used these concepts in Node.JS The single threaded nature of V8 was no longer a problem 29
  29. 29. You’ve gotta love it 30
  30. 30. Node.JS
  31. 31. What can Node.js do? Simple http hello world 32
  32. 32. Simple web server Continuations break processing into steps Function called on each requestFunction called when file contents available 33
  33. 33. Node.JS Lots of additional modulesReally 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
  34. 34. Node.JSThink carefully if your application needs it Highly interactive? Loads of AJAX? Very high number of requests? Not just because you can! 35
  35. 35. 1000’s of concurrent requests All server-side JavaScript
  36. 36. Writing continuations for everything is hardSooner or later something has to do something
  37. 37. Writing continuations for everything is hard 38
  38. 38. 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
  39. 39. Our SolutionLets call it pragmatic 40
  40. 40. IcedCoffeeScript? Not a drink but derived from coffeesriptCoffeeScript = Cool, elegant syntax, JavaScript without the Bad Bits 41
  41. 41. IcedCoffeeScript?What happen to the 1 language It makes you think different. 42
  42. 42. await and defer used to express callbacksCleaner code layout but you do have to learn CoffeeScript Extra build step to generate JavaScript 43
  43. 43. And that other issue? 44
  44. 44. Sooner or later something has to do something For many things this is not a problem eg Database modules written to be asynchronous 45
  45. 45. 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
  46. 46. V8 is single threaded!A badly written extension and Bye Bye server… 47
  47. 47. Use Node.JS for it’s strengths 48
  48. 48. Multiple workers processes JavaScript Worker JavaScript Worker JavaScript Worker TeaJS TeaJS TeaJS Worker Manager Node.JS Java Worker Requests Java Worker Java Worker Java VM Java VM Management Java VM Security Node.JS Worker Node.JS Worker Node.JS Worker Node.JS Node.JS Node.JS 49
  49. 49. Best of all worlds Requests delegated to a suitable worker or queued if worker busyA 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
  50. 50. Where Next? Does the industry need Node.JS?Other web servers can/will achieve similar performance So its really all about the language? 51
  51. 51. 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
  52. 52. So will it survive? 53
  53. 53. Today most sites.. 54
  54. 54. Multiple Dev Languages 55
  55. 55. Client is a dumb browser 56
  56. 56. Clients are isolated from one another 57
  57. 57. Anything more interactive tends to be bespoke 58
  58. 58. Imagine 60
  59. 59. ImagineOne server-side infrastructure 61
  60. 60. ImagineOne Language 62
  61. 61. ImagineOne Data Format: JSON? 63
  62. 62. ImagineTransfer Data not UI 64
  63. 63. ImagineCollaborate & Distribute 65
  64. 64. 66
  65. 65. So is it just a dream? 67
  66. 66. 68
  67. 67. But that’s for the next talk? 69
  68. 68. Final Thoughts…. The web is changing at pace. There will be lots of shiny toys They might not lead to nirvanabut they will often give you a glimpse of a very exciting future!! Stay Excited… 70
  69. 69. Any questions? Thank you!!PS. We are hiring!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×