RFC 6455 – Websocket


I have been exploring Websocket RFC 6455 recently and wanted to share my thoughts on this HTML5 addition to web technologies. Websocket provides an API and HTTP upgrade mechanism to take a standard HTTP request and upgrade it to a bi-directional socket connection. The standard includes a simple JavaScript API to instantiate a new socket and listen for events connect, close, message while being able to send messages programmatically.

Port 80/443 - The first barrier with any network communication is firewall traversal. Port 80(HTTP) and Port 443(HTTPS) are typically open both ways within firewalls. Although Websockets can operate on custom ports, they default operation to using port 80/443 depending on the protocol selected. The key is that HTTP has always used TCP/IP Sockets to communicate. When you make a URL GET/POST/HEAD request you make a TCP/IP socket connection to the target server and send a header. The server responds and closes the connection unless it is using HTTP1.1 which simply provides more persistant connections supporting multiple requests.

2 Way – Websockets allows the server or client to send messages at any time without requiring a request. After the initial HTTP handshake, you can send data to the server and the server can send data to the client. The key is that a request does not imply the server will respond and thus there are 2 independent channels of messages.

I tested Websocket using Play (Java) and Tornado(Python) Frameworks and found it trivial to get up and working with Websockets quickly. Both frameworks provide a simple means to defining a route to serve the Websocket handshake and provide events for events. Given the symmetry within the Websocket, both client and server are very similar in API. Here is the Websocket Class in Play and Tornado:

#Tornado Framework - Websocket Class
class EchoWebSocket( tornado.websocket.WebSocketHandler ):
  def open( self ):
    print "WebSocket opened"

  def on_message( self , message ):
    print "You said: " + message
    self.write_message( message )

  def on_close( self ):
    print "WebSocket closed"
//Play Framework - Websocket Controller
public class Application extends Controller {
  public static WebSocket<String> live() {
    return new WebSocket<String>() {
      public void onReady(final WebSocket.In<String> in, final WebSocket.Out<String> out){
        in.onMessage(new Callback<String>() {
          public void invoke(String event) {
            out.write("onmessage:" + event);
          } 
        });

        in.onClose(new Callback0() {
          public void invoke() {
            Logger.info("onclose");
          }
        });
        out.write("Connected");
      }
    }
  }
}

Compatibility – Today the Websocket API is deployed in the following browsers: IE10+, FF14+, Chrome 21+, Safari 6+, Opera 12, IOS 6+, Chrome Android 4+, and BB7+. With proper fallback to Flash Player on desktop browsers, this provides a very solid base of support.

JavaScript API – The JavaScript API is fairly simple to use. You simply create a new instance of WebSocket and pass in a ws:// or wss:// uri to the target server. Here is an sample:

socket = new WebSocket( "ws://example.com/live" );
socket.onopen = function( event ) { onOpen( event ) };
socket.onclose = function( event ) { onClose( event ) }; 
socket.onmessage = function( event ) { onMessage( event ) }; 
socket.onerror = function( event ) { onError( event ) };

There are some interesting service possibilities with Websockets allowing clients to query a services layer within a persistant socket connection. The hard part with Websockets is handling scalable server architectures where messages must traverse multiple servers between multiple clients. Although this is a very solvable problem with messaging libraries like ZeroMQ and server to server socket connections.

Try Websockets out! Here is a full Websockets server written in Tornado Framework in Python. It is a single file and should be fairly easy to run once you install the Tornado libraries into Python locally. Instructions for installation are located within the file itself.

Cheers,

Ted :)

Changes


Friday 9/28 will be my last day at Sencha and marks 20 days until the birth of my daughter. I am departing Sencha to focus on family and return to working as a consultant and entrepreneur.

I have been extremely lucky over the past 7 years to work for some amazing companies (Adobe, Barnes & Noble, Sencha) and I have learned a ton about business and large scale software development in the process. Sencha has been a great experience working inside a world class, fast growth startup at the heart of HTML5. In my short time at Sencha, we focused on enterprise, delivered major releases of every product, added 30+ people to the company, and welcomed a ton of application developers to the platform. It has been a distinct honor to work at Sencha, build a great developer relations team, and work with so many amazing developers in the community.

As an evangelist I only advocate for technologies that I believe in and my path has included Flash, Flex, Android, and Sencha. In the case of Sencha, I am giving up employment to build services using Sencha as a platform. I am not sure there is a better validation of Sencha and given the large scale use of Sencha frameworks at Adobe, SalesForce, Cisco, Concur, Morgan Stanley, and many others; I know this is a very sound decision.

Having started-up straight out of college, I have yet to see an entrepreneurial climate as good as today. With a command line, I can launch hundreds of servers, leverage a ton of revolutionary code, and work with amazing people remotely. The costs of starting-up have literally fallen an order of magnitude in the past 10 years and executing projects has never been easier. During my time at NOOK, I launched 63 apps which turned into a solid recurring revenue business. This success enabled me to leap quickly to Sencha and with upcoming family changes has evolved into my return to being a consultant and entrepreneur.

Long story short, I am an entrepreneur at heart, I love solving problems, and I love building things. This change allows me to focus on family while executing on a project that has been burning a hole in my pocket. For now… family, family, family!

Regards,

Ted :)

Which Framework? Document to Interactive to Application


Since joining Sencha, I have been constantly asked to compare Sencha’s web frameworks to others. Truth is comparing frameworks really depends on the user experience you want to deliver and the resources available to deliver that experience. There is an infinite spectrum of experiences possible between Document to Interactive to Application and there is a parallel set of frameworks, boilerplate, scripts, libraries for every type experience possible. Name a web toolset and you can place it on the Document to Interactive to Application spectrum fairly easily.

Sencha’s frameworks sit at the far right of this spectrum on the Application use case and fade in purpose towards the Interactive center. While you can use Sencha to deliver interactive pages, documents, or mobile websites, our tools are really 100% geared towards professional developers building native-like application experiences with web technology. Sencha provides an object-oriented and component-based paradigm for building web applications for desktop and mobile. Here are some features of Sencha’s frameworks to make it clear what I am talking about:

  • OOP - Inheritance, Packages, Mixins, Class loading with dependency support.
  • MVC – Integrated Model, View, Controller with route support
  • XTYPE – Declarative component composition. Create and load views easily.
  • DATA – Models, Stores, Connectors for simple typed server/service integration
  • UI – Modern UI Controls and Containers
  • Integrated – Everything is designed to work together.
  • Cross-Browser – Pixel perfect on every supported browser engine

While I would love it if everyone starting using Sencha frameworks, not every experience should use Sencha frameworks. I would strongly encourage you to learn and understand the diverse set of frameworks and options out there. I have learned a ton by trying out all the different web frameworks and understanding what types of experiences they best make. In many cases, their might be a better framework fit for the project you are building and you should explore your options. Most importantly get really specific about what type of experience you are creating:

  • Is it an application?
  • Is it interactive?
  • Is it media driven?
  • Is it a game?
  • Lots of pages without much interactivity?

Choose carefully, I keep seeing projects start with one framework only to watch the experience drive the chosen framework to its absolute limit. There is nothing worse than building on the wrong stack and having to refactor and rebuild with a framework switch. Make sure you know and understand the framework limitations and make sure the highest risk part of your experience is covered.

Now if you are building mobile or desktop applications experiences with web technology, we should chat. :)

On Tuesday 2/14, I will be presenting a webinar on Flex to Sencha which will focus on explaining the details of Sencha’s frameworks.

Cheers,

Ted :)

Joining Sencha: The Intersection of Applications and The Open Web


I am joining Sencha to build a world-class developer program but in a larger sense I am returning to the intersection of Applications and The Open Web. I wanted to share my thoughts on why I am returning to web technologies and highlight some industry trends that are rapidly driving change within the software industry.

I believe that we are witnessing a sea-change in the platforms upon which software is built and delivered. Long term, I believe all software will be built with web technologies across enterprise and consumer facing applications.

Here are a few trends driving this change:

1. Web Innovation – Browsers and the core fabric of web technologies are innovating rapidly again. CSS, JS, HTML are changing to enable running first class applications in the browser with no dependencies.

2. Web Performance – The performance of web technologies has eclipsed end user performance requirements. JavaScript performance has improved dramatically in the past 3 years and browser rendering performance is in most browsers now leveraging the GPU for rendering. Fast code and fast graphics are essential elements to building great end user experiences.

3. Computing Cost & Capability – The ecosystem surrounding ARM is lowering hardware costs while delivering exponential performance growth in mobile and will soon engulf desktop and server markets.

4. Touch – Sensors for touch both physical and virtual (Kinect) are enabling simpler UI across devices.

5. Native Capacity – Few companies have the team capacity to deliver native applications across multiple platforms successfully. I am seeing many developers leverage web technologies within native applications to simplify development and reuse existing content, servers, and services.

6. Utility Computing – Services are changing how software is created, sold, and deployed server-side.

7. Mobile – Everyone will have a browser in their pocket… Everyone!

Now while the trends and market opportunity seems crystal clear, the reality is there are actually very few companies actively delivering “professional grade” web technology solutions that “just work”. Sencha stood out for me for a few reasons:

1. Team – An exceptional team with world class leadership and focus.

2. Opportunity - The Intersection of Applications and The Open Web

3. Customers - Read the list, it speaks volumes.

4. Products - Professional engineering teams building high quality frameworks, tools, and services for developers.

I am very excited to join Sencha to build a world-class developer program and to return to investing in web technologies full time. Exciting times ahead!

Cheers,

Ted :)

Thanks NOOK!


Today I resigned from B&N NOOK Apps to embark on a new journey in my career. Before I talk about the next destination, I wanted to talk openly about my time at NOOK Apps and say thanks to those who made it great.

NOOK Apps was an amazing journey and will always be a highlight of my career. The opportunity to build a marketplace for applications atop a new class of content centric device was big, complex, and a ton of fun. I joined a small team and we built out all the required elements to succeed from scratch in 5 months.  We launched NOOK Apps with 136 apps within an operating system update to NOOK Color. We went from 0 to millions of app installs per month and worked non-stop to make the platform better for all developers building applications. Over the past year we have helped thousands of app developers monetize great content on a new platform in a new market.

The best part of working on NOOK Apps was the team. I have worked with great teams before but never quite as good as the team on NOOK Apps. Every role was filled with a person with vast experience in the mobile space and together we made NOOK Apps a success.

Claudia, Simon, Tavares, Steven, Josh, Gideon, Cary, Titus, Eric, Ron…

Thanks, You made my time at NOOK great and we accomplished allot working together as a team.

As for next steps for me…  I will save that for tomorrow.

GO NOOK GO!

Thanks for all the fish!

Ted :)

Living in the Future


What if you received a copy of the Wall Street Journal dated November 12, 2015, today?

What if you knew what the future would be like 5 years from today, and better, how things would play out?

Where would you invest?

What problems would you solve?

What would you start to build?

For the past decade, developers within the Flash ecosystem have been living in the future building upon a stable consistant runtime with great tooling and advanced text/graphics/animation/vectors/video APIS for building interactive applications. As an ecosystem, Flash enabled amazing things, impossible things, fantastic things with a technology with very humble beginnings centered on vector graphics. I spent the last 12 years working with Flash professionally and evolving with the medium over that time has been an honor and highlight of my career.

A few years back browsers began innovating and that innovation is beginning to fix many of the inconsistencies and capabilities once only privy to Flash. While still in their infancy around rich media, browsers and standards based platforms will evolve along a similar path to the Flash ecosystem’s evolution over the last decade. The same problems, patterns, solution, services, tools, tips, tricks, and know-how will be required to make this standards based ecosystem as vibrant as Flash is today. The fact is that knowing Flash is far more than just knowing ActionScript or a raw Adobe tool, it is the knowledge of how to build rich interactive content. Much of our knowledge domain is not in implementation details but rather understanding the nature of interactive media, architecting a proven interactive solution, and balancing usability, design, and interactivity to create a great experience. In short, you have a massive upper hand in an emerging market called HTML5 and Adobe is shifting resources and investing there too.

Exploring OpenGLES – A break from Flash

For the past 8 months, I have been personally exploring and investing in tools and technologies that are focused on leveraging fast graphics and hardware acceleration using OpenGLES. As I work for Barnes and Noble on the NOOK Platform, I wanted to figure out how best to deliver fast graphics within native apps on NOOK with a lower end hardware profile (800Mhz 256Mb OpenGLES 1.1 & 2.0). Given that Flash/AIR does not directly support an OpenGL-like surface today on Android, I explored several alternatives that included CoronaSDK, Moai, Marmalade, but have settled on using the native Android SDK with ANDEngine. The output results on NOOK Color are 60fps regardless of the volume of graphics and textures I throw at the displaylist. Physics, fast vm, great java tooling, it is a real treat to develop interactive content this way! This exploration was hugely enlightening for me and has made me realize that even when I completely switch stacks my interactive skills I perfected with Flash are extremely relavant. Even the easing equations were a java port from Robert Penner’s work.

Truth is, things have changed but the foundational knowledge of interactive development will remain with us all long term regardless of what platform you target. Should you choose to focus on native or open web apps, you have a great advantage, once upon a time you lived in the future called Flash.

Cheers,

Ted :)

PS. Adobe please improve the performance of AIR on Android.

Perspective Matters


This past week I got very frustrated at a process at work. Initially I thought, surely this is broken. How could something this simple be architected this way. So I decided to understand and I dug deeper. After about 2 days of digging I found some dependencies that forced the very solution that I was complaining about. Had I been in the shoes of the creator, I would have been forced down the same path.

From the outside, problems can look trivial but inside, there is often far more at work.

As technologists we are ready to declare something stupid, silly, wrong at first glance and at times say, “I could do that better”. Behind any problem is a larger more hidden set of dependencies and problems. Problem is that often dependencies are invisible and the larger problems are hard to see unless you went though the hard lesson of actually building something under the same circumstance. It is easy to judge but solving real problems is often dramatically harder than it looks.

Perspective Matters.

cheers,

Ted :)