On Github runspired / onyourmark
Javascript is a dynamically typed scripting language most commonly used for web application development.
In Javascript, everything is an object, and all objects are passed by reference.
In the most abstract sense, an object is a constant pointer to specific memory.
In usage, an object is a collection of properties: key : value pairs for specific data.
Some properties are actually functions, known as methods.
Basic objects are used often, but aren't actually that useful.
Most applications eventually need reusable object templates.
Some applications also need to be able to know when an object's property changes.
Sometimes you need more advanced behavior from your properties
Javascript applications typically have three scopes to consider.
Javascript applications typically have three scopes to consider.
Javascript applications typically have three scopes to consider.
I mentioned that functions are objects too. This means that functions also have properties and methods.
We say this above with closures and reusable objects, both of which utilized a function wrapper.
Three function methods you should know about: .call(), .apply() and .bind()
Web applications are "mostly" limited to a single threaded environment.
All of your code, and all the rest of the code on a page, runs on a single blocking thread.
Some modern features (WebGL, CSS Transitions) greatly improve single threaded performance.
Some tricks (using document fragments, caching) are also used to improve performance.
All function calls, including functions triggered by events, are pushing into a single callstack executed in the order they were received.
You can write code to mess with this order in a specific manner (controlled event loop), or you can use setTimeout to delay execution.
alert (usually) pauses the thread.
your entire script finishes executing before delayed functions are processed.
A timeout of 1 millisecond does not mean your code will execute 1 millisecond later.
A timeout (usually) means your code will execute after "at least N milliseconds."
The function invoked later by setTimeout is known as a callback.
A callback is some code you want to run later, after something else has finished executing.
That depends on the circumstance, but often no.
Sometimes you need to execute one function on success, and another on failure.
This is especially true when requesting data from an external location.
The solution: promises
Promises are functions that execute one function on success and another function on failure.
Promises can be chained and grouped
Libraries that provide a promise feature should conform to the Promises/A+ spec.
RSVP.js is one such a library, and is used within Ember.js
Sometimes you have a collection of unrelated promises for which you need to ensure all succeed.
Sometimes you will want these promises executed in a particular order.
Events, Callbacks, setTimeout, Promises, and AJAX collectively make up "asynchronous behavior".
The web is driven by asynchronous behavior; AJAX is an acronym for...
Asynchronous JavaScript and XML (AJAX)
AJAX Requests typically utilize a basic HTTP request to send or retrieve data.
Basic HTTP requests have a connection that closes quickly and cannot handle much data.
Other request types involve HTTP Long-poll, WebSockets, and Flash Sockets.
Most "real-time" applications utilize all four request types in order to support all browser environments.
TCP/IP:
Socket:
Port:
HTTP: (Hyper Text Transfer Protocol).
Essentially the HTTP connection gets held open longer so that it can be reused and more data sent through as it becomes ready.
HTTP and HTTP Long-Poll real time solutions involve a constant stream of new HTTP requests to ensure that one connection is always present as soon as the previous connection closes.
The Java based Flash plugin offers a socket API allowing for streaming. Where available, flash sockets are the most stable and reliable transport.
Concerns about Java and Flash security as a whole mean that this transport option is often under-utilized.
Custom Java plugins and applets can provide sockets as well, but these would need to be installed by the end user.
WebSockets are a new browser API that allows for a "socket-like" transport.
WebSockets aren't widely supported yet, but most modern browsers have a stable enough implementation for us to utilize them extensively.
Web standards, browser APIs, and browser environments are always-changing.
What works in Javascript, HTML, and CSS today might not work tomorrow and likely didn't work yesterday.
People do use older browsers.
Even "modern" browsers have differing opinions on what the standards specs mean or should be, and implement them differently.
The idea that technology should support the most recent standard, but "gracefully" fallback onto older standards when needed.
Works pretty well for HTML / CSS support.
Was the design principle behind "APE" and "Socket.io", but has been proven a flawed approach.
This causes problems because feature detection can take a while, can fail to ever resolve, and doesn't meet user expectations for fast connections.
The idea that technology should support the most basic version, then "gradually enhance" the experience for devices supporting newer standards.
Works really well for video, audio, and "web real-time"
Is the design principle behind "engine.io" as well as YouTube's video player.
API stands for "application programming interface".
An API is a collection of named functions that are grouped by a "namespace"
Most of the time, an API is synonymous with a "code library"
They can be that too!
An API is a way to expose properties or methods to a user.
In a web based API, these properties and methods are accessd via URL instead of by invoking a function call.
In API driven development, an engineer scaffolds the functions or data an API should expose, then implements (programms) scripts to actually do so.
API driven development
At it's most basic level, a framework is a collection of APIs that help you build applications faster.
Framework's also help you organize your code and provide ways to build more re-usable code.
Advanced framework's make important design decisions for you.
Code organization is always important. Both Time and Scale harm projects, great organization lessens this harm and makes projects maintainable.
What starts as a few jQuery scripts often balloons into a tangled mess. Tangled messes are unmaintainable. Using a framework will often help you produce more, even on smaller projects.
Sometimes, even the simplest app can be made better with a framework.
If you consider it a "web app" and not a "web page", then you definitely need a framework.
Ideally you should know what these design decisions are, and why they are good/bad design decisions when you evaluate a framework for use in a project.
In practice, most engineers know little about the guts of the framework they use.
Use something you mostly understand, that has good documentation, strong examples, and a vibrant support community.
When it comes time for it, hire someone more experienced to make the informed framework decision.
Ember has good, but not great documentation. (Missing version based documentation)
Ember has good, but conflicting examples. (Ember has changed a lot in the last few years, not everything you read is right).
Ember "is too hard/complicated"
Ember "is Beta"
Ember has an amazing support community.
Ember is supported and used by the biggest names in the industry.
You've been exposed to the idea's in Ember before, as "Sproutcore".
Sproutcore is the foundation of Apple's and Facebook's web interfaces.
Ember is currently the choice framework of Groupon, Living Social, Apple, and Yahoo
Ember's design decisions are proven best practices.
Ember isn't "Beta", but be careful: ember-data most definitely is.
Ember's learning curve can be steep, but the payoff curve is far steeper.
Ember uses handlebars.js for templating and metamorph for content binding (as do most frameworks that allow for live-binding). This inserts script tags that decrease rendering performance and prevents some CSS selectors used by Bootstrap from operating correctly.
The Ember team is close to releasing HTMLBars. This will solve the Bootstrap issue, and will also make Ember the most performant framework on the web. In some test cases, HTMLBars results in Ember out-performing default native rendering.
An introduction to radid web application prototyping with Ember and Firebase