node ts1

25
Get Your Node.js Under Control with TypeScript Yaniv Rodenski Senior Architect Level: Intermediate - Advanced

Upload: yaniv-rodenski

Post on 06-May-2015

2.250 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Node ts1

Get Your Node.js Under Control with TypeScript

Yaniv RodenskiSenior Architect

Level: Intermediate - Advanced

Page 2: Node ts1

About me:

• Senior Architect – Sela Group• Windows Azure MVP• Coauthor of Developing Windows Azure

and Web Services (MOC 20487)• Developing software professionally since

1997

Page 3: Node ts1

About 1997:

Page 4: Node ts1

About 1997:

Script-based server side

Shared hosting environment

Browser wars

New HTML standard that will “Change the World”

This guy was the PM of Israel

Page 5: Node ts1

Agenda:

• Introduction to Node.js• Introduction to TypeScript• Getting Node.js under control

Page 6: Node ts1

Back to the future – Node.js

• A JavaScript runtime that is designed for asynchronous IO operations

• Very lightweight and fast• Used by a growing number of companies:

Page 7: Node ts1

The Node.js ecosystem• Web frameworks

– Express.js– Socket.io

• Database support– MongoDB– SQL Server

• Hosting and Cloud environments– IIS, Azure– Forever, PM2

Page 8: Node ts1

Demo

Hello Node.js

Page 9: Node ts1

Wait! JavaScript on the server side?

• JavaScript is considered a second-class language:• "JavaScript is Assembly Language for the Web“ - Erik

Meijer• “You can write large programs in JavaScript. You just

can’t maintain them.” - Anders Hejlsberg

Page 10: Node ts1

Hmmm

Page 11: Node ts1

JavaScript benefits

• But JavaScript is a powerful language:• Functional• Object Oriented• Dynamic

• Great runtimes• Huge community • Tools

Page 12: Node ts1

Demo

Fun with dynamic typing

Page 13: Node ts1

So what is TypeScript?

• TypeScript is one of many new JavaScript front ends:– DART– CoffeeScript– ClojureScript

• A JavaScript superset• Introduces static typing for JavaScript• Some ECMAScript 6 features

Page 14: Node ts1

Key Features:

Support standard

JavaScript code

Provides static typing

Encapsulation through

classes and modules

Support for constructors,

properties and

functions

Interfaces and enums

support

Lambda support =>

Intellisense and syntax checking

Page 15: Node ts1

Demo

Getting TypeScript

Page 16: Node ts1

Demo

Fun with static typing

Page 17: Node ts1

How good is the TypeScript output?

Page 18: Node ts1

Demo

TypeScript and Node.js

Page 19: Node ts1

Synchronous server operations

Client

DBServer

Client

Page 20: Node ts1

Asynchronous server operations

Client

DBServer

Client

Page 21: Node ts1

Express

• ExpressJS is a web application framework inspired by Sinatra

• Minimal and flexible• Provide a quasi-MVC server side

development

Page 22: Node ts1

Demo

Doing cool things with Express

Page 23: Node ts1
Page 24: Node ts1

Summary

• Node.js is a powerful and lightweight out-of-browser JavaScript environment

• JavaScript is a powerful language by itself• TypeScript provides optional static typing

and cleaner syntax and tools, which can be handy while developing large applications and exposing APIs

Page 25: Node ts1

Resources

• Node.js: http://nodejs.org/• TypeScript: http://www.typescriptlang.org/• Slides and Demos: http://sdrv.ms/152qU0b• Definitely Typed:

https://github.com/borisyankov/DefinitelyTyped

• Twitter: @YRodenski