Home page

www.spannerjs.com

Nuget

www.nuget.org/packages/Spanner

Project Description

Spanner is a domain-specific language, embedded in C#, for building highly reliable single-page web applications.

Spanner is built around the following principles:

  • Using a single, statically typed programming language for all aspects of a web application (HTML, JavaScript, model/view binding, etc.) allows for dramatically faster, more dependable development.
  • The MVVM style (model/view/view-model) allows for declarative UI coding, which is far simpler than traditional, principally event-driven approaches.
  • A good solution should provide mechanism, but impose only minimal policy: how you design your application should not be dictated by the tools you use.
  • A good solution should use familiar technologies and should integrate well with third-party libraries.

Spanner is essentially a domain-specific language implemented as a set of C# classes corresponding to HTML elements and JavaScript statements and expressions.  The Spanner type system transparently abstracts Knockout MVVM observables and bindings.  A Spanner solution is just a C# program which, when run, generates the static HTML and JavaScript files implementing the web application (that is, the resulting web pages are deployed independently of Spanner and the originating program).

While the Spanner approach is different, the vocabulary is familiar: every HTML element, every well typed JavaScript construct, and every well typed Knockout construct has a corresponding Spanner method of the same name.

Because a Spanner solution is rigorously and statically typed, almost all programming errors are immediately flagged in the Visual Studio error window.  Moreover, the full gamut of C# abstractions and refactoring opportunities are available to the programmer.  "Stringly typed" programming, where identifiers and code are embedded in HTML strings, is completely absent.  This, plus the immediate error reporting via C#'s static type checking, make web programming in Spanner substantially less error prone than traditional approaches.

Motivation

I come from a functional programming background where writing complex programs that work first time is not uncommon.  This happens in great part due to rich, statically checked type systems.  In my experience, people who have never worked seriously with these languages cannot readily appreciate just how much more effective is this style of programming (to put it simply, a single type declaration amounts to a universe of unit tests that you didn't have to write and never had to run).

My commercial career has involved a substantial amount of web development.  I cannot believe what a dismal, primitive, ad hoc mess is the world of web application programming.  Type systems are all but absent, standard abstraction tools (i.e., functions) are, at best, bolted on as a collection of awkward tricks, and "stringly typed programming" is the norm, where identifiers and code are embedded in HTML.  The whole mess is overly complex and utterly tedious to debug; there is all but no protection from even the most basic programming mistakes -- even basic typographical errors are often only caught through user testing!  Yes, there is a plethora of attempts to make life better, but none that I have seen address the core problem: you need to be able to express checked, end-to-end constraints in a single, convenient language.  Spanner is my attempt to do this in a form accessible to non-functional programmers.  If you agree with my assessment of contemporary web development, I hope Spanner is a good solution.

Last edited Sep 9, 2014 at 7:46 AM by ralphbecket, version 7