This was my first talk at JSLA. At the time I had given talks quite a bit a meetup called Riverside.JS. I love looking back on this talk because it was just at the time when electron was split into its own project. I do not even think that I name electron at all because at the time it was called atom-shell.
Native NodeJS apps are a relatively new breed of apps coming out of the NodeJS community that combine NodeJS and Webkit. Ill be going over
- what are the options out there
- what kind of things can these apps do compared to webapps
- what are the current pro/cons of making a NodeJS native
Native NodeJS apps are a relatively new breed of apps coming out of the NodeJS community that combine NodeJS and Webkit.
Transcripts (auto-generate)
-
00:05so how's everybody doing
-
00:07um my name is jacob and i'm going to be
-
00:09talking about native node.js apps
-
00:13i'm on github it's my username for
-
00:15github i'm going to have i have some
-
00:17relevant material up there so if you
-
00:19want to go check that out um all my
-
00:21demos will be up there as well
-
00:22i work full time at a company called
-
00:24honey inc we make embeddable
-
00:26quizzes and and ads and stuff it's
-
00:29really cool um we're looking uh we have
-
00:32some job openings up on our website um
-
00:35if you're interested come talk to me
-
00:36afterwards and then i'm also an
-
00:38ambassador for syngrid
-
00:41so you might be thinking like what is a
-
00:42native node.js app
-
00:45you can almost say like isn't all
-
00:47node.js apps native because you can
-
00:49essentially run c code from them so
-
00:52i don't know how much more native you
-
00:54can get
-
00:56well yeah they are they are native
-
00:58node.js apps but i'm i was trying to
-
01:00think like what
-
01:02should i call these type of apps because
-
01:04there's not really like a a
-
01:05qualification or like a marketing term
-
01:07for these type of apps so like it's not
-
01:09a web app at all because it does so much
-
01:12more than a web app it would be kind of
-
01:13degrading to it to say hey it's a web
-
01:15app
-
01:16a native web app is actually a little
-
01:17bit better but it's it's not a web app
-
01:20at all because a kind of a web app like
-
01:22implies that it can be ran on a browser
-
01:24which if you run a heavily modified
-
01:27browser you can run these apps but not
-
01:29really on a regular web browser
-
01:32node.js app it is kind of a node.js app
-
01:35but like when you say node.js app
-
01:38you're usually talking about something
-
01:39like a web server or some type of
-
01:41networking server or even though it can
-
01:43be a number of things and then like
-
01:46native node.js app is kind of lame as
-
01:48well i mean i don't like it i think we
-
01:50could do a little bit better
-
01:52so like super effing cool way to use
-
01:54webtech to make a native-esque type of
-
01:57app
-
01:58i like that a lot better
-
02:00so but really what i'm talking about is
-
02:03a lightweight version of a browser
-
02:05and then the runtime of the browser is
-
02:08replaced with node.js runtime which is
-
02:10really cool and i say most instances
-
02:13because there's a lot of choices
-
02:15um well not a lot of choices but there's
-
02:17multiple choices to this
-
02:19and and luckily they're open source as
-
02:20well
-
02:22so
-
02:23the first one i'm going to talk about is
-
02:26desk shell now desk shell
-
02:28has been around for a while
-
02:30it's
-
02:31not that actually actively developed but
-
02:34it is very close to a web app you
-
02:37essentially are running a web app that
-
02:39interacts with the backend
-
02:41and they're kind of they're it used to
-
02:42be called app.js and i think they
-
02:44changed the name because they're looking
-
02:45to support php i don't know if that's
-
02:46considered like a bad thing about this
-
02:49type of app but
-
02:52um and then the big guy that i think
-
02:54most of you have probably heard about is
-
02:56a node webkit it's very full featured
-
02:58i've built apps in node webkit it is
-
03:00very cool they even have a grunt plugin
-
03:02to pack applications which is just
-
03:04awesome
-
03:05like you have no idea
-
03:07it is kind of slow to start up
-
03:10and there's a number of reasons for that
-
03:13and actually i was going to talk about
-
03:15node webkit throughout this whole entire
-
03:17presentation
-
03:18um but then something happened uh this
-
03:21month and just for reference for people
-
03:23who are watching this online this is may
-
03:25of 2014
-
03:27so what happened is that
-
03:29github
-
03:31released their atom ide to open source
-
03:33which i thought was great i mean a new
-
03:35project that's open source it's using
-
03:37very similar technologies i've actually
-
03:39speculated with a lot of my friends that
-
03:40they're using node webkit
-
03:42in atom to build this ide
-
03:45but they actually hired on one of the
-
03:47core developers of node webkit to build
-
03:50adam shell
-
03:51which is very actively developed because
-
03:54it's
-
03:55from github and it acts just like
-
03:57node.js runtime
-
03:59it is missing a few key features because
-
04:01really it was just built to run their
-
04:03ide and now they're just open sourcing
-
04:05it so eventually they'll get these
-
04:06features like uh for instance you can't
-
04:08even set like an icon to the app very
-
04:10easily grant you can do it but you have
-
04:13to kind of hack around to do it compared
-
04:15to like what you can do in node webkit
-
04:18so before i talk about like
-
04:20how cool these things are these types of
-
04:22apps there is some things to think about
-
04:24before you like try to build a
-
04:25production app with one of these
-
04:28so it's different i mean this is with
-
04:30all new technology it's going to be
-
04:32different um for instance like things
-
04:34like live reload will not work right off
-
04:37the bat with it maybe actually this
-
04:39stuff's being actively developed pretty
-
04:40quick so there actually might be a
-
04:42plug-in for live reload now
-
04:44but at the time of making this there
-
04:45wasn't
-
04:46and like
-
04:47it's it's just weird and like for
-
04:49instance have you ever made a web app
-
04:51that you've never had that you don't
-
04:53have access to the window object like
-
04:56you always have access to that where you
-
04:57can like just store stuff in there and
-
04:59you can just pull stuff right back out
-
05:01these types of apps you don't have that
-
05:02capability
-
05:04sometimes you have it'll
-
05:06access window a lot of times though
-
05:08and then like there's something that we
-
05:10don't have to deal with as web
-
05:12programmers that you have to deal with
-
05:14with these type of apps which is like
-
05:15uses on different os's usually these
-
05:17browsers just work on these different
-
05:19os's and you have to worry about you
-
05:21know the actual processes and stuff
-
05:23but um
-
05:25you have the same
-
05:26browser but now you you're storing data
-
05:28into different locations i actually have
-
05:31an app that i built that like
-
05:33i had a friend on a mac computer that
-
05:35couldn't run it just for some stupid
-
05:37reason
-
05:39um but yeah that's one thing to look out
-
05:41for
-
05:42um and then actually uh the app store
-
05:44like a lot of people are trying to like
-
05:45release these apps the app store i've
-
05:47heard a lot of nightmare situations
-
05:48where they didn't uh pass
-
05:50uh the app store and then i've actually
-
05:54heard of a few node webkit ones that
-
05:56have
-
05:57but um adam shell i guess there's people
-
05:59trying to do it but a few of the github
-
06:01employees don't think that they're gonna
-
06:04pass
-
06:05and then it's experimental like some of
-
06:07the features that you've used on web and
-
06:10that you've come to love or on node.js
-
06:13some of those features just don't work
-
06:15like
-
06:16granted you can get native plugins to
-
06:17work npm modules that run c code but
-
06:20like there is catches for instance like
-
06:22adam shell
-
06:23is only running version 0
-
06:260 11 9 is the first version that it came
-
06:29out with so if you have a native plugin
-
06:30that's running at 0 10
-
06:33only is compatible with 0 10 versions of
-
06:35node
-
06:36you're going to run into a lot of issues
-
06:37because they did a lot of changes with
-
06:38native bindings
-
06:40but there is before i blame you guys out
-
06:42there is a lot of exciting stuff about
-
06:44this app about these types of apps and
-
06:46one thing that really excites me is that
-
06:47like w3 standards they have a bunch of
-
06:50different specs that come out all the
-
06:51time that like are just like
-
06:53experimental sometimes or sometimes you
-
06:56know have been around for a while but
-
06:58actually these features can be built by
-
06:59just your regular
-
07:01javascript programmer so they can start
-
07:03playing with these types of things right
-
07:05away and actually what's cool is that
-
07:06you can actually learn these
-
07:07technologies before they even come out
-
07:09in browsers so when they do come out
-
07:11it's not something new to you
-
07:14and then you actually have control over
-
07:15the browser as a web programmer there's
-
07:17always been that moment where you just
-
07:19like curse ie8 you know to all hell
-
07:22where like something's broken you don't
-
07:24know why you actually control
-
07:26the the browser that you're running on
-
07:28which is great which means you can run
-
07:30you know all the cool apis that that
-
07:32browser gives you
-
07:34um
-
07:35it's it isn't just a node.js app it does
-
07:38so much more like it has a gui that
-
07:40isn't a terminal i mean i don't know how
-
07:42many times you know
-
07:44a client has asked you for a terminal
-
07:46program that they can play around with
-
07:48because it doesn't happen because
-
07:49clients usually want something that's
-
07:51nice and pretty and something that has
-
07:53an actual gui not just a terminal
-
07:55program
-
07:57it this is for people who like
-
08:00hate saying setting up dbs or they just
-
08:02don't want to do it
-
08:03it actually has built-in web storage so
-
08:05if you wanted to actually get up and
-
08:06started without having to set up
-
08:07something like leveldb or our uh
-
08:10mysql or sqlite or something some
-
08:13embeddable database it actually already
-
08:15has indexeddb and local storage and all
-
08:17that kind of cool stuff in it so you can
-
08:20get started really quick
-
08:21and it has a real dom i don't know how
-
08:23important this is to you but
-
08:25you can actually interact with this dom
-
08:26and see things happening where like if
-
08:28you use js dom and stuff it feels kind
-
08:30of abstract
-
08:31you're interacting with it but it's it's
-
08:33kind of you know something that is um
-
08:36very abstract
-
08:38and then you have access to native
-
08:39features and i'm talking about like
-
08:41native gui features like menus menu bars
-
08:44windows docs start menu and actually i
-
08:47have a demo here of a
-
08:49node webkit app
-
08:51um and this is a note-taking app that
-
08:54syncs up with gist and actually you have
-
08:56access to
-
08:58as you can see here i have you know
-
09:00access to the file menu
-
09:01when i like try to switch apps you see
-
09:03that it's in here
-
09:05let me close that
-
09:07so you actually have access to those
-
09:08types of things which is great because
-
09:11like you i granted you could probably do
-
09:12that with a regular node.js app but you
-
09:14have to hack around to get to it and
-
09:16then it's like kind of awkward without a
-
09:17window to actually show a gui in
-
09:21so all those things were about like node
-
09:23uh like web apps like what abs what uh
-
09:26what web apps do compared to node.js
-
09:28apps so i want to explain why it's not
-
09:31just a web app
-
09:33so you have access to node.js apis like
-
09:36streams file system child processes all
-
09:38kinds of really cool stuff built in and
-
09:41i'm not talking about like file access
-
09:43like you would have in chrome or file
-
09:45access that you would have like through
-
09:47browserify or something you actually
-
09:49have access to the whole file system
-
09:51which is great we'll grant it you have
-
09:52the permissions
-
09:55um and then synchronous module imports
-
09:58these are really great where you just
-
09:59like
-
10:00require something and it's there
-
10:03where like i i can hear you saying like
-
10:05oh whatever you know you can you you can
-
10:08actually do this stuff with component i
-
10:10o or or browserify so why is that
-
10:13important
-
10:14but actually you have like access to
-
10:16like all the npm modules on npm granted
-
10:19there are some um some gotchas where
-
10:22like with native modules and stuff like
-
10:24that where
-
10:25they kind of don't work um sometimes but
-
10:28a lot of the modules will work right out
-
10:30of the box
-
10:32and one thing that's really cool is that
-
10:33you can actually interact with installed
-
10:35programs like git python or like your
-
10:38keychain or something and actually i
-
10:39have another demo showing this
-
10:42so i'm going to go to my terminal
-
10:45switch over
-
10:48and i'm going to go
-
10:53so i'm going to start up the app this is
-
10:54actually an adam shell app
-
10:58as you can see it's showing me like a to
-
11:00do of like a a to do md
-
11:04and actually i'll go into my editor
-
11:07and i'll open up this one let me bring
-
11:09that back
-
11:11so
-
11:12um
-
11:13let's say i want to
-
11:14check off like we went to the the kitty
-
11:17bar afterwards
-
11:18so i save that and then you'll see
-
11:21that it should update
-
11:25so it updated so i'm actually
-
11:26interacting with git here
-
11:28i'm actually
-
11:29just running a
-
11:31um
-
11:33a child process to
-
11:35run git right here so i spawn a get
-
11:39process and then i just spit that the
-
11:41output straight to the the uh
-
11:44the window
-
11:46which is really cool because i didn't
-
11:47have to set up web sockets or or
-
11:49anything crazy to get that running i
-
11:51just it was it felt kind of natural
-
11:53those things just interacting with each
-
11:54other
-
11:56and then also another really cool thing
-
11:58is that i have access to hardware now i
-
12:00have another demo here
-
12:03and i'm not a hardware guy so
-
12:05it's just a little bit of a warning so i
-
12:07have this arduino board hooked up to a
-
12:11like a breadboard with an accelerometer
-
12:13on here
-
12:14and then i have a demo app
-
12:23that i'm going to run and is anybody
-
12:25epileptic because i'm going to change
-
12:27the background color of this thing
-
12:29pretty quickly
-
12:31yeah
-
12:34oh actually real quick it's going to
-
12:35throw an air
-
12:37and that is because
-
12:39i need to be sudo to get access to the
-
12:41usb port
-
12:45okay
-
12:46so give it a second it's going to start
-
12:49turning colors
-
12:50so actually the wiring is probably off
-
12:53on here because i'm not a uh
-
12:56a uh
-
12:57hardware guy but i can actually move
-
12:59this thing around and it will change
-
13:01colors and sometimes you'll get some
-
13:02pretty colors out of it
-
13:04but
-
13:05yeah so i'm actually talking directly to
-
13:07the app from this piece of hardware
-
13:09which i mean i don't know of any web
-
13:12apps that can really do that and i'm
-
13:14using uh johnny five and
-
13:16some hackery to to get this thing
-
13:18working on adam's shell it's kind of a
-
13:20pain to get that kind of stuff working
-
13:22but yeah
-
13:23my name is jacob and thanks
-
13:41um so you can't run these things on
-
13:43mobile phones right now just because you
-
13:45would have to install like an apk or
-
13:49an actual like ios app and these things
-
13:51are mainly for desktop currently so but
-
13:55you can have access to the camera of the
-
13:57computer
-
13:59but again you can do that kind of stuff
-
14:00with web apps as well with get user
-
14:02media and stuff like that
-
14:07so if you were starting a new project
-
14:09would you use node webkit or or adam
-
14:11michelle
-
14:12okay so
-
14:13i should have said this before but the
-
14:14main difference between adam's shell and
-
14:16node webkit is that
-
14:19node webkit your entry point is like an
-
14:21html file so you essentially you render
-
14:24that html file and then you start
-
14:25running the scripts on that html page
-
14:28and that's how you start up a node
-
14:29webkit app
-
14:30and with adam's shell it's different
-
14:33because you have an entry point of a
-
14:35js file so you actually start running
-
14:38the js process and then you can open up
-
14:41windows when your app's ready which is
-
14:42kind of good with like
-
14:44perceived uh performance like oh it's
-
14:47opening up real fast but really you're
-
14:49just waiting before and then opening up
-
14:51the app
-
14:52i would have to say
-
14:53i would probably use adam's shell
-
14:56well
-
14:57it depends because if i
-
14:59if the the timeline was like a month
-
15:02probably node webkit because i need a
-
15:04lot of the features that node webkit has
-
15:06but if let's say it's like six months
-
15:09adam shell probably will catch up in
-
15:11terms of like the nice features like
-
15:13icons and stuff like that in six months
-
15:16so i would probably for a longer project
-
15:18picked adam shell
-
15:21it's written in coffee script oh yeah
-
15:23that is the down part but
-
15:25luckily you can interact with it with
-
15:27javascript
-
15:30okay um i think this is probably not a
-
15:34fair question for you but i've been
-
15:35using atom editor and
-
15:38ui wise visual
-
15:40it's awesome i love it but performance
-
15:42wise
-
15:43it's really sluggish
-
15:46yes
-
15:47you can speak on that at all so you is
-
15:50you're essentially you're not completely
-
15:51native you're still running a web
-
15:53browser you're dealing with all the the
-
15:55rendering of a web browser i mean it's
-
15:57the same performance issues that you
-
15:58would run into with a regular web
-
16:00browser
-
16:01right now it's not completely optimized
-
16:05and i don't think there's you know
-
16:07there's stuff that they can do
-
16:09eventually to to optimize that but i
-
16:11yeah i don't know i guess i'm just like
-
16:14it's almost a proxy question for you i
-
16:16want to ask when i said get up but like
-
16:18are they aware of it
-
16:20yeah they are aware of it actually i i
-
16:22saw recently they pushed a big update
-
16:23for scrolling speeds that's supposed to
-
16:25improve the scrolling speeds actually i
-
16:27have a linux box so i haven't really had
-
16:30the the
-
16:31the royalties of getting to use atom uh
-
16:34the the actual ide
-
16:35until recently so
-
16:37yeah i don't
-
16:39yeah i think they're they're doing stuff
-
16:40to make the performance a little bit
-
16:42better but it's still not completely
-
16:43native
-
16:49can we see the code for the hardware
-
16:51yeah
-
16:53so in the hardware
-
16:56i just require the app here let me blow
-
16:58this up
-
16:59a little bit
-
17:04so i require the app and then with adam
-
17:07they have like this browser window and
-
17:08then this is johnny five it's just a
-
17:11module that i had to install
-
17:13and then i just make a new board
-
17:15when the board's ready i
-
17:17make an accelerometer which is
-
17:21talking to this thing and then when the
-
17:23accelerometer inputs change i emitted
-
17:26event
-
17:27and let's see if we scroll over
-
17:28accelerometer change and that just sends
-
17:31out the data to that event
-
17:34and here i'm just opening up the window
-
17:35when the app is ready
-
17:37and then actually the html file
-
17:41so you have to do like background
-
17:43require remote and then as you see from
-
17:45the background i can require the app
-
17:48and then in here
-
17:49see this is converting it all
-
17:52and right here i listen to the change
-
17:53event so i grab the app and i look for
-
17:55that excel change and then i handle the
-
17:58change which then does some conversion
-
18:01stuff to make it a little bit more like
-
18:02rgb
-
18:05than it comes out as
-
18:11right here so
-
18:13i guess given some of the like cross
-
18:17uh cross os compatibility issues like
-
18:20when
-
18:21what would be the primary use case for
-
18:23this like when would you say yeah we'll
-
18:25do
-
18:26we'll use uh node webkit rather than
-
18:29just we'll build a node app and we'll
-
18:32tell people to run it in webkit
-
18:35um so
-
18:36i think the main use case is when you
-
18:39need something that's um
-
18:43you want to build like a node app that
-
18:45that has some good performance and you
-
18:47want to write node code but you also
-
18:49want access to some modules that you can
-
18:52then like pull out bluetooth or some
-
18:55technology that's just not quite there
-
18:58plus like
-
19:00for instance i i reference the the
-
19:02service worker api or spec that's coming
-
19:05out um
-
19:06and like there's gonna they're gonna do
-
19:08a lot of like network proxy next network
-
19:11proxy and stuff with that to make like
-
19:13caching really good in a browser but
-
19:16with like this type of stuff you can
-
19:17already do like those types of things to
-
19:19where you can have really good caching
-
19:21and really good you know uh access
-
19:24really good like um
-
19:25access to cash assets and stuff
-
19:29so i would say like if you're doing
-
19:30something with hardware it's a definite
-
19:31go because
-
19:33i don't know when you're ever going to
-
19:34be able to like connect up a usb to
-
19:36arduino board and then run like a web
-
19:38app
-
19:39um
-
19:40but besides that there's there is i mean
-
19:43there's a lot of cool things about it
-
19:45but really uh
-
19:47there's not too many differences from
-
19:50the web platform which is kind of nice
-
19:52in itself because then you can you know
-
19:54have very similar code bases if you
-
19:55wanted to make a web app in one of these
-
19:57kind of like native esk apps
-
20:01uh give it up for jacob
-
20:11you