Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

16
MILAN november 28 th /29 th , 2014 Living on the Edge Survive and Thrive with JavaScript and .NET running in-process [email protected] @rafek ABB Rafał Legiędź

description

by Rafał Legiędź - If you're one of those developers who are tied to a .NET platform but are willing to use JavaScript whenever possible? Or maybe you develop server-side applications in JavaScript and you would like to call infrastructure code written in .NET? During this session you will get to know how to deal with above scenarios by using Edge.js module, which allows you to run Node.js and .NET code in one process on Windows, MacOS, and Linux.

Transcript of Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

Page 1: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014

Living on the EdgeSurvive and Thrive with JavaScript and .NET running in-process

[email protected]@rafek

ABB

Rafał Legiędź

Page 2: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

About me

Rafał Legiędź[email protected]

@rafek

Page 3: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Node.jsPlatform built on Chrome’s V8 JavaScript engine that provides an event-driven architecture and a non-blocking I/O API that optimizes an apllication’s throughput and scalability.

Page 4: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Node.js in practice

„[..] the only developer community that was built from day one around asynchronous, event-driven application logic as a core principle.”

~ Node.js is taking over the Enterprise

„On Black Friday the WalMart servers didn’t go over 1% CPU utilisation and the team did a deploy with 200,000,000 users online.”

~ Why Node.js is becoming the go-to technology in the enterprise

Page 5: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Node.js use cases

Page 6: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

.NETAdvantages over Node.js:

Page 7: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Edge.js„[..] provides an asynchronous, in-process mechanism for interoperability between Node.js and .NET”

…on Windows, Linux and Mac OS X

Page 8: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Edge.js – interop model

Page 9: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Edge.js – possibilitiesEnables or simplifies application scenarios which are hard or impossible to achieve with Node.js alone:•implementing CPU-bound workloads in-process•simplifying access to Windows specific functionality•extending Node.js in .NET instead of native C

in any CLR language using inline code, separate files or assemblies.

Page 10: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

What problem does it solve?

Page 11: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Edge.js – code

Page 12: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Installing Edge.js• >= Node.js 0.8.x• .NET Framework 4.5 or Mono 3.4.0

Page 13: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

.NET that scripts Node.js in-process

Page 14: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Tips• External class/assembly over inline code• Separate modules• Stay async• Benchmark• Node.js Tools for Visual Studio (Windows only)

Page 15: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Alternatives• Stick with Node.js if possible• Process invocation (Node.js’s process api)• WebService (local/remote)• *MQ

Page 16: Living on the Edge(.js)! Survive and thrive with JavaScript and .NET in one process

MILAN november 28th/29th, 2014 – Rafał Legiędź

Resources• Edge.js presentation• Source code• This presentation• The Birth & Death of JavaScript (Gary Bernhardt)• Node.js is taking over the Enterprise• Why Node.js is becoming the go-to technology in the enterprise