Showing posts with label sinatra. Show all posts
Showing posts with label sinatra. Show all posts

Sunday, August 25, 2013

Scratching the surface with flask

Python is a strange beast. These days, I am trying my hand at django and right now am trying to do a bit of development in flask. As I was doing web apps in java/ruby before this, it is quite natural for me to compare django with rails and flask with sinatra.
However, I find flask a little bit more verbose than sinatra as it has a little bit more verbose metadata. Check out the following yourself:
 
from flask import Flask              require 'sinatra'
app = Flask(__name__)

@app.route("/")                      get '/' do
def hello():
  return "Hello World!"                "Hello World!"
                                     end 
 if __name__ == "__main__":
 app.run(debug=True)


To start off with, one of the nice feature is the presence of reloader by default in flask. If I saved the python file with syntax errors, the program crashed in the terminal. This is different with sinatra as it needs to be restarted (sinatra-reloader is not present as a default). The template engine, jinja (rhymes with ninja) is reminiscent of mustache template to an extent. However, instead of yielding within a master template, all the child templates must extend the master template itself.
So far, I have created a simple application that was previously working in sinatra in little over an hour. My initial experience is a tad disappointing with nothing really worthy of a mention. However, it can be deployed to platforms like google app engine that support python or heroku which pretty much supports all open source platforms now.

Friday, April 5, 2013

Book Review: Jump start sinatra



The book is a good starting point for a new as well as intermediate experts having background in developing web applications in ruby.
However, this book assumes a basic level of competency in developing web applications as it is obvious from the very less emphasis placed for discussing over concepts like git, css, javascript and html. Since it assumes that a user knows ruby and has a basic idea if not familiarity with Ruby On Rails, rather than repeating basic information all over again, the focus is more on latest tools such as heroku, sass, coffescript that are more complex, but are more relevant if seen from a point of an intermediate or professional developer.

The book is centered around end to end application development of a sample website and lays emphasis on adding new features over it during the course of different iterations as is done in real life.
Considerable mentions go to deploying the website over Heroku as well as introduction of DataMapper  ORM.
While this incremental approach of building a sinatra powered application makes perfect learning for beginners, lack of pointers related to advanced solutions, tackling issues like setting up environment, debugging, etc are felt as the books usability seems constrained by the simplistic pattern it adopts.

After a high level introduction, a basic website is created, using different views. Next, a basic CRUD functionality with database is exposed and the application is deployed live, this is followed by additional DRY concepts available in sinatra and the book caps off its learning with creating modular sinatra applications and enhancing its functionality by demonstrating a custom framework.

Overall, this is a 150 page neat  and to the point book for people interested in sinatra.

Note: This book has been provided to me for reviewing under the Oreilly Blogger Review Program.