30
Getting Started with Meteor Trenton Computer Festival 2013 IT Professional Conference March 15, 2013 Michael P. Redlich [email protected] [email protected] , @ @ mpredli mpredli

Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

  • Upload
    ngobao

  • View
    231

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

Getting Started with MeteorTrenton Computer Festival 2013

IT Professional ConferenceMarch 15, 2013

Michael P. Redlich

[email protected]@redlich.net, @@mpredlimpredli

Page 2: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

2Trenton Computer Festival 2013March 15, 2013

My Background (1)

Degree

�B.S. in Computer Science

�Rutgers University (go Scarlet Knights!)

“Petrochemical Research Organization”

�Senior Research Technician (1988-1998, 2004-)

�Systems Analyst (1998-2002)

Ai-Logix, Inc. (now AudioCodes)

�Technical Support Engineer (2003-2004)

Amateur Computer Group of New Jersey (ACGNJ)

�Java Users Group Leader (2001-)

�President (2007-2009, 2013-), Past-President (2010-present)

�Secretary (2006)

Page 3: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

3Trenton Computer Festival 2013March 15, 2013

My Background (2)

Publications�Java Boutique (http://http://www.javaboutique.comwww.javaboutique.com//)

�Co-authored with Barry Burd

�Design Patterns

��http://www.redlich.net/publications/http://www.redlich.net/publications/

Presentations

�Trenton Computer Festival (TCF) since 1998

�TCF IT Professional Seminars since 2006

�Emerging Technologies for the Enterprise

�Princeton Java Users Group

�Capital District Java Developers Network

�New York Software Industry Association (NYSIA)

Page 4: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

4Trenton Computer Festival 2013March 15, 2013

TCF 2013

Page 5: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

5Trenton Computer Festival 2013March 15, 2013

Objectives

What is Meteor?

The Seven Principles

Getting started with Meteor

Live Demo (yea!)

Meteor Resources

Page 6: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

6Trenton Computer Festival 2013March 15, 2013

What is Meteor?

“…an open-source platform for building top-quality web apps in a fraction of the time, whether you’re an expert developer or just getting started.”

A full-stack framework using JavaScript

Compiles, combines, and distributes, your JavaScript, CSS, and HTML

Deploys on the fly

Page 7: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

7Trenton Computer Festival 2013March 15, 2013

Supported Operating Systems

Mac

�OS X 10.6 and above

Linux

�x86 or x86_64 Debian- and Red Hat-based systems

Windows

�Not supported at this time by core Meteor developers

�Unofficial Windows installer by Tom Wijsman

Page 8: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

8Trenton Computer Festival 2013March 15, 2013

The Seven Principles

Data on the Wire

One Language

Database Everywhere

Latency Compensation

Full-Stack Reactivity

Embrace the Ecosystem

Simplicity = Productivity

Page 9: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

9Trenton Computer Festival 2013March 15, 2013

#1 - Data on the Wire

No HTML is rendered on the server

JSON is sent to the browser

Browser renders the templates

Page 10: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

10Trenton Computer Festival 2013March 15, 2013

#2 - One Language

All code is in JavaScript

�Client and server

But you could use CoffeeScript as well

Page 11: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

11Trenton Computer Festival 2013March 15, 2013

#3 - Database Everywhere

Client data API mirrors the server database API

The local data API looks just like MongoDB

Page 12: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

12Trenton Computer Festival 2013March 15, 2013

#4 – Latency Compensation

All data operations take place in memory first

Page 13: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

13Trenton Computer Festival 2013March 15, 2013

#5 – Full-Stack Reactivity

Embraces the concept of reactive programming

Everything is realtime

Templates automatically re-render themselves

Page 14: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

14Trenton Computer Festival 2013March 15, 2013

#6 – Embrace the Ecosystem

Meteor is open source

Integrates existing open source tools and frameworks

Page 15: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

15Trenton Computer Festival 2013March 15, 2013

#7 – Simplicity = Productivity

APIs are plain and simple

Page 16: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

16Trenton Computer Festival 2013March 15, 2013

Getting Started with Meteor

Download Meteor��http://www.meteor.com/http://www.meteor.com/

��http://win.meteor.com/http://win.meteor.com/

Review the built-in examples

�Leaderboard

�Parties

�Todos

�Wordplay

Create your first Meteor app

Page 17: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

17Trenton Computer Festival 2013March 15, 2013

C:\meteor-apps>meteor create myapp

myapp: created.

To run your new app:

cd myapp

meteor

C:\meteor-apps>

Page 18: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

18Trenton Computer Festival 2013March 15, 2013

Page 19: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

19Trenton Computer Festival 2013March 15, 2013

C:\meteor-apps>cd myapp

C:\meteor-apps\myapp>meteor

[[[[[ C:\meteor-apps\myapp ]]]]]

Initializing mongo database... this may take a moment.

////////////////////////////////////////

////////////////////////////////////////

Running on: http://localhost:3000

Page 20: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

20Trenton Computer Festival 2013March 15, 2013

Page 21: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

21Trenton Computer Festival 2013March 15, 2013

// myapp.html

<head>

<title>myapp</title>

</head>

<body>

{{> hello}}

</body>

<template name="hello">

<h1>Hello World!</h1>

{{greeting}}

<input type="button" value="Click" />

</template>

Page 22: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

22Trenton Computer Festival 2013March 15, 2013

// myapp.js – client-side code

if(Meteor.isClient) {

Template.hello.greeting = function () {

return "Welcome to myapp.";

};

Template.hello.events({

'click input' : function () {

// template data, if any,

// is available in 'this'

if(typeof console !== 'undefined')

console.log("You pressed the button");

}

});

}

Page 23: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

23Trenton Computer Festival 2013March 15, 2013

// myapp.js – server side code

if(Meteor.isServer) {

Meteor.startup(function () {

// code to run on server at startup

});

}

Page 24: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

24Trenton Computer Festival 2013March 15, 2013

// create new database

Players = new Meteor.Collection(“players”);

Create a MongoDB Database in Meteor

Page 25: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

25Trenton Computer Festival 2013March 15, 2013

// create some players if the database is empty.

if(Meteor.isServer) {

Meteor.startup(function () {

if(Players.find().count() == 0) {

var names = ["Ada Lovelace",

"Grace Hopper",

"Marie Curie",

"Carl Friedrich Gauss",

"Nikola Tesla",

"Claude Shannon"];

for(var i = 0;i < names.length;i++)

Players.insert({name: names[i], score:

Math.floor(Math.random()*10)*5});

}

});

}

Page 26: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

26Trenton Computer Festival 2013March 15, 2013

if(Meteor.isClient) {

Template.leaderboard.players = function () {

return Players.find({},{sort: {score: -1, name: 1}});

};

}

Page 27: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

27Trenton Computer Festival 2013March 15, 2013

And Now For...

...a live demo (yea!)

Page 28: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

28Trenton Computer Festival 2013March 15, 2013

Meteor Resources (1)

Meteor��http://www.meteor.com/http://www.meteor.com/

MongoDB

��http://www.mongodb.org/http://www.mongodb.org/

Handlebars��http://www.handlebarsjs.com/http://www.handlebarsjs.com/

CoffeeScript��http://www.coffeescript.org/http://www.coffeescript.org/

Backbone��http://www.backbonejs.org/http://www.backbonejs.org/

@meteorjs

@MongoDB

Page 29: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

29Trenton Computer Festival 2013March 15, 2013

Meteor Resources (2)

The Meteor Book

�Coming April 2013

��http://www.themeteorbook.com/http://www.themeteorbook.com/

Matt DeBergalis Presentation��http://www.infoq.com/presentations/Meteor/http://www.infoq.com/presentations/Meteor/

Page 30: Getting Started with Meteor - Princeton Joint Professional ...princetonacm.acm.org/tcfpro/Michael_Redlich.pdf · Getting Started with Meteor Trenton Computer Festival 2013 IT Professional

30Trenton Computer Festival 2013March 15, 2013

Local Java Users Groups

ACGNJ Java Users Group�facilitated by Mike Redlich

��http://www.javasig.org/http://www.javasig.org/

Princeton Java Users Group�facilitated by Yakov Fain

��http://www.myflex.org/princetonjug/http://www.myflex.org/princetonjug/

NYJavaSIG�facilitated by Frank Greco

��http://www.javasig.com/http://www.javasig.com/

Capital District Java Developers Network�facilitated by Anthony DeBonis

��http://www.cdjdn.com/http://www.cdjdn.com/

@javasig

@mpredli

@nyjavasig