Web Development Stack And Other Things
The web provides a very unique environment to develop in due to the numerous layers it has. At a fundamental level, there is a client and a server, but there can be many layers within both the client and server individually.
I intend this to be an evolving collection of notes on various programming languages, libraries, concepts and implementation details that I use (or would like to eventually use) for the projects I have worked on.
My language of choice is Python. Python is a dynamic scripting language that has an incredible standard library and a plethora of third-party libraries available. Development time is short due to it's terseness and simple grammar, yet since Python requires whitespace for indentation your code stays clean and readable.
I use the Django web framework as the foundation to many of my web sites and web applications. It has a very active community and the codebase is constantly improving.
PostgreSQL is my relational database of choice. I have used MySQL in the past and haven't had too many issues (that is, after I realized how to enable transactions...), but my gut tells me Postgres is simply better. Oracle is expensive. SQL Server is a Microsoft product (though it is one of there better ones). SQLite is excellent for quick setups and testing, but not suitable for database-heavy applications.
I have very little experience in this area, but from the limited usage (and a lot of reading), MongoDB seems to be a pretty solid non-relational database. 10gen seems to be very serious about improving the speed and scalability of it and the query API is very solid.
My typical setup looks like the following:
static/ coffee/ ... js/ min/ src/ page1/ page2/ ...
Each page directory contains a
main.js and any other scripts applicable to that page. I use the optimization tool to combine all scripts into the
main.js file for each page, that way I only need to define a single script for the web page.
I digress.. when I have published APIs and want a dynamic web app, BackboneJS provides a solid, yet simple MVC framework. The
Backbone.Collection classes exists to encapsulates the application's data. Collections can fetch the data from the server (or any other persistence layer) via a GET and can POST new data to the server when a Model instance has been added to the collection. Model instances handle sending updates to their data to the server via PUT requests and if a model instance is deleted, the DELETE request is made.
Backbone.View provides the view layer in MVC and should contain all the necessary logic that interacts directly with the DOM (as suppose to the model layer, which should not). Backbone has an event system that fires all event handlers when certain actions occur on model or collection instances. The views that represents these objects can then bind their own even handlers to update the DOM when certain properties change or when models are created or destroyed.
$ coffee -w -b -o static/js/src -c static/coffee
This command watches the
static/coffee directory for
.coffee files that are created or modified and compiles them to
static/js/src mimicking there path. Thus
static/coffee/foo/main.coffee is compiled and written to
-b flag means "bare" and tells the compiler not to wrap all the code in a closure. In most cases this would be desirable, but since I use the RequireJS optimization tool, this is redundant.