2. Old JavaScript Over 15 years old Implemented everywhere: Browsers, Web Servers, Scripting, Phones Server Implementations (Old): Netscape, Rhino (JVM), Microsft IIS Old JavaScript feels “old” Namespacing, polluted globals, poor inheritance, not very modular.. Those platforms don’t give you much
3. New and Modern Tricks Modules, Namespacing “Separation of Concerns” Model, View, Controller (MVC): Request Routing (Controller) Object Relational Mapping (Model) Templating (Views) Binary, UTF-8, JSON, Callbacks Concise and Elegant
4. Microsoft Javascript JScript on IIS (ASP) Not modern or cool, but old, stable and Windows hosting can be found everywhere JScript.dll updated with IE (up to 8) so it’s not ancient Not JScript.NET, not JIT, but quick enough (compared to other interpreters of it’s era)
5. Why JS on the Server Code re-use, sure.. Real strength: Heaps of stuff already written and tested: Parsers, Crypto, ORM, Testing, etc. (I’ve even seen a Linux Emulator) Expressive and Powerful: Callbacks/handlers, Query Iteration, flexible inheritance, extendibility (override built-in methods) Poor dates, formatting, etc. But easily fixed.
6. The Framework Event Binding Bind to the “ready” event to attach controller code / route handlers Routes: Sinatra-style; named parameters Modules: load modules similar to common-JS Templating: compile your data in the route handler and then use template module to render your view Data Models: create your models, validation, methods and relationships Clean separation of code, helpful, intuitive interface
11. Now the Cool Stuff ActiveRecord for JavaScript Powerful modeling, no writing SQL HTML Parser, DOM implementation and jQuery on the Server Read html files from file system and populate with dynamic content Webpage scraping with ease Node.js based dev-server Uses windows scripting host behind Node to use framework without Schema-less doc-store, Binary, Crypto, Advance language/full-text-search features, Persistent sessions with namespacing, etc.
16. Weaknesses and Future Development Needs better testing library (qunit) Debugging could be easier SQLite Adapter almost Working on adapters for other Server JS platforms (Apache + v8, Rhino on JVM) Good abstraction layers makes it not too closely coupled to current platform
17. Wrapping Up What can be learned from Do It Yourself Not Re-inventing the Wheel Re-using other open-source code Github: http://github.com/sstur/aspjs